Game Development Reference
In-Depth Information
} else {
tempShot.update();
}
}
Figure 5-8. Shots exploding into Flak
Now, we need to iterate through our
Flak
explosions. Unlike
Shot
's, when
Flak
's explosions are
set to
finished
, we simply remove them from the screen. We don't create anything else or play
any sounds. You will notice that the rest of the objects we iterate through operate in a nearly
identical manner.
for each (tempFlak in flakArray){
if (tempFlak.finished) {
removeItemFromArray(tempFlak,flakArray);
} else {
tempFlak.update();
}
}
Updating
Enemy
,
Explosion
, and
BonusPlane
objects works just like updating
Flack
explosions.
for each (tempEnemy in enemyArray){
if (tempEnemy.finished) {
removeItemFromArray(tempEnemy,enemyArray);
} else {
tempEnemy.update();
}
}
for each (tempExplode in explodeArray){
if (tempExplode.finished) {
removeItemFromArray(tempExplode,explodeArray);
} else {
tempExplode.update();