make sprite inputs relative to center of screen

This commit is contained in:
Connor Olding 2018-06-08 14:52:04 +02:00
parent fec148fb79
commit f576a47282

20
smb.lua
View File

@ -88,21 +88,29 @@ local function set_timer(time)
end
local function mark_sprite(x, y, t)
if t == 0 then
-- place unused/unseen sprites
x = -0x08 -- just off the left side of the screen
y = 0xC8 -- at ground level.
end
local cx = 2 * (x - 0x80) -- relative to center of screen.
local cy = 2 * (y - 0x88) -- relative to standing on 4th block from floor.
if x < 0 or x >= 256 or y < 0 or y > 224 then
sprite_input[#sprite_input+1] = 0
sprite_input[#sprite_input+1] = 0
sprite_input[#sprite_input+1] = 0
else
sprite_input[#sprite_input+1] = x
sprite_input[#sprite_input+1] = y
sprite_input[#sprite_input+1] = cx
sprite_input[#sprite_input+1] = cy
sprite_input[#sprite_input+1] = t
end
if t == 0 then return end
if overlay then
if overlay and t ~= 0 then
gui.box(x-4, y-4, x+4, y+4)
--gui.text(x-2, y-3, tostring(i), '#FFFFFF', '#00000000')
gui.text(x-13, y-3-9, ("%+04i"):format(t), '#FFFFFF', '#0000003F')
--gui.text(x-5, y-3+9, ("%02X"):format(x), '#FFFFFF', '#0000003F')
gui.text(x-13, y-3+9, ("%+04i"):format(cx), '#FFFFFF', '#0000003F')
end
end