Physics Platformer Demo

Post your Construct-made creations!

Post » Sun Nov 18, 2007 12:26 am

I whipped up a small demo of how someone might make a platfomer that uses physics instead of manually updating the XY coordinates of sprites.

You can jump off of platforms and objects with the Z key, and kick objects around with the X key.

The custom movement was actually pretty easy to make. No need to check if the sprite is intersecting with the ground, and run loops to push him out, because collisions and gravity are automatic with Construct's physics.

Here's the .cap:

[url:18nvo0gy]http://projectbrimstone.googlepages.com/kickit.cap[/url:18nvo0gy]

It's heavily commented and should be pretty easy to follow.

Some other notes:
- Be sure to check out the player and kick sprites to see how the image points and hotspots are set up.
- The player sprite has two private variables set up, "direction," and "kickTimer," both of which are used to control the kicking action.
- The Gravity, Mass, and Angular and Linear Dampening for objects have been changed from the default settings to get a more "platformer" feel.
- There is a minor bug where the objects sometimes stop responding to collisions with the kicking sprite. I believe that this is because I haven't specified which individual object should be colliding. You could probably make a loop during the kick routine to check for collision with specific objects, and that would take care of it, but I'm lazy so who cares.


Some general tips I picked up while working with the Physics movement:
- Objects rotate according to their hotspot placement.
- The bounding box is also set according to the hotspot placement! WTF?!?
- If you want perfect rotation and collision between objects, make them an odd number of pixels high and wide, so you can set the hotspot directly in the center of the object.
- Use "Ellipse" for the collision mask on round objects. Duh.

Comments? Suggestions? Ideas?
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Sun Nov 18, 2007 12:31 am

Hmm, the physics movement assumes all hotspots are centred. So it's probably a good idea to centre the hotspot for all objects with physics.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,518

Post » Mon Nov 19, 2007 7:03 pm

That is a great demo :)

The physics engine sure has some potential.

If it was being used for a super mario type 2d platformer, is is possible to stop the player from bouncing as they land?
B
2
G
5
Posts: 17
Reputation: 1,284

Post » Mon Nov 19, 2007 7:37 pm

[quote="Camm":2c0jrifw]That is a great demo :)

The physics engine sure has some potential.

If it was being used for a super mario type 2d platformer, is is possible to stop the player from bouncing as they land?[/quote:2c0jrifw]

Hey, thanks :)

As for the bouncyness, I'll see what I can come up with.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Sun Dec 09, 2007 11:17 pm

It sounds good and I want to try it, but when I tried to open it, I got the following error:
"Microsoft Visual C++ Runtime Library"
"Runtime error!

Program: C:\Program Files\Construct\Construct.exe


The program has requested that the program be terminated in an unusual way.
Please contact the application's support team for more information."
B
1
G
5
Posts: 8
Reputation: 1,241

Post » Sun Dec 09, 2007 11:36 pm

That's strange. I don't know what would cause that. It's still opening fine for me.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Sun Dec 16, 2007 5:59 pm

[quote="deadeye":1sn19xlo]That's strange. I don't know what would cause that. It's still opening fine for me.[/quote:1sn19xlo]

I checked your sample and it is really nice. One thing though that I couldn't figure out. How on earth do you do ground solid without the solid checkbox?
I couldn't find anything in the event tab.


Sincerely
Andla
B
2
S
1
G
5
Posts: 79
Reputation: 1,558

Post » Mon Dec 17, 2007 8:06 am

The physics movement has it's own solidity. Check it out under the movements properties, you'll see a setting for "Collision mask." You can currently set it to bounding box or ellipse.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Thu Dec 27, 2007 5:05 pm

Awesome engine! Shows of capabilities of Construct.
B
2
S
1
G
5
Posts: 30
Reputation: 1,460

Post » Wed Jan 09, 2008 6:57 pm

That's really nice!

I played around a bit and tried making dominos. Worked very well. :D
B
1
G
4
Posts: 2
Reputation: 1,029

Next

Return to Your Creations

Who is online

Users browsing this forum: No registered users and 1 guest