Hi I don't speak English very well so ill try to do my best :P

I'm doing my first top-down racing game for LibGDX, now I need to create tracks, the tracks aren't very large, I prefer doing this with a set of tiles with different types of curves, because I want to do a level editor. So I need to check whether the car is on the track or not. I thought that these alternatives are good but I need help by choosing the best one

  • An big array. Doing an array of tiles, saving whether in that position there is a track, looks very memory consupting
  • A set of polygons. And then checking if the car is inside them. Looks very CPU consupting
  • An Black-White image of the track. I've seen a recomendation here about that, but looks similar to an array

Do you know another way to do this?


I'd have to say the array. Creating a black and white image, then processing it based on color can really limit gameplay. It also creates a lot of lag(assuming you're using java's robot), Polygons may work, but wouldn't that be like a more complicated version of an array? I see no real advantage to polygons. UNLESS... You have really weird and irregularly shaped bounds, such as triangles and hexagons used together.

| improve this answer | |
  • \$\begingroup\$ I agree with dylan, And just because it is a big array doesn't mean it will be laggy... You could make it so that it only renders tiles within a certain distance... e.g. Have it only render the tiles that are inside your window. Of course you may have to extend it by a few so there aren't any black spots whilst rendering the next tiles... If you want i can create a youtube video for you demonstrating this method?? This is the method i have used for a 700 * 700 map of 32pixel tiles and I get no lag from the map rendering at all... \$\endgroup\$ – Savlon Feb 8 '13 at 8:17
  • \$\begingroup\$ Oh perfect, Ill do that. Thanks for the fast answer! :D \$\endgroup\$ – user26061 Feb 8 '13 at 12:31
  • \$\begingroup\$ glad to hear it helped you. \$\endgroup\$ – Dylan Katz Feb 9 '13 at 4:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.