Jump to content

Code ideas for implementing slope map in arcade physics


eugenioclrc
 Share

Recommended Posts

Hi i am trying to implement some simple half squares in my tilemap but only using the arcade physics.

 

I have do it with the ninja physics, but they look a bit complex and inefficient, especially in big maps.

 

Does anyone got a workaround?

Do i have just to write a custom isColliding function for the slopes?

 

 

Link to comment
Share on other sites

arcade doesn't support anything else than aabb collision..  so yes - it looks like you would have to rewrite arcade physics on your own.. or just use the mighty "p2" engine..  

you can create polygons in "physicseditor" or in "tiled" and automatically create objects that will collide out of it 

Link to comment
Share on other sites

Wow... seems a lot of work.

 

Just another question, could the P2 system make my game slow?, here is the demo;

http://msemelman.github.io/pirate-ninja-zombie-soldier/

 

Its a platform game, move around with WASD, you can aim an shoot with the mouse and pressing space bar you activate the turbo.

 

Any code advice you give will be grateful welcome!

Link to comment
Share on other sites

p2 physics will definitely be more resource hungry IF you use all those expensive methods it provides..  

 

your platformer example is a very simple one..  you will not see any performance issues when switching to p2

 

but there are very expensive features in p2 like impact-events for example .. you don't need them because you can always use onBeginContact instead..   and of course calculating the collision of a polygon body will be more expensive than a simple aabb calculation.. but you don't have to make extensive use of polygons.. you could just go with rectangles or circles for your player/enemies if that's good enough and use polygons only for the ground... 

 

i made this fully commented example where you can have a look at a tilemap created with tiled and polygons with p2 physics...

http://www.html5gamedevs.com/topic/6556-how-to-export-from-tiled-and-integrate-into-phaser/?p=39495

Link to comment
Share on other sites

I'm looking to add slope functionality to my game as well (100% and 50% slopes), but I'm not sure I completely understand how your approach works. Could you do a quick walkthrough maybe, or comment the code? That would be super helpful. Thanks!

Link to comment
Share on other sites

  • 1 month later...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...