Physics Engine

Posted by necromian on March 2, 2008, 11:03 a.m.

This is pretty much just my easy alternative for people who want simple physics in their platform games but for some reason don't want to mess around with gmphysics. The gimmick in this physics engine is that it's also an engine for a game in which the character manipulates objects via telekinesis, so I guess this is a starting point for that awesome psychic game you've always wanted to make. ;D

—–quoted from game info——–

Necromian's Simple Physics Engine

Move with the WASD keys

(Note, this is topdown movement, I was too busy improving the physics rather than turning it into a full fledged platforming engine. So sue me).

Click and hold the left mouse button while blocks are within your casting radius to cast telekinesis on them. During telekinesis, the block will move towards the mouse. While using telekinesis, you can move the block as far away from the character as you want, but if the block gets too far from the mouse, the telekinesis stops. You can use this to your advantage when you want to fling objects.

Click the right mouse button to cause blocks to shoot away.

Press the Spacebar to toggle those black circles that are used for debug purposes only.

All of the physics is already worked out in the step event of the 'obj_moveparent' object. If you want to make a new object with the telekinesis physics applied, follow the following steps-

-Make sure the object has a sprite.

-Make the parent 'obj_moveparent'

-In the create event of the object, put the code "spellon = false;"

-Define the weight and bounce of the object (Check the comments in the create event of obj_crate or obj_ball for more details on this)

Everything else you should be able to figure out from my comments.

Credits to GMLscripts for the motion blur script. Give credit to me where due.

————

download link: http://www.nfyre.com/simple%20physics.gm6 (I'll make a page for it later)

Comments

JID 16 years, 9 months ago

I'm not talking about the rubber balls, I'm talking about the boxes.

necromian 16 years, 9 months ago

Well it doesn't matter. Both have the same exact physics applied

JID 16 years, 9 months ago

It really does, because you have an example here, and examples really shouldn't have glitches, remember your trying to teach people something.

necromian 16 years, 9 months ago

When I said it doesn't matter, I was talking about how I was talking about the balls and you were talking about the boxes. Both have the exact same physics applied, so it doesn't matter which we're talking about.

But anyways, I found the problem and updated the engine at the same link, and while I was at it, fixed all the other lil bugs in it.

Updates:

-Changes in gravity (Newtons first law of motion now applies. Don't worry, I'm getting on the rest, check back in a couple years and I might even have the law of universal gravitation down =D)

-Heavier objects are slightly harder to control

-Fixed errors in terminal velocity during telekinesis.

-Fixed elasticity/weight problem when colliding with the ground.

-A couple other minute changes. Probably not noticeable unless you're a really nitpicky person.