Windows Tower Defense: New Rooms, Multiple Waves, Multiple Paths

L

Lee Hartsell

Guest
Hey guys! I'm back with another issue. I hope this post is articulate enough and easy to understand. hehe

Some context:
I'm creating a simple tower defense game, programming for level one is complete, save for a little bit of polishing.

Level 1 has three waves of 10 enemies of 3 different types spawn at intervals using the timeline. The enemies then follow a single path from start to finish.

Now I'm moving on to level two and three.
For level 2 I'm trying to program 6 waves, with 3 following one path and 3 another.
For level 3 I'm trying to have 9 waves, with 3 waves each following one for each 3 paths on the level.

I'm only here because I'm really not quite sure how to approach this particular task. I might have to share the file, but I'll try to explain what I've been doing so far: how level 1 is handled, and what I've tried to do for level 2.

For level one:
Currently, each wave starts when the player hits space bar. This is signified by a simple start Boolean.
Once the game is stared, the timeline spawns specified enemy types at intervals. The path they follow is determined inside the enemy parent object. This is currently determined by a variable stored in the level's controller object. (note: each level has it's own controller object)

The level controller handles the waves in a step event. I've used switch statements to determine which wave is active and if start is true. Within the timelines, the last event stops the timeline and decrements the wave count. Once the wave count is 0 and all instances of the enemy are destroyed, the level will end.


That all works great, but obviously only works for a single path. I've tried setting the path at the beginning of each wave, as well as creating new objects for level 2 enemies and giving them their own level 2 parent. I've also tried using scripts instead of timelines to handle the waves, but that also doesn't seem to work.


The issue is, regardless of the above methods used for level two, the waves will not start when hitting space bar. Debugging shows that start is switching to true, and the wave starts at wave the correct number, but no enemies spawn or follow the path.

I'm not entirely sure where the code is going wrong. I've gotta have this guy nice and polished and burned to a disc by the 22nd, and this task here seems to be the last significant hurdle.

Let me know if there is anything I can clarify, or if you have questions!
It might also help to let you guys know that I used VTR Studios' Tower Defense Tutorial YouTube series for a lot of the code.

Ideas, suggestions, solutions?

Also, here's some spinets of code for reference:

Handling Waves:
Code:
switch(currentWave)
{
//wave 1
    case 3:
    if (start)
    {
        timeline_index = tm_Lvl1W1;
        timeline_running = true;
    }
        break;
//wave 2
    case 2:
            if (start)
    {
        timeline_index = tm_Lvl1W2;
        timeline_running = true;
    }
        break;
//wave 3
    case 1:
            if (start)
    {
       timeline_index = tm_Lvl1W3;
        timeline_running = true;
    }
        break;
}
Setting Path (in obj_enemyParent)

Code:
path_start(pth_lvl1, enSpeed, path_action_stop, 1);
script version of wave handling:

Code:
if (canSpawn)
{
    instance_create(0, 0, obj_enemy1_lvl2);
    alarm[1] = obj_enemyParent2.oneRespawnRate;
    obj_Controller.canSpawn = false;
    obj_Controller.enemies--;
}
stopping waves at end of timeline

Code:
start = false;

currentWave--;

alarm[1] = 450;

timeline_position = 0;

timeline_running = false;
 
Top