HTML and CSS Reference
In-Depth Information
Saucers
Unlike Atari's
Asteroids
game, which has both small and large saucers, we are going to have
only one size in
Geo Blaster Basic
. It will be stored in the
saucers
array. On a 28×13 grid
(using paths), it looks like
Figure 8-6
.
Figure 8-6. The saucer design
The variable attributes of the
saucer
object are very similar to the attributes of a
rock
object,
although without the rock
scale
attribute. Also, saucers don't have a rotation; it is always set
at
0
. The saucer also contains variables that are updated on each new level to make the game
more challenging forthe player.Here are those variables, which will bediscussed inmore de-
tail in the upcoming section
Level Knobs
:
newSaucer
.
fireRate
=
levelSaucerFireRate
;
newSaucer
.
fireDelay
=
levelSaucerFireDelay
;
newSaucer
.
fireDelayCount
=
0
;
newSaucer
.
missileSpeed
=
levelSaucerMissileSpeed
;
Missiles
Both the player missiles and saucer missiles will be 2×2-pixel blocks. They will be stored in
the
playerMissiles
and
saucerMissiles
arrays, respectively.
The objects are very simple. They contain enough attributes to move them across the game
screen and to calculate life values:
newPlayerMissile
.
dx
=
5
*
Math
.
cos
(
Math
.
PI
*
(
player
.
rotation
)
/
180
);
newPlayerMissile
.
dy
=
5
*
Math
.
sin
(
Math
.
PI
*
(
player
.
rotation
)
/
180
);
newPlayerMissile
.
x
=
player
.
x
+
player
.
halfWidth
;
newPlayerMissile
.
y
=
player
.
y
+
player
.
halfHeight
;
newPlayerMissile
.
life
=
60
;
newPlayerMissile
.
lifeCtr
=
0
;
newPlayerMissile
.
width
=
2
;
newPlayerMissile
.
height
=
2
;