HTML and CSS Reference
In-Depth Information
Replace your background object code with the following code so it displays an image. You
must get background.jpg from Manning's source files and place it in your root directory for
the listing to work.
Listing 6.4. game.js—Default JavaScript
Now that you've set up the main engine components, the next step is to create the game's
visual assets. If you have no experience creating visual assets with a language like C++,
you might find some of the following listings difficult. Once you've completed the list-
ings, you'll understand basic concepts that you can use for 2D programming in multiple
6.2.2. Creating dynamic rectangles
Bricks are the easiest shape to create because they're rectangles. Rectangles in Canvas are
clear, filled, or outlined and accept four parameters, as shown in figure 6.5 . The first two
parameters determine the spawning position (x and y on a graph). Although the current
Search WWH ::

Custom Search