Mr.S Posted August 11, 2009 Report Share Posted August 11, 2009 Does anyone know how to do a set of random explosions on a object? For example when objBoss is destroyed a set of random explosion happened on objBoss. Link to comment Share on other sites More sharing options...
LarkSS Posted August 12, 2009 Report Share Posted August 12, 2009 Can't you just set a variable in objBoss to 1, and when that value is 1 ( or true ), create the random explosions? While the value ( we'll call it Explode ) is one, you can check if another value ( which we'll call TimedExplode ) in objBoss is 0. If it is, create an explosion with a random set of coordinates and set TimedExplode up a bit say like 6. Then have this value count down by 1 while Explode equals 1 until it reaches 0 again. If your frame rate is 60, then this will cause ten explosions with slightly random coordinates around objBoss per second, but only while Explode equals 1. This way, you can easily set that value to 0 to stop the exploding process. Link to comment Share on other sites More sharing options...
Kain Posted August 15, 2009 Report Share Posted August 15, 2009 What exactly do you want to be randomized? The location? The shape? The frequency (in the case of multiple explosions as is common in Sonic boss deaths)? Here's the code I've used more than a couple times in the past in order to create an exploding boss: CREATE EVENT: alarm[0] = 5; ALARM 0 EVENT: { instance_create(x + random(64)-32,y+ random(64)-32,objExplosion); alarm[0] = 5 + floor(random(10)); } objExplosion is just an object with an explosion sprite that terminates when its animation is over (by using the Animation end event, found in the Other tab). It also plays a sound in its create event. Obviously tweaking the random values will tweak the effect. In general you want the number in place of 64 to be twice the number in place of 32 (that way you have an even distribution around the center of the object). Link to comment Share on other sites More sharing options...
Recommended Posts