GML: enemy formations that drop items

A place for people with an interest in developing new shmups.
Post Reply
EddyMRA
Posts: 798
Joined: Wed Jan 26, 2005 9:36 am
Location: San Diego, CA, USA

GML: enemy formations that drop items

Post by EddyMRA »

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.
User avatar
monkeyman
Posts: 225
Joined: Wed Nov 14, 2007 8:53 pm

Re: GML: enemy formations that drop items

Post by monkeyman »

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:

Code: Select all

target (set to the amount of enemies in the wave)
killed = 0
removed = 0
and when spawning enemies use the following:

Code: Select all

ene=instance_create(x,y,enemy object)
ene.spawner=id
For the enemy object have the following 2 bits of code:

When destroyed by the player (hitpoints = 0 etc):

Code: Select all

spawner.killed+=1
When removed from the game (ie outside of screen/ attack pattern finished etc)

Code: Select all

spawner.removed+=1
Destroy event

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()
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!
My shmup Projects
Finished: Invader! -- Tri Hunter -- Proj Raiden
WIP: Infinity Squadron
agustusx
Posts: 592
Joined: Tue Dec 02, 2008 6:08 pm

Re: GML: enemy formations that drop items

Post by agustusx »

Thanks for the ideas, this fills in some gaps in my line of thought.
User avatar
Rozyrg
Posts: 918
Joined: Wed Feb 11, 2009 12:03 am
Location: Southeast USA

Re: GML: enemy formations that drop items

Post by Rozyrg »

@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! :D
EddyMRA
Posts: 798
Joined: Wed Jan 26, 2005 9:36 am
Location: San Diego, CA, USA

Re: GML: enemy formations that drop items

Post by EddyMRA »

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.
User avatar
monkeyman
Posts: 225
Joined: Wed Nov 14, 2007 8:53 pm

Re: GML: enemy formations that drop items

Post by monkeyman »

Glad I could be of help! (and slightly amazed it actually worked!!)
My shmup Projects
Finished: Invader! -- Tri Hunter -- Proj Raiden
WIP: Infinity Squadron
Post Reply