Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

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.

share|improve this answer
    
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... –  Savlon Feb 8 '13 at 8:17
    
Oh perfect, Ill do that. Thanks for the fast answer! :D –  user26061 Feb 8 '13 at 12:31
    
glad to hear it helped you. –  Dylan Katz Feb 9 '13 at 4:29
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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