Archive for October, 2009

Physics Engine Progress

I’ve recently discovered that APE (Actionscript Physics Engine) lacks a lot of basic features that I really wanted to use in the game I was going to make with this, which is a shame as it was so easy to program. The biggest problem I found with the engine was the lack of any rectangle physics, so I stuck it out and attempted to learn Box2DFlashAS3 which I found needlessly complex and required to many lines to get the desired effects (in other words I’m too lazy!).

So instead I found a substitute called QuickBox2D which is a library built on top of Box2DFlashAS3 which makes everything a lot easier as well as adds a couple more helpful features. But on top of that the creators website has LOADS!!! of examples of the engine working which makes it so easy to learn from references.

So check it out if you are looking to learn an AS3 Physic Engine as it is definitely the easiest to pick up and play with. Also here are two examples to compare APE and QB2D.

(Make sure you click the file to focus on it and not switch to the next file through shadowbox)

APE-Demo
QB2D-Demo

October Update!

Well I haven’t posted for awhile so I thought I’d keep anyone who cares updated. I’m currently halting work on EvoCannon 2 due to me being lazy and that I’m back at college doing my A Levels, some more useless than others…

…But anyway after much frustration I’m finally making head-way with learning a AS3 Physic Engine called APE (Actionscript Physics Engine).

So far I’ve just been getting to grips with the engine by messing around with demos and creating my own. But I was thinking a physics based puzzle platformer or PPP as I like to call it :P would be interesting.

So anyway this is what I have so far and is just a short demo:
PPP-Demo

Controls:
Up = Jump
Right = Roll Right
Left = Roll Left

Source:

package {
import org.cove.ape.*;
	import KeyObject;
	import flash.events.Event;
	import flash.display.Sprite;
 
	public class APETest extends Sprite {
 
		public function APETest() {
			var angVel:Number = 0;
			var angAcc:Number = 0.1;
			var keyP:Boolean = false;
			var keyU:Boolean = true;
			var key:KeyObject = new KeyObject(stage);
 
			APEngine.init(1/4);
			APEngine.container = this;
			//Gravity
			APEngine.addMasslessForce(new Vector(0,2));
 
			var defaultGroup:Group = new Group();
			defaultGroup.collideInternal = true;
 
			var wp:WheelParticle = new WheelParticle(250, 200, 15, false, 1, 0.1);
			defaultGroup.addParticle(wp);
 
			var cp1:CircleParticle = new CircleParticle(448, 300, 72, true, 100, 0.1);
			defaultGroup.addParticle(cp1);
 
			var cp2:CircleParticle = new CircleParticle(52, 300, 72, true, 100, 0.1);
			defaultGroup.addParticle(cp2);
 
			var rp1:RectangleParticle = new RectangleParticle(250,400,200,20,0,true);
			defaultGroup.addParticle(rp1);
			var rp2:RectangleParticle = new RectangleParticle(230,400,200,20,0.2,true);
			defaultGroup.addParticle(rp2);
			var rp3:RectangleParticle = new RectangleParticle(270,400,200,20,-0.2,true);
			defaultGroup.addParticle(rp3);
			var rp4:RectangleParticle = new RectangleParticle(210,400,200,20,0.5,true);
			defaultGroup.addParticle(rp4);
			var rp5:RectangleParticle = new RectangleParticle(290,400,200,20,-0.5,true);
			defaultGroup.addParticle(rp5);
			var rp6:RectangleParticle = new RectangleParticle(190,400,200,20,0.8,true);
			defaultGroup.addParticle(rp6);
			var rp7:RectangleParticle = new RectangleParticle(310,400,200,20,-0.8,true);
			defaultGroup.addParticle(rp7);
			var rp8:RectangleParticle = new RectangleParticle(170,400,200,20,1,true);
			defaultGroup.addParticle(rp8);
			var rp9:RectangleParticle = new RectangleParticle(330,400,200,20,-1,true);
			defaultGroup.addParticle(rp9);
			var rp10:RectangleParticle = new RectangleParticle(150,400,200,20,1.2,true);
			defaultGroup.addParticle(rp10);
			var rp11:RectangleParticle = new RectangleParticle(350,400,200,20,-1.2,true);
			defaultGroup.addParticle(rp11);
			var rp12:RectangleParticle = new RectangleParticle(130,400,200,20,1.4,true);
			defaultGroup.addParticle(rp12);
			var rp13:RectangleParticle = new RectangleParticle(370,400,200,20,-1.4,true);
			defaultGroup.addParticle(rp13);
			var rp14:RectangleParticle = new RectangleParticle(250,280,180,5,0,true);
			defaultGroup.addParticle(rp14);
			var rp15:RectangleParticle = new RectangleParticle(0,200,20,400,0,true);
			defaultGroup.addParticle(rp15);
			var rp16:RectangleParticle = new RectangleParticle(500,200,20,400,0,true);
			defaultGroup.addParticle(rp16);
			var rp17:RectangleParticle = new RectangleParticle(250,0,500,20,0,true);
			defaultGroup.addParticle(rp17);
 
			APEngine.addGroup(defaultGroup);
 
			addEventListener(Event.ENTER_FRAME, eachFrame);
			function eachFrame(e:Event):void {
				APEngine.step();
				APEngine.paint();
				moveWheel();
			}
			function moveWheel() {
				if(key.isDown(key.UP)){
					if(!keyU){
						wp.addForce(new Vector(0,-40));
						keyU = true;
					}
				}else{
					keyU = false;
				}
				if (key.isDown(key.LEFT)) {
					wp.angularVelocity = -angAcc;
					keyP = true;
				}
				if (key.isDown(key.RIGHT)) {
					wp.angularVelocity = angAcc;
					keyP = true;
				}
				if (!key.isDown(key.RIGHT) && !key.isDown(key.LEFT)){
					keyP = false;
				}
				if(!keyP){
					wp.angularVelocity = 0;
				}
				if(key.isDown(key.SPACE)){
					trace(defaultGroup.collisionList);
				}
			}
		}
	}
}

Enjoy and leave a comment with your ideas and thoughts!

Search
Categories
Archives

You are currently browsing the SyntheCypher's Blog blog archives for October, 2009.