Jump to content


Photo

Help with creating an enemy spawning system


  • Please log in to reply
2 replies to this topic

#1 Merlinthewizard

Merlinthewizard

    GMC Member

  • GMC Member
  • 59 posts
  • Version:GM8

Posted 22 December 2011 - 12:41 PM

Hello everybody, I'd be very grateful to anybody who would be willing to help me with creating a top down shooter game feature that I am currently stumped on.

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.
  • 0

#2 filulilus

filulilus

    GMC Member

  • GMC Member
  • 928 posts
  • Version:GM:Studio

Posted 22 December 2011 - 03:05 PM

You could keep the time line but change it a bit by adding a type and a times variable! :thumbsup:
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!

Example:

Timeline:
0:
type = obj_critter
times = 6
alarm[0] = 1

900:
type = obj_critter
times = 10
alarm[0] = 1

1800:
type = obj_airplane
times = 4
alarm[0] = 1
And so on....

Then in alarm[0] event you put something like this:
instance_create(x, y, type)
times -= 1
if times > 0 alarm[0] = 60
This will make it create a unit every second until times is equal to 0


EDIT:
Wait a minute... I totaly missed the part about spawning locations :biggrin:
Well... you could still use the same system and add a spawn_x and spawn_y variable... I hope :unsure:
0:
type = obj_critter
times = 6
spawn_x = 100
spawn_y = 100
alarm[0] = 1

900:
type = obj_critter
times = 10
spawn_x = 200
spawn_y = 200
alarm[0] = 1

1800:
type = obj_airplane
times = 4
spawn_x = 500
spawn_y = 100
alarm[0] = 1
instance_create(spawn_x, spawn_y, type)
times -= 1
if times > 0 alarm[0] = 60

Edited by filulilus, 22 December 2011 - 03:11 PM.

  • 2

#3 Merlinthewizard

Merlinthewizard

    GMC Member

  • GMC Member
  • 59 posts
  • Version:GM8

Posted 22 December 2011 - 11:52 PM

Thank you, that's very helpful! That's actually a really good system. I think I know where to go with it now. Thanks again!
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users