GML: enemy formations that drop items
GML: enemy formations that drop items
In Game Maker, has anyone successfully found a way to make formations of enemies that drop items when the whole formation is destroyed? A good example of this are the popcorn formations that drop capsules in the Gradius games. I devised a crude method in Xeno Fighters EX-R, but I would like to get other programmers' input on their approach to this technique. Later, I will post my method in a demo GMK.
The age of Alluro and JudgeSpear is over.
Re: GML: enemy formations that drop items
Someone was asking something similar regarding wave detroyed bonuses, and the pricible is pretty similar.
I've just modified the rules for the score bonus that I came up with so that the last enemy will drop a power up. There may be some 'dead wood' in there you can cut out.
Basically you would need an object which spawned the enemy formation. And have the following on creation:
and when spawning enemies use the following:
For the enemy object have the following 2 bits of code:
When destroyed by the player (hitpoints = 0 etc):
When removed from the game (ie outside of screen/ attack pattern finished etc)
Destroy event
I admit I haven't tried it and there may be better ways of coding it, but basically the spawner object keeps track of how many of the enemies have been destroyed by the player, and when enemies are destroyed, they will check to see if they are the last one destroyed and trigger the power up if they are.
Feel free to have a tinker and modify it as you see fit.
Not sure how well I explained it. Let me know if it works or even if it makes any sense!
I've just modified the rules for the score bonus that I came up with so that the last enemy will drop a power up. There may be some 'dead wood' in there you can cut out.
Basically you would need an object which spawned the enemy formation. And have the following on creation:
Code: Select all
target (set to the amount of enemies in the wave)
killed = 0
removed = 0
Code: Select all
ene=instance_create(x,y,enemy object)
ene.spawner=id
When destroyed by the player (hitpoints = 0 etc):
Code: Select all
spawner.killed+=1
Code: Select all
spawner.removed+=1
Code: Select all
if spawner.killed=target
{
instance_create(x,y,'power up object')
with(spawner)instance_destroy()
}
if spawner.killed + spawner.removed = target
with(spawner)instance_destroy()
Feel free to have a tinker and modify it as you see fit.
Not sure how well I explained it. Let me know if it works or even if it makes any sense!
Re: GML: enemy formations that drop items
Thanks for the ideas, this fills in some gaps in my line of thought.
Re: GML: enemy formations that drop items
@monkeyman :THANK YOU!
I know I asked you about this earlier; but it wasn't till now I felt focused/knowledgeable enough to actually try it out. I had to tweak it a bit for my scripts; but it worked!
I know I asked you about this earlier; but it wasn't till now I felt focused/knowledgeable enough to actually try it out. I had to tweak it a bit for my scripts; but it worked!

Re: GML: enemy formations that drop items
Wow. My approach to this is more or less the same as monkeyman's approach. Thanks for the help.
The age of Alluro and JudgeSpear is over.
Re: GML: enemy formations that drop items
Glad I could be of help! (and slightly amazed it actually worked!!)