[Solved] Combining Collision Tiles In tile-based Game?

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
I~=Spam
Party member
Posts: 206
Joined: Fri Dec 14, 2012 11:59 pm

[Solved] Combining Collision Tiles In tile-based Game?

Post by I~=Spam »

Hello!

I'm looking for a way to combining collision tiles together to optimize my game and make collision detection a bit easier if I decided on using Hadron Collider (read about some weird problems when I looked through the forums).

here's a pic ( sorry if it is a bit sloppy )
Untitled.png
Untitled.png (3.86 KiB) Viewed 2401 times
I didn't find anything when I searched the forums and I found this when I searched the wiki.
Although it didn't work! :o Instead it gave weird locations for tiles that didn't make sense.

I uploaded the .love file. ( I used Kikto's inspect.lua to display the tables )
Any help is appreciated.
Attachments
tilemerging.love
(2.79 KiB) Downloaded 84 times
Last edited by I~=Spam on Thu Feb 14, 2013 5:23 pm, edited 1 time in total.
My Tox ID: 0F1FB9170B94694A90FBCF6C4DDBDB9F58A9E4CDD0B4267E50BF9CDD62A0F947E376C5482610
User avatar
MarekkPie
Inner party member
Posts: 587
Joined: Wed Dec 28, 2011 4:48 pm
Contact:

Re: Combining Collision Tiles In tile-based Game?

Post by MarekkPie »

There's a couple of things you can do before what you are suggesting using HardonCollider, because that is a bit of a harder problem that it might seem.
  • Make sure all of your tiles are set to passive, so they only respond to collision detection, and not actively search of it;
  • Make sure all of your tiles are in the same group, so they don't collide with each other.
Now, to the tile merging. If you are using something like Tiled, the easiest way is to make a separate object layer and make those objects act as what you collide with, rather than the tiles itself. Then, you can just drag out the regions you want to group.

I'd try all of those before you look into programmatically merging tiles.
User avatar
markgo
Party member
Posts: 190
Joined: Sat Jan 05, 2013 12:21 am
Location: USA

Re: Combining Collision Tiles In tile-based Game?

Post by markgo »

I would not recommend using HardonCollider for tile collision. There are plenty of examples in the forum that demonstrates how to handle tile collision. With that said, if you are willing to use HC for tile collision, you can do what MarekkPie suggested with the object layer in tiled.
User avatar
MarekkPie
Inner party member
Posts: 587
Joined: Wed Dec 28, 2011 4:48 pm
Contact:

Re: Combining Collision Tiles In tile-based Game?

Post by MarekkPie »

markgo wrote:I would not recommend using HardonCollider for tile collision. There are plenty of examples in the forum that demonstrates how to handle tile collision. With that said, if you are willing to use HC for tile collision, you can do what MarekkPie suggested with the object layer in tiled.
I didn't even think about that. If your movements as restricted to within the tile grid, then as markgo said, there are much better ways to handle tile-based collisions. However, if you are making some game that uses a tileset to design a level (but needs more robust collision detection), then follow my advice.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Combining Collision Tiles In tile-based Game?

Post by Robin »

This is something I made (for Simon, actually, if anyone remembers that) that solves this problem. (I use HC as well.)

Warning: this algorithm can get pretty slow for large levels with lots of tiles. It might make sense to pre-generate the large tiles instead of generating them every time you start the game.
Attachments
block-test-new-hc.love
(111.29 KiB) Downloaded 162 times
Help us help you: attach a .love.
User avatar
I~=Spam
Party member
Posts: 206
Joined: Fri Dec 14, 2012 11:59 pm

Re: Combining Collision Tiles In tile-based Game?

Post by I~=Spam »

THANKS! I'll try it out. Sorry for the late response... I've had other important things for a while :|

EDIT: Finished testing and it works great! Thanks again! :ultrahappy:
My Tox ID: 0F1FB9170B94694A90FBCF6C4DDBDB9F58A9E4CDD0B4267E50BF9CDD62A0F947E376C5482610
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests