Chapter 3

Coding Like a Pro

In This Chapter

arrow Learning more about variables

arrow Making decisions with conditions

arrow Repeating with loops

arrow Debugging your programs

arrow Breaking up your code with functions

Computer games are complex. They are about a lot of information: scores, maps, characters, and all the data they represent. You also have complicated instructions. Even simple games are complicated enough that you’ll need to break them into smaller segments. You’ll also find that some of your code is repetitive. You’ll also want the computer to make decisions so the enemy characters will appear to think and the game will respond to different circumstances in different ways.

The basic ideas of programming are the same in any language. Programs are about data, which is stored in variables. You’ll sometimes have a chunk of code that you’ll want to combine into functions. Your program needs to do different things in different situations, and sometimes it needs to be able to repeat things. Sometimes ...

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.