You know when you throw a grenage or shoot a rocket in some sirst-person shooter games, they blow up right? I was wandering if this can be done in scratch witha simple 2d game, when you shoot a rocket it flies, touches something, and blows up while damaging the enemies around this. I have tried this but i don't know use. Any suggestions?
Offline
How bout this?
For the Projectile:
forever if <touching [object v]?> repeat [length of animation] next costume end endand in another script
forever if <touching [enemies v]?> broadcast [kill v] end endand then you'd programme the enemies do do something when they are killed. This method would work if you want to make a proper, fiery explosion. However, you'd have to make each frame of the explosion individually which can be annoying and time-consuming and tricky.
forever if <touching [object v]?> broadcast [explosion v] end endfor the explosion (this would be a separate sprite)
when i receive [explosion v] show set size to [10]% go to [projectile v] repeat [10] change size by 10 if touching [enemies v] broadcast [kill v] end hide
Offline
well broadcast sends a message to everything, so all the enemies will die at once!
But you could do
when i receive [explosion v] set size to (0) % go to [wherever the explosion is - usually a sprite v] show repeat (50) change size by (2)% wait [a short amount - probably 0.001] secs end hide when i receive [spawn v] //Then in the enemy scripts if <<(alive) = [yes]> and <(number of enemies) = [number indicating this enemy - start from 0 for the first one then add one for each new enemy you add]>> set [alive v] to [yes] //make alive a "for this sprite only" variable change [number of enemies v] by (1) show forever do stuff if <touching [explosion v]?> hide change [number of enemies v] by (-1) set [alive v] to [no] stop script end
Last edited by joefarebrother (2012-04-19 15:40:31)
Offline