O'Reilly logo

HTML5 Game Development For Dummies by Andy Harris

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required