Chapter 4

Random Thoughts: Building a Simple Game

In This Chapter

arrow Generating random numbers

arrow Designing a game

arrow CSS styles through code

arrow Building the components

arrow Writing the gameplay code

arrow Testing your game

If you can build an HTML page and write some JavaScript code, you’re almost ready to write a game. (If you aren’t comfortable with those skills, you may want to glance over Chapters 13.)

However, a game is more than just code. This chapter explains how to build a complete (if basic) game that involves real-time interaction with the user.

Creating Random Numbers

Random numbers are a key part of game programming. Often you want some kind of random behavior. This is used to mimic the complexity and unpredictability of the universe. Most languages have a random number generator built in. This special function produces some sort of semi-random number. Often you’ll have to do some manipulation ...

Get HTML5 Game Development For Dummies now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.