From f576a4728295cc4dd2ae13965f0df1495aced87d Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Fri, 8 Jun 2018 14:52:04 +0200 Subject: [PATCH] make sprite inputs relative to center of screen --- smb.lua | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/smb.lua b/smb.lua index dbda609..71137ef 100644 --- a/smb.lua +++ b/smb.lua @@ -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