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

PY 16 years, 9 months ago

Damn, I just did this!

PY 16 years, 9 months ago

EDIT:Except mine's better.

necromian 16 years, 9 months ago

Lawl, link phazon?

PY 16 years, 9 months ago

Not done yet, I'm perfecting the lighting engine.

It's a HL2-ish engine, the gravity gun inspired me, I've almost done a lighting engine, then I need other stuff. Like striders. Win.

Yours was good though, it worked well.

edmunn 16 years, 9 months ago

Very nice engine BTW =]

JID 16 years, 9 months ago

I thought it was a little too glitchy, when you add more weight, the bouncier the object becomes. If you would've submit this, I think the appropriate rating would be a 7/10.

Nice try though.

necromian 16 years, 9 months ago

It actually should become bouncier as the weight increases. If you were to drop two rubber balls which bounced the same amount, but one was alot heavier than the other, the heavier one would gain alot more momentum before it hits the ground, and therefore would bounce alot higher. At least that's what I intended it to do. So in response to your post, no, that wasn't a glitch.

PY 16 years, 9 months ago

Nononono! No!

Newton's law (I think<_<) Two objects dropped will always fall at the same speed? IE, It will bounce less, try dropping a light book and a heavy book, or something like that, heavier=bounce less, at least for a simple physics engine.

necromian 16 years, 9 months ago

I'm pretty sure that law only applies if there's no air resistance, like in a vacuum or summat. I mean, right now if I drop a pencil and a piece of paper from the same height, the pencil will hit the ground first.

necromian 16 years, 9 months ago

Anyways, I'm pretty sure if you really care that much about the bounce with heavier object, change the bounce accordingly yourself so it seems more realistic.