--[[pod_format="raw",created="2024-04-14 14:05:11",modified="2024-04-14 15:22:15",revision=25]] mouse_debug = true function _init() x = 128 y = 128 speed = 2 hflip = false playerSpr = 64 end function _draw() cls(0) --camera(x - 240, y - 135) drawMap() spr(playerSpr,x,y, hflip) debug_mouse() end function drawMap() for i=2,1,-1 do map(fetch"map/0.map"[i].bmp) end end function _update() local col_x = x local col_y = y if (btn(0)) col_x -= speed hflip = true if (btn(1)) col_x += speed hflip = false if (btn(2)) col_y -= speed if (btn(3)) col_y += speed if (checkCollision(col_x,col_y) == true) then x = col_x y = col_y end end function checkCollision(x,y) return fget(mget(x,y),0) end function debug_mouse() local mx,my = mouse() local x_offset = 5 local y_offset = 5 -- tile size local tw=16 local th=16 -- window width and height local w=480 local h=270 -- offset if box leaves screen if mx>w-20 then x_offset=-15 end if my>h-29 then y_offset=-24 end -- draw debug text box local tile_x = mx/tw local tile_y = my/th local sprite = mget(tile_x,tile_y) local flag = fget(sprite) rectfill(mx+x_offset-1,my+y_offset-1,mx+x_offset+14,my+y_offset+23+8,1) print(mx/tw,mx+x_offset,my+y_offset,8) print(my/th,mx+x_offset,my+y_offset+8,9) print(sprite,mx+x_offset,my+y_offset+8*2,10) print(flag,mx+x_offset,my+y_offset+8+8*2,10) end