2008-03-02

The Secret Posts - Attack Waves

(Written 04/02/2008)

I’ve been debating how attack waves and levels are going to work. The simplest solution, and the one I’m probably going to go with, is to add a “_level” variable to the Game class that stores the current level number, along with a “_distance” variable. This will store the distance that the player has travelled during the level.

With these two variables, I will know where the player is in the overall game world and can use that data to trigger new enemies. The code will look something like this:

switch (_level) {
    case 1:
        switch(_distance) {
            case 10:
                createNewRocket();
                createNewRocket();
                createNewUFO();
                break;
        }
        break;
}

In the above code, two rockets and a UFO are created when the screen scrolls 10 pixels upwards in level 1.

I might even create level objects containing this logic to keep the code tidy. That way, each level can implement its own “createNewUFO()” function, so each level can inject its own movement and cannon engines into the enemies.

One nice touch in Sagaia/Darius 2 is the concept of attack waves. If you shoot all of the first wave of enemies that attack you get a bonus. If you miss one, you don’t get the bonus. This would be achievable by adding in a “wave” property to the (newly created) Enemy class, and keeping track of the number of alive/dead enemies in each wave in the Level object. Attack waves are great because they add an element of strategy to the game - do you go for the single high point value enemy that takes half a dozen shots to kill, or do you shoot the enemies in a fast-moving but weak attack wave? Individually they aren’t worth many points, but they will give you a big bonus if you manage to get them all.

The argument against implementing attack waves is two-fold. I haven’t got enough time - I might come back to it later. The second argument against it is that I want score bubbles to appear for every enemy explosion, not individual bubbles for waves of enemies. This is part of my idea that an excessive amount of movement on the screen will compensate for the lack of colour. I suppose it might be possible to have bubbles for both standard explosions and wave bonuses.

New stuff includes a “Score” class for managing the current and high scores, removing the unneeded Sprite class, making clipping optional in the render engines, and adding bounding box and pixel collision detection to the GameSprite class. The SDLTools class has methods for getting the colour of a pixel and for checking if it is transparent, in addition to the same set of functions for working with surfaces other than the screen. I’ve added “Enemy” and “EnemyManager” classes, and altered all of the enemy sprites so that they inherit from Enemy instead of GameSprite.