Sunday, 25 September 2011

Destruction [Preview]

Today I'll be bringing some more interactivity and gameplay to the game. I wanted to post this yesterday earlier today, but when I looked at the clock it was already 5:30am. So yeah. Whilst trying to drag myself to bed I ran into my mother who apparently had to get up early to go to work. She wasn't happy.

Today I'll be introducing destructible content. In terms of gameplay this can be a very interesting feature. It allows the game to slow the hero down in case you're in a time-based level or if you're running from something.

But that's not all, I've made the choice to add physics to my destruction. Why? Because animating destruction is soooo 20th century. Nah, I mostly only want to prove myself capable of doing it. This game is all about challenge.

Being a student, this is the perfect opportunity to prove and improve my skills. It took me a few hours to get it working, but I did it. And I'm proud of it.

Enough with the text, on with the video!


And in case anypony would be interested, I'll post my DebrisSpawner Class here. I'll probably extend this class further when needed.


package mlp_effects
	import Box2DAS.Common.V2;
	import flash.display.DisplayObject;
	import wck.BodyShape;
	import wck.World;

	public class DebrisSpawner
		public function DebrisSpawner(numberofdebris:int, theWorld:World, theObject:DisplayObject)
			trace("DebrisSpawner>>> Spawning debris.");
			for (var i:int = 0; i < numberofdebris; i++)
				var part:BodyShape = new Debris_part;
				part.x = theObject.x + randomNumber(-theObject.width/2,theObject.width/2);
				part.y = theObject.y + randomNumber(-theObject.width/2,theObject.width/2);
				part.rotation = randomNumber(0,359);
				part.categoryBits = 0x0004;
				var scale:Number = randomNumber(10, 100)/100;
				part.scaleX = scale;
				part.scaleY = scale;
				part.b2body.ApplyImpulse(new V2(randomNumber(7,14)/100, randomNumber(5,10)/100), part.b2body.GetWorldCenter());
			trace("DebrisSpawner>>> Done spawning debris.");
		private function randomNumber(low:Number=0, high:Number=1):Number
			return Math.floor(Math.random() * (1+high-low)) + low;

And when the object is destroyed, simply create a new DebrisSpawner
new DebrisSpawner(15, parent as World, this as DisplayObject);

Stay tuned for more awesomeness!

Your Brony


  1. Oooh, this looks really interesting, yet I feel as though the other ponies could use some new abilities as well. Maybe Twilight can make certain platforms appear or something in that nature.
    Other than that, I'm glad you made a YT channel so I can promote the game more.

  2. Don't worry, I'll revise the other ponies in due time. ;)