The Daily Click ::. Forums ::. Klik Coding Help ::. Multiple instances spawning multiple instances
 

Post Reply  Post Oekaki 
 

Posted By Message

CPW



Registered
  21/02/2009
Points
  3
21st February, 2009 at 21:08:36 -

What I've been trying to do is create an enemy spawning system that works like old NES platformers (Kirby or Megaman for example).

If a spawner is on screen, it should create one instance of an enemy. As long as that instance of the enemy is on screen, that instance of the spawner should be inactive. If the enemy goes off screen, it is destroyed, and the spawner can become active again. It should only create an enemy while it's on the edge of the screen, the player should not see it be created. However, if a second instance of that same type of spawner comes on screen while the other one is still there, it should also create an enemy, so there can be multiple instances of an enemy on screen if there are multiple instances of the spawner. Each instance of the spawner should identify which enemy it created, and only be able to create a new one if its particular enemy no longer exists.

Any ideas?

 
n/a

Chloe Sagal

under the influence of FUN

Registered
  19/02/2009
Points
  607

Orange
21st February, 2009 at 21:35:37 -

i think if you spread a value to an id of the spawn points, then when you create the enemy set an id on the enemy to the spawn points id and set a flag on for the spawn point, make sure the flag needs to be off for the event to happen. any time the enemy is destroyed keep a condition on the destroy event that if the id is eqaul to the id of the spawn point, then set the flag on. to kill the enemies off screen, just set it so that if the x of the player (or camera) is greater than half the screen size plus the width of the baddy, then it gets destroyed, and the same for the y except the highth. aslo the same goes for the spawning events (i think). give it a shot.

 
Patreon: http://www.patreon.com/chloesagal
Twitter: https://twitter.com/ChloeSagal

CPW



Registered
  21/02/2009
Points
  3
21st February, 2009 at 23:32:49 -

There's always some problem when I try that kind of thing, and I've tried many many variations of it. I need to turn the flag back off when the spawner can create a new enemy and that always causes problems.

I'm having trouble when I need to destroy a specific enemy and tell which spawner to turn the flag on for, I have no idea if it's matching them up. It doesn't seem to be because it's either always letting spawner 1 work and never spawner 2 or it's only working when both are on screen or only when one is, etc.

UGH this is a huge confusing mess.

 
n/a

Chloe Sagal

under the influence of FUN

Registered
  19/02/2009
Points
  607

Orange
21st February, 2009 at 23:52:15 -

thats what the spread value does. do an always event then on the spawn location hit spread value of 0. then make sure that when you actually spawn the enemy that you set the ID of the enemy created to the ID that was spread to the spawn point. then on all your distruction events put the condition if ID of enemy equals ID of spawn point. if it dont work then i dont know, im still kind of new to this.

 
Patreon: http://www.patreon.com/chloesagal
Twitter: https://twitter.com/ChloeSagal

CPW



Registered
  21/02/2009
Points
  3
22nd February, 2009 at 00:12:36 -

Aha, I figured it out!

Okay, so on the destroy event, I had it set a global value to the ID of the destroyed enemy. Then, if the spawner's ID was equal to that value, it would reactivate, then reset the global value.

 
n/a

Nick of All Trades

Possibly Insane

Registered
  03/09/2002
Points
  2312

Game of the Week Winner
22nd February, 2009 at 11:30:25 -

I am thinking the 'spawner' could be a flag (well, two really) on the enemy, which makes it active or inactive depending on weither or not it is in 0the screen. At the start of the level two values are determined, one "original X" and an "original Y" one, which resets the enemy whenever it is outside the screen and becomes active whenever they are close to the screen edges.

Flag 1- Active or inactive
Flag 2- Becomes active when enemy is in the screen

...

I use TGF

 
n/a
   

Post Reply



 



Advertisement

Worth A Click