I'm back. Ready your faces for palming.
I'm still programming a little 2D tile engine ala the old retro RPGs of yore (Ultima, Wasteland, etc.)
I've programmed a fog of war setup that uses a rogue-like line of sight routine to determine which blocks are "seen" and then it does post-processing on darkened tiles to make the edges rounded off.
It works okay when the player is outdoors. I never could get it to work indoors and I couldn't understand why.
My question for now is - is there an easier way to do this? My method was the most straightforward answer I could come up with. I go to each dark tile on the viewport, see what tiles are around it, and then I paste a pre-made curved or otherwise "fitted" tile to make the transition smooth.
Here's part of the code that does the tile transitions outside.
All tiles start covered in darkness/fog of war.
If a tile is "discovered" then it has been seen by the player and will always show up - unless the player goes in a building. Walls always block line of sight.
.dark = 42, .dark = 44, etc. Those are my transition tile graphics. I have one for each cardinal compass direction.
As I mentioned above the routine checks to see what neighbor tiles are doing and then determines what tile to place to make it smooth looking. It also eliminates shapes that I don't have graphics to cover - like long 1 tile wide rows.
A "roof" tile is really just a floor tile. I'm using "roof" to indicate that it's a tile that is considered "inside". I will rename that later.
` Shadow shaping for outdoor tiles
if Tiles(Map_Array(mx,my).Tile_Type).Dark > 0 and Tiles(Map_Array(Viewport_X + Player_X,Viewport_Y + Player_Y).Tile_Type).Roof = 0 and Tiles(Map_Array(mx,my).Tile_Type).Roof = 0
myminus = my-1 ` if 'my' reaches -1 then it goes outside the array... That's bad
if myminus < 0
myminus = 0
endif
myplus = my+1
if myplus > Map_Size_Height-1
myplus = Map_Size_Height-1
endif
mxminus = mx-1
if mxminus < 0
mxminus = 0
endif
mxplus = mx+1
if mxplus > Map_Size_Width - 1
mxplus = Map_Size_Width - 1
endif
` N
if map_array(mx,myminus).discovered = 1
Tiles(Map_Array(mx,my).Tile_Type).Dark = 38
endif
` E
if map_array(mxplus,my).discovered = 1
Tiles(Map_Array(mx,my).Tile_Type).Dark = 42
endif
` S
if map_array(mx,myplus).discovered = 1
Tiles(Map_Array(mx,my).Tile_Type).Dark = 44
endif
` W
if map_array(mxminus,my).discovered = 1
Tiles(Map_Array(mx,my).Tile_Type).Dark = 40
endif
` NE
if map_array(mx,myminus).discovered = 1 and map_array(mxplus,my).discovered = 1
Tiles(Map_Array(mx,my).Tile_Type).Dark = 39
endif
` SE
if map_array(mxplus,my).discovered = 1 and map_array(mx,myplus).discovered = 1
Tiles(Map_Array(mx,my).Tile_Type).Dark = 45
endif
` SW
if map_array(mx,myplus).discovered = 1 and map_array(mxminus,my).discovered = 1
Tiles(Map_Array(mx,my).Tile_Type).Dark = 43
endif
` NW
if map_array(mx,myminus).discovered = 1 and map_array(mxminus,my).discovered = 1
Tiles(Map_Array(mx,my).Tile_Type).Dark = 37
endif
` forever alone - these statements clean up loose ends
` single horizontal row tile - eliminate it
if map_array(mx,myminus).discovered = 1 and map_array(mx,myplus).discovered = 1
map_array(mx,my).discovered = 1
endif
` single vertical row tile - eliminate it
if map_array(mxminus,my).discovered = 1 and map_array(mxplus,my).discovered = 1
map_array(mx,my).discovered = 1
endif
ENDIF
I also attached a WIP so you can see it in action.
Please let me know if there is a better way to do this. I suspect there is but I could not understand the few examples I saw online.
I'm sort of curious as to what FPS you are getting too.