Explorable Map

Hi,

Is there any way to have a map blacked out until you explore an area like starcraft does?

Thanks, Greg

I gather this isn’t an easy thing to do… you’d probably have to be able to hide/show tiles within a radius right?

gb8, I believe there is a way to do this just don’t remember off the top of my head, did you try emailing michael he is normally pretty responsive and really great at pointing you in the right direction.

I experimented with a Fog of War effect in MTE last year and was quite happy with the results - so it is possible. Doesn’t one of the lighting demos provided give a suggestion of where to start.

If my HDD hadn’t crashed last year I would have supplied code…

Yes, sorry for the delay in getting back to you, but this is one of those open-ended questions with many possible answers. How easy it will be depends on the kind of effect you want and how efficient you want the resulting code to be.

One of the easiest solutions I can think of would be to add a layer to the top of the map and fill it entirely with black tiles. In your enterFrame you could loop through the tiles near your player and remove those black tiles, thus revealing the map. Looping through a few dozen tiles each frame isn’t terribly efficient, but I doubt it would cause problems on modern hardware. Something like this:

local map = mte.getMap() local topLayer = 5 --whatever your top black map layer is for x = -4, 4, 1 do for y = -4, 4, 1 do local locX, locY = player.locX + x, player.locY + y if locX \< 1 then locX = 1 elseif locX \> map.width then locX = map.width end if locY \< 1 then locY = 1 elseif locY \> map.height then locY = map.height end if mte.tileObjects[topLayer][locX][locY] ~= 0 then mte.updateTile({layer = topLayer, locX = locX, locY = locY, tile = 0}) end end end

Revealing a circular region instead of a rectangular region would take a modification to the code. You could define the circular region as a table to loop through, or you could use trigonometry to calculate the circular region on the fly.

that excellent, just what I was looking for, I can get more complex with it later!

Thank, Greg

I gather this isn’t an easy thing to do… you’d probably have to be able to hide/show tiles within a radius right?

gb8, I believe there is a way to do this just don’t remember off the top of my head, did you try emailing michael he is normally pretty responsive and really great at pointing you in the right direction.

I experimented with a Fog of War effect in MTE last year and was quite happy with the results - so it is possible. Doesn’t one of the lighting demos provided give a suggestion of where to start.

If my HDD hadn’t crashed last year I would have supplied code…

Yes, sorry for the delay in getting back to you, but this is one of those open-ended questions with many possible answers. How easy it will be depends on the kind of effect you want and how efficient you want the resulting code to be.

One of the easiest solutions I can think of would be to add a layer to the top of the map and fill it entirely with black tiles. In your enterFrame you could loop through the tiles near your player and remove those black tiles, thus revealing the map. Looping through a few dozen tiles each frame isn’t terribly efficient, but I doubt it would cause problems on modern hardware. Something like this:

local map = mte.getMap() local topLayer = 5 --whatever your top black map layer is for x = -4, 4, 1 do for y = -4, 4, 1 do local locX, locY = player.locX + x, player.locY + y if locX \< 1 then locX = 1 elseif locX \> map.width then locX = map.width end if locY \< 1 then locY = 1 elseif locY \> map.height then locY = map.height end if mte.tileObjects[topLayer][locX][locY] ~= 0 then mte.updateTile({layer = topLayer, locX = locX, locY = locY, tile = 0}) end end end

Revealing a circular region instead of a rectangular region would take a modification to the code. You could define the circular region as a table to loop through, or you could use trigonometry to calculate the circular region on the fly.

that excellent, just what I was looking for, I can get more complex with it later!

Thank, Greg