Platformer using the Box2d and tiled.

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
Jeeper
Party member
Posts: 611
Joined: Tue Mar 12, 2013 7:11 pm
Contact:

Platformer using the Box2d and tiled.

Post by Jeeper »

With my current game nearing completion I have started to plan on my next project. It is going to be a puzzle platformer. I would like to use the Box2d physics module for colision etc. So in my mind I would have a tile map like {0,0,1,0,0,1} and make a static box (lets say 32x32px) on every "1". I would then draw art on top of that box using the same method. So I wonder if this is a good idea, or if it will cause performance issues to have so many physics driven boxes at the same time, as opposed to one very wide box for the ground.

I would also like to use the program Tiled with the lib Simple Tiled Implementation (STI). Would this be possible and a good way to go on about things?

For those of you who are interested, here is a prototype picture of the game https://love2d.org/imgmirrur/ULFCaJ6.png

Thanks a lot in advance!
User avatar
Azhukar
Party member
Posts: 478
Joined: Fri Oct 26, 2012 11:54 am

Re: Platformer using the Box2d and tiled.

Post by Azhukar »

Using a rectangle for each tile will cause some problems in box2d. You will sometimes get collisions where the rectangle is touching another rectangle, even if they form a straight line. Your characters would end up bumping into those places.

You can use box2d chainshape for your terrain to prevent this issue, and likely increase performance at the same time. To generate the vertices needed for the terrain chainshape you can use a tile grid tracing function I made. http://love2d.org/forums/viewtopic.php?f=5&t=77091
User avatar
MarekkPie
Inner party member
Posts: 587
Joined: Wed Dec 28, 2011 4:48 pm
Contact:

Re: Platformer using the Box2d and tiled.

Post by MarekkPie »

Another solution to Azhukar's potential issue is to create a separate Object Group in Tiled, and use those objects to define the collision objects for the tile map, rather than each individual tile itself. That way, the floor is a single smooth surface rather than a series of blocks. This is what I did for my Global Game Jam game Toughen Up, Robot! You can find the .tmx files in assets/maps/ if you want to load them up for a visual. I wrote the loader myself, but I'd imagine STI handles Object Groups fine.

Performance really isn't much of an issue. Lua is designed to be fast (and LOVE 0.9.0 uses the LuaJIT implementation, so it's really fast); besides, you should only think about the efficient way to do things when it becomes an issue, not before. Too often I've seen people micromanage a project, wasting time and burning their patience before they've even really started.
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 27 guests