Tile Map Editor/Collision Detection

Started by
10 comments, last by menyo 10 years, 7 months ago

Crusable:

Ah thanks Crusable! Yes this is what I was thinking of but in reverse. I did not know SFML had a VIew class that took care of these things, that is very nice. The method I was thinking of using was one I used back when I was developing my game in Java. I was keeping my player on the center of the screen but moving the background around him, but I guess this is a lot more intuitive!

DekuTree64:

Oh okay that clarifies things a lot more. I will be experimenting with the method you suggested as well others in order to see what works best for me. Thanks a lot! :]

Advertisement

I recently came to the conclusion that it's very handy to have a separate array for each feature of a tile. When you need to iterate over some or a lot of tiles for a specific parameter you'll just use the corresponding array. This is very efficient since you won't ever need to itterate over data you don't want. Let's say you only need to know if tiles are walk-able in an area of 100x100. If you just have to itterate over a boolean array it's a lot cheaper then itterating over a array containing stucts of several int's,shorts, bool's, etc.

It's just a bit more expensive if you have to go over a lot of tiles and need all the data for some reason.

So instead of:

struct tile {

int tileType;

bool walkable;

short layer1;

byte moveCost;

}

Just:

int[,] tileType;

bool[,] walkable;

short[,] layer1;

byte[,] moveCost;

This topic is closed to new replies.

Advertisement