Super Copter update – jet fighters and bombs

I have been putting some effort in to refining the Super Copter game code and playing with the concept of spawning jet fighters way off screen. The simple reason for this is that they can then attack the player from right to left. I handle all jet sprite movement in a single function and randomly modify the altitude of the fighters with a random “bob”. This is reasonably satisfying although I’m convinced that diving jets would be a whole lot more satisfying.

Something that I wanted to implement was “smart” bombing. I wanted the jets to target the player with their bombs sensibly based on their position in relation to the player. Here is a verbose look at the code I currently use:

if (oPlayer.y < o.y) // Player above
{
if ((o.y – oPlayer.y) < 100)
{
o.x > oPlayer.x ? oAlienBomb[a].direction = 6
: oAlienBomb[a].direction = 2;
oAlienBomb[a].speed = nGroundSpeed + rnd(2) + 2;
} else {
o.x > oPlayer.x ? oAlienBomb[a].direction = 5 + rnd(2)
: oAlienBomb[a].direction = rnd(3) – 1;
oAlienBomb[a].speed = nGroundSpeed + rnd(2);
}
} else { // Player below
if ((o.y – oPlayer.y) < 100)
{
o.x > oPlayer.x ? oAlienBomb[a].direction = 6
: oAlienBomb[a].direction = 2;
oAlienBomb[a].speed = nGroundSpeed + rnd(2) + 2;
} else {
o.x > oPlayer.x ? oAlienBomb[a].direction = 3 + rnd(2)
: oAlienBomb[a].direction = rnd(2) + 2;
oAlienBomb[a].speed = nGroundSpeed + rnd(2);
}
}

Hopefully you can see what I’m trying to achieve. Directions run clockwise from 0 (North) through to 7 (North West). I only implement 8 core directions and modify them as required.

I’m going to document this “smart” stuff in more detail at some point since I think it really makes the difference between a game experience and a game challenge.

Advertisements
Post a comment or leave a trackback: Trackback URL.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: