Light Racer 2.0 - Days 15-16 - Maps and MapObjects

After getting a decent graphic in for the Decimator, I began working on design changes that would allow Light Racer to have 10 unique levels. I implemented a LevelBuilder class that is responsible for configuring the World for a given level number. I tried to take into account the idea of the skirmish game later for single and multi-player modes in this design. I created the base MapObject class. A MapObject is any obstacle or interactive GameObject that's considered part of the "level." My first MapObject is the PowerLine, which is an object spanning a distance either vertical or horizontal that periodically arcs tesla-like lightning across the coils. The important thing for now is that per level, different numbers of AI players can be placed in different starting locations facing different directions, MapObjects can created and placed anywhere and initial speeds can be set on the players.

Day 15 - What Was Done:

Added Decimator Art
Made it so that the decimator would turn the sprite to face which direction it is going.
Added a little attack delay.

I'm happy with how the Decimator looks and feels. Now it needs some sounds and animation, which will be added in later.

Day 16 - What Was Done:

Added a LevelBuilder class that configures the level. The game is now limited to 10 levels. I'm thinking about adding in a "speed-play" mode that lets you configure a game and play it as fast as you can, kinda like the old light racer. For now I'm focused on getting a really good 10-level game built. I'll add all the configurable stuff later.

I standardized the way GameObjects work and now have 3 main classes of things. The GameObject, which is the base class and then the Player, Item and MapObject, all of which extend GameObject. I added a bounds-based collision detection interface to the game object so that now players can just ask an object in the world if they are colliding with it. This will make implementing the map objects much easier, because they just need to do that basic bounds check.

Added basic graphics for the power emitter
Added lightning animation - problem - it's huge.
Got animation and drawing code in for the power line.
Here's what I have decided will be the levels for the game:

level 1 is plain map, 1 AI player. position directly across from each other, speed 1
level 2 is plain map, 2 AI players. human in center bottom, AIs both across, speed 2
level 3 is horiz power map, 1 AI player, directly across from each other, speed 3
level 4 is vert power map, 1 AI player, side to side across, speed 3
level 5 is power box map, 2 AI players, top and bottom, speed 3
level 6 is laser sweep map, 1 AI player, both at bottom, speed 4
level 7 is laser sweep map, 2 AI players, top and bottom, speed 4
level 8 is power-cross map, 1 AI player, both at bottom, speed 4
level 9 is power-cross map, 2 AI players, top and bottom, speed 5
level 10 is portals, 1 AI player, both at bottom, speed 5

I started by implementing a method in the LevelBuilder which is responsible for configuring each level. You will also see the applyMap method. This is what actually makes a map a map. It takes a MapObject that I have developed and puts it in the World.

public void buildLevel(int levelNumber, int difficulty, LightRacerWorld world) {
if (levelNumber == 1) {
// level 1 is plain map, 1 AI player. position directly across from each other, speed 1
world.players = createPlayers(2, difficulty, 1, false, world);
applyMap(MAP_VERT_POWER, world);
} else if (levelNumber == 2) {
// level 2 is plain map, 2 AI players. human in center bottom, AIs both across, speed 2
world.players = createPlayers(3, difficulty, 2, false, world);
applyMap(MAP_PLAIN, world);
} else if (levelNumber == 3) {
// level 3 is horiz power map, 1 AI player, directly across from each other, speed 3
world.players = createPlayers(2, difficulty, 3, false, world);
applyMap(MAP_HORIZ_POWER, world);
} else if (levelNumber == 4) {
// level 4 is vert power map, 1 AI player, side to side across, speed 3
world.players = createPlayers(2, difficulty, 3, false, world);
applyMap(MAP_VERT_POWER, world);
} else if (levelNumber == 5) {
// level 5 is power box map, 2 AI players, top and bottom, speed 3
world.players = createPlayers(3, difficulty, 3, false, world);
applyMap(MAP_POWER_BOX, world);
} else if (levelNumber == 6) {
// level 6 is laser sweep map, 1 AI player, both at bottom, speed 4
world.players = createPlayers(2, difficulty, 4, false, world);
applyMap(MAP_LASER_SWEEP, world);
} else if (levelNumber == 7) {
// level 7 is laser sweep map, 2 AI players, top and bottom, speed 4
world.players = createPlayers(3, difficulty, 4, false, world);
applyMap(MAP_LASER_SWEEP, world);
} else if (levelNumber == 8) {
// level 8 is power-cross map, 1 AI player, both at bottom, speed 4
world.players = createPlayers(2, difficulty, 4, false, world);
applyMap(MAP_POWER_CROSS, world);
} else if (levelNumber == 9) {
// level 9 is power-cross map, 2 AI players, top and bottom, speed 5
world.players = createPlayers(3, difficulty, 5, false, world);
applyMap(MAP_POWER_CROSS, world);
} else if (levelNumber == 10) {
// level 10 is portals, 1 AI player, both at bottom, speed 5
world.players = createPlayers(2, difficulty, 5, true, world);
applyMap(MAP_PORTALS, world);
}
}

public void applyMap(int map, LightRacerWorld world) {
if (map == MAP_VERT_POWER) {
world.mapObjects = new MapObject[1];
world.mapObjects[0] = new PowerLine(world.width / 2, world.height / 2, 300, true, gameResources);
}
}

The first level won't have this but for testing, I changing the configuration of the first level to be whatever map I'm currently working on. All in all there will be 6 maps that use about 3 totally unique features. This is kind of how the Power Line will work but instead of being on constantly it will have a visible charge period then it will let the power go for a second or two. I need to add collision detection to it so that it shocks the players that come too close wihle it's turned on.

To show you how the different levels might look, I took these screenshots:

Example Vertical Power LineExample Vertical Power Line Example Map PlainExample Map Plain