Help with creating an enemy spawning system
Posted 22 December 2011 - 12:41 PM
A little background: I'm creating a top down shooter (not unlike Raiden) with enemies that spawn in groups which arrive in waves. These enemies come to the player, rather than the player going to them (so the screen never actually moves; the background moves to give the illusion of movement while the enemies are spawned off screen and fly in from the top). So basically the enemies arrive based on a timeline, which pauses at certain points to allow the player to clear existing enemies first. The idea is sort of like Space Invaders in that you have to clear a wave of enemies to get the next one to come.
So here's what I'm stumped on: I have the wave system all figured out--simply write a timeline and write when I want each group of enemies to spawn. However, as you can imagine, if I wrote an instance_create function for every single enemy, it would be really messy and difficult to design. I want figure out how to make a soft code system where I can create groups of enemies in formations without having to write an instance_create function for every single one. Rather, I would just be able to change a few values and it would automatically put the type of enemy I want in the specified place.
I considered using a grid data structure for this where I would be able to theoretically change the values on the grid and the game would spawn enemies in different positions depending on where the values were on the grid, but I'm a noob and have no idea how to do this in a simple way that doesn't use a ton of memory.
If anybody can give me advice on how to go about creating this or even lend me a hand, I would really appreciate it.
Posted 22 December 2011 - 03:05 PM
Type would be which type of enemy that you like to spawn and times would be how many times you like the enemy to spawn, then you simply start a alarm that execute it!
0: type = obj_critter times = 6 alarm = 1 900: type = obj_critter times = 10 alarm = 1 1800: type = obj_airplane times = 4 alarm = 1And so on....
Then in alarm event you put something like this:
instance_create(x, y, type) times -= 1 if times > 0 alarm = 60This will make it create a unit every second until times is equal to 0
Wait a minute... I totaly missed the part about spawning locations
Well... you could still use the same system and add a spawn_x and spawn_y variable... I hope
0: type = obj_critter times = 6 spawn_x = 100 spawn_y = 100 alarm = 1 900: type = obj_critter times = 10 spawn_x = 200 spawn_y = 200 alarm = 1 1800: type = obj_airplane times = 4 spawn_x = 500 spawn_y = 100 alarm = 1
instance_create(spawn_x, spawn_y, type) times -= 1 if times > 0 alarm = 60
Edited by filulilus, 22 December 2011 - 03:11 PM.
Posted 22 December 2011 - 11:52 PM
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users