So you know how half of the sprite sheet is shared with the map? Because of that, usually I use the half for the map, one spritesheet tab for sprites, and one tab for map tiles. Well, I just figured out that in doing so I dont use 1/4th of the tile data. This program I made uses the 1/4th tile data to flip the map tile. I will be making a tool to use this easily soon.
Code to import:
function _map(x,y,sx,sy,celw,celh,layer) local x=x local y=y local celw=celw local celh=celh local layer=layer --not used yet if x==nil then x=0 end if y==nil then y=0 end local sx=x local sy=y if celw==nil then celw=16 end if celh==nil then celh=16 end for i=0,celw*celh do tile=mget(x,y) if tile<64 then --first tab flipx=false flipy=false tile+=64 elseif tile>63 and tile<128 then --second tab flipx=true flipy=false elseif tile>127 and tile<192 then --third tab flipx=false flipy=true tile-=64 else --fourth tab flipx=true flipy=true tile-=128 end spr(tile,x*8,y*8,1,1,flipx,flipy) x+=1 if x==sx+16 then x=0 y+=1 end end end |
The code uses the 2nd spritesheet tab for the tiles.
Call _map() whenever you want to use the function in your game.
P#84531 2020-11-20 15:36 ( Edited 2020-11-20 15:40)
[Please log in to post a comment]