Jump to content

Platformer game template


enpu
 Share

Recommended Posts

Enpu - this is JUST what I was looking for!

I was just about to open a thread asking for advice on how collision with tiles can be handled - but now I don't have to! I've got that "this is gonna be great feeling" because everything I try to do with panda 2 so far is simple and fun.

You've got a SWEET THING going on here with panda 2 and I want to wish you a happy new year!

nice02.png.c283897bcde32b76aedc2ea975962de2.png

Link to comment
Share on other sites

No problem @jojo2020! Good to hear that it was helpful to you.

One thing you should notice is that the example doesn't have any optimization, because i wanted to keep it as simple as possible. If you open the debug panel you can see that there is a lots of draw calls and bodies (one draw call for each tile and one body for every tile that the player collides with):

5a47ee3e280f4_ScreenShot2017-12-30at21_51_10.png.4141182393160792b0469a7efd6caae2.png

That's a bit more advanced subject, maybe i will do a tutorial or example on that some time later.

(Thanks for the monkey!)

Link to comment
Share on other sites

Yeah - each tile in the layer called 'main' is added to the game world one at a time. The game world provides collision detection. I'm sure if the adjacent tiles were joined together and added as a single body it would help reduce the draw calls, but the init function would have to have more logic.

for (var i = 0; i < this.tilemap.layers.main.tiles.length; i++) {
    var tile = this.tilemap.layers.main.tiles[i];
    this.addBodyForTile(tile);
}

addBodyForTile: function(tile) {
    var body = new game.Body();
    ...

really great to have the tmx file, and be able to see the camera used with the tiled plugin. This template covers a lot and is going to get a lot of people up and running.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

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