Dusk platformer without physics question(s)...

I wonder what is the best approach using dusk to create a platformer without using the physics of Corona?

Especially how to detect a platform or wall when a character is walking on it or running against it?

What is a good approach to achieve this in dusk?

My current idea for it would be to create a tiled map and checking the surroundings of the character (means the tiles around the character) for possible collision objects (tiles from a collision layer in tiled) and then looking for a collision with only the surrounding tiles.

Is this a good approach?

How can I detect if a character is walking on a platform or hitting a wall or when jumping hitting with it’s head against a platform above or else? Is some kind of collision object “rig” (objects on each side of the character)  in a character group needed to check which kind of collision is happening or is there a better solution for this?

I really would appreciate all your ideas, experience and feedback here because I think a lot of people who want to use dusk for creating a platformer without physics will have this kind of basic questions to get started.

Thx! :slight_smile:

Ahhhh… Platformer physics. My favorite topic. (No, seriously, I love platformer physics!)

There are quite a few ways to do what you’re looking for. For basic physics, you can use simple AABB collision, or you can go a little more complex and do Sonic physics with line math, or you can go more complex and do the whole hog with all sorts of horrifyingly complex vector maths. I’d recommend option 1 or 2 :D.

Here are two of my favorite guides:

http://higherorderfun.com/blog/2012/05/20/the-guide-to-implementing-2d-platformers/

http://info.sonicretro.org/SPG:Solid_Tiles

Another thing to do is just start Googling stuff like “how to implement physics for a platformer”, “2d platformer physics”, “physics engine platformer”, etc. You’ll get a lot of information.

Incidentally, I’ve created an extremely robust physics engine for my game, so, even though it uses an unconventional approach and is thus not exactly the same, I can give you advice if you run up against snags.

  • Caleb

Thx for the links Caleb. Helping a lot.

One thing regarding “falling” characters… how can this be done without physics gravity?

When adding an increasing value to a characters y value I can get acceleration for the fall BUT how do I check if the character is hitting a solid tile below correctly, so the character can land on the tile (platform). The problem I see here is the following: When the character is falling from great height he gets a huge speed value and I’m adding 10pixels to the y value of the characters y position… so when checking the y value of the character with the value of the solid tile it can happen the last position of the character is also overlaying the solid tile and a collision is detected to late. BECAUSE when I move the character on top of the solid tile it already was seen “stuck” in the tile for a short moment.

How is a collision detection done manually for fast moving objects?

I handled fast movement with pseudo-continuous collision detection: using the previous position, calculate each tile-sized increment between last frame and this frame. Then, step one by one through those positions and check for collisions with the tiles at that location. If you find a collision at any point, resolve it and cancel the remaining steps. This approach is fast enough and accurate enough for just about everything.

  • Caleb

Thx for your fast feedback but I think I don’t get it in detail… can you please explain a little more how the calculations are done?

You should probably start with the actual response functions. Start by ignoring continuous collisions for now. Get the basics down - collision detection and response. The two guides I linked to are very useful for that.

Then, once you’ve got that done, I’ve attached a (slightly creepy) quick sketch I made of my approach to continuous physics.

  • Caleb

http://www.raywenderlich.com/62049/sprite-kit-tutorial-make-platform-game-like-super-mario-brothers-part-1

this article helped me and it uses the “step through collisions and cancel” method caleb describes.  this is for spritekit though and is written in objective c.  Using this article i got my platformer working in corona.

Great stuff! Thank you!

Ahhhh… Platformer physics. My favorite topic. (No, seriously, I love platformer physics!)

There are quite a few ways to do what you’re looking for. For basic physics, you can use simple AABB collision, or you can go a little more complex and do Sonic physics with line math, or you can go more complex and do the whole hog with all sorts of horrifyingly complex vector maths. I’d recommend option 1 or 2 :D.

Here are two of my favorite guides:

http://higherorderfun.com/blog/2012/05/20/the-guide-to-implementing-2d-platformers/

http://info.sonicretro.org/SPG:Solid_Tiles

Another thing to do is just start Googling stuff like “how to implement physics for a platformer”, “2d platformer physics”, “physics engine platformer”, etc. You’ll get a lot of information.

Incidentally, I’ve created an extremely robust physics engine for my game, so, even though it uses an unconventional approach and is thus not exactly the same, I can give you advice if you run up against snags.

  • Caleb

Thx for the links Caleb. Helping a lot.

One thing regarding “falling” characters… how can this be done without physics gravity?

When adding an increasing value to a characters y value I can get acceleration for the fall BUT how do I check if the character is hitting a solid tile below correctly, so the character can land on the tile (platform). The problem I see here is the following: When the character is falling from great height he gets a huge speed value and I’m adding 10pixels to the y value of the characters y position… so when checking the y value of the character with the value of the solid tile it can happen the last position of the character is also overlaying the solid tile and a collision is detected to late. BECAUSE when I move the character on top of the solid tile it already was seen “stuck” in the tile for a short moment.

How is a collision detection done manually for fast moving objects?

I handled fast movement with pseudo-continuous collision detection: using the previous position, calculate each tile-sized increment between last frame and this frame. Then, step one by one through those positions and check for collisions with the tiles at that location. If you find a collision at any point, resolve it and cancel the remaining steps. This approach is fast enough and accurate enough for just about everything.

  • Caleb

Thx for your fast feedback but I think I don’t get it in detail… can you please explain a little more how the calculations are done?

You should probably start with the actual response functions. Start by ignoring continuous collisions for now. Get the basics down - collision detection and response. The two guides I linked to are very useful for that.

Then, once you’ve got that done, I’ve attached a (slightly creepy) quick sketch I made of my approach to continuous physics.

  • Caleb

http://www.raywenderlich.com/62049/sprite-kit-tutorial-make-platform-game-like-super-mario-brothers-part-1

this article helped me and it uses the “step through collisions and cancel” method caleb describes.  this is for spritekit though and is written in objective c.  Using this article i got my platformer working in corona.

Great stuff! Thank you!