LibGDX and Tiled.. selective tile rendering??

Hello all,

I am very new to game programming (have experience programming in Java/C++ but feel overwhelmed by some of these APIs with not very good tutorials) and I am attempting to create a java game using libgdx and the Tiled 2d map editor. I am a bit confused about a few things so I’ll address them and hope someone enlightens me. Some have told me that it would be better not to use tiled… but I’d like to use tiled for the ease of creating a map.

Is there a way to only render specific coordinates of the tiled tilemap? I am going for a fog of war effect. So say for example a unit only has a 1 tile fog of war around where its positioned on the map (x,y). And there are multiple of these units on the map. Can I directly tell the libgdx orthogonal map renderer to render the map around those objects? If so how can I do this?

Another approach I was thinking (but not quite sure its possible) create a completely black layer on top of the original map and do some alpha tint around entity object. How can I do this programatically?

From how I understand it (Don’t take this too seriously, just constructive opinionation from someone else just starting to mess with the graphics side of java) you would render the tiled-map first, then you can create your own system for fog of war, you would have this system rendered ON-TOP of the tiled map. So, Instead of NOT drawing the Tile, you draw a Black Tile on-top of it, if it’s not in vision.

Probably not the most efficient way of doing things and I’m sure a more experienced user will come and tell you the proper way to do things, however that’s how I would invision it being done.

No, that’s probably pretty good. Just make sure to only update your fog of war system every time the camera moves, not when the camera is resting, or else you’ll be wasting a lot of precious CPU cycles. Other than that, you’re pretty much spot on! Although, you probably just want to change the actual color of the tiles instead of rendering an overlay. That’s just how I would do it personally, it’s not that much different from what you were suggesting!

Thats how I would do it. You could extend the OrthogonalTiledMapRenderer class and edit the rendering method I guess, more effort than its worth though. Also, you could use box2dlights, set ambient light to 0 and attatch a point light to each actor. box2dlights is really good, but this might not give the effect you’re looking for, might just look like night.