Chapter 4
Random Thoughts: Building a Simple Game
In This Chapter
Generating random numbers
Designing a game
CSS styles through code
Building the components
Writing the gameplay code
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 1–3.)
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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access