Page 1 of 2

Tilemap collision

Posted: Mon Apr 18, 2011 2:22 pm
by Anxiety
You know how you make a tilemap by taking a part of a picture and placing it on a quad and drawing it? Pff, thats easy. Now theres only one problem. How can i detect a collision with a certain tile? Im using a character which can move (obviously). I havent made the tilemap yet.

Re: Tilemap collision

Posted: Mon Apr 18, 2011 4:13 pm
by Lafolie
This is pretty simple to do with Object Orientation. I would explain it but I'm not sure it would be beneficial. I think you should create something more simple than a tile-engine. Not that I'm discouraging you. I just think that, based on your other posts, you aren't ready for this yet.

But, that's just my humble opinion. Credits to you for trying and going ahead with this, but I reckon it would be a good move for you to try creating something simple and returning to this once you have a better grasp of Lua/Löve. :)

Oh, and this page may be of interest to you regarding tilemaps: http://info.sonicretro.org/SPG:Solid_Tiles

Re: Tilemap collision

Posted: Mon Apr 18, 2011 4:36 pm
by Anxiety
Well, what would be the more simple way, rather that tilemap?

And im learning all the time :)

Re: Tilemap collision

Posted: Mon Apr 18, 2011 5:14 pm
by bartbes
A tilesheet + quads is typically a good solution, personally, I'd put the static part of the map in a spritebatch, so you can draw that in one go.

Re: Tilemap collision

Posted: Mon Apr 18, 2011 5:36 pm
by Anxiety
bartbes wrote:A tilesheet + quads is typically a good solution, personally, I'd put the static part of the map in a spritebatch, so you can draw that in one go.
Thats, basically what im trying to do. I just want to do it BIG size (http://love2d.org/forums/viewtopic.php?f=3&t=2857)

Re: Tilemap collision

Posted: Mon Apr 18, 2011 5:37 pm
by bartbes
So what's the problem?

Re: Tilemap collision

Posted: Mon Apr 18, 2011 5:37 pm
by Anxiety
As i said, i want to make it big. Right now im using a table fileld with numbers, since thats the only thing i can do.

Re: Tilemap collision

Posted: Mon Apr 18, 2011 7:36 pm
by Robin
I still don't understand the problem?

EDIT: this sort of reads like: "I want to do X." "Then why don't you do X?" "No no, you don't understand. I want to do X."

Re: Tilemap collision

Posted: Mon Apr 18, 2011 8:17 pm
by tentus
It sounds like he wants to make one big render of a level map, assign that as a tilemap, and then draw it out like a normal tilemap-based game.

If that's the case, :death: :death: :death:

Re: Tilemap collision

Posted: Mon Apr 18, 2011 9:44 pm
by kikito
Anxiety, repeating "I want to make it big" is not an explanation, it's a ... repetition. Tell us why "making it big" is an issue for you with more detail. Help us help you.

I'm going to make some hypothesis and give you some answers. I could go into more detail once I know what your problem is, exactly.
  • You are complaining that you have to type lots of tiles manually (100x100 tiles by hand can be lots of commas, apostrophes, etc). On that case, using a multi-line string instead of an array helps. See my tile tutorial
  • You don't know how to do scroll. In that case, the easiest thing to do is drawing everything on each frame and just translate with love.graphics.translate
  • You are complaining that drawing a big map is too slow. The simplest approach here is dividing the map into smaller maps - instead of 1 big map of 100x100, you have several smaller maps of 10x10. You only draw the maps that are visible. This can be made even faster if you use one Framebuffer per sub-map.