Game Development Reference
In-Depth Information
Perform the following steps to create the code to respond to the game start and create
one brick for each grid:
1. Start with a
when I receive <game_start>
broadcast message block.
2. Set the index of the new grid to
0
using the
set <new_grid_idx> to ()
block.
3. Set the index of the minimum grid to
0
using the
set min_grid_idx to ()
block.
4. Set the maximum scrolling amount to
480
and the grid count to
0
using the
set
<max_scroll_amount> to (() * ( grid_count - () ))
block.
5. Then, for each plaform, create a clone and assign it the clone plaform index.
First start with the
repeat unil (new_grid_idx > grid_count)
block.
6.
Inside the
repeat unil (new_grid_idx > grid_count)
block, place a
create clone
of <myself>
block. Then, enter
1
in the
change <new_grid_idx> by ()
block.
Before building the scripts, let's irst look at how to ind iniial and current posiions
of the scrolling sprites.
Assume that your game grids look like the following screenshot, all the bricks start with
x=
0
inside their grid, thus point to the center of the grid. In the grids, however, each brick
is at
(my_loc_in_grid + 1/2*grid_width + grid_width*my_grid_idx)
. The Food sprite's iniial
posiion is computed in the same way. In the example that follows, brick 1 starts at x=
480
,
and apple starts at x=
680
.