Created
April 19, 2016 00:18
-
-
Save anonymous/67f2ec9ae41a3694a10f4bc7205cbf4f to your computer and use it in GitHub Desktop.
NES Star Soldier (J) hitbox
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local OBJ_N = 24 | |
local BLT_N = 8 | |
local MYBLT_N = 15 | |
local HERO_HIT_OBJ = 14 | |
local HERO_HIT_BLT = 12 | |
local OBJ_HIT_OBJ = 14 | |
local OBJ_HIT_BLT = 12 | |
local BLT_HIT = 6 | |
local MYBLT_HIT = 6 | |
local COLOR_HERO_OBJ = "#00FFFF" | |
local COLOR_HERO_BLT = "#FFFF00" | |
local COLOR_OBJ_OBJ = "#00FFFF" | |
local COLOR_OBJ_BLT = "#FFFF00" | |
local COLOR_BLT = "#FFFF00" | |
local COLOR_MYBLT = "#00FF00" | |
local function array_append(ary, o) | |
ary[#ary+1] = o | |
end | |
local function get_info() | |
local info = {} | |
info.hero_x = memory.readbyte(0x3A) | |
info.hero_y = memory.readbyte(0x3B) | |
info.objs = {} | |
for i = 1, OBJ_N do | |
if memory.readbyte(0x0400+i-1) ~= 0 then | |
local obj = {} | |
obj.x = memory.readbyte(0x0418+i-1) | |
obj.y = memory.readbyte(0x0430+i-1) | |
array_append(info.objs, obj) | |
end | |
end | |
info.blts = {} | |
for i = 1, BLT_N do | |
if memory.readbyte(0x0648+i-1) ~= 0 then | |
local blt = {} | |
blt.x = memory.readbyte(0x0650+i-1) | |
blt.y = memory.readbyte(0x0658+i-1) | |
array_append(info.blts, blt) | |
end | |
end | |
info.myblts = {} | |
for i = 1, MYBLT_N do | |
if memory.readbyte(0x061B+i-1) ~= 0 then | |
local myblt = {} | |
myblt.x = memory.readbyte(0x062A+i-1) | |
myblt.y = memory.readbyte(0x0639+i-1) | |
array_append(info.myblts, myblt) | |
end | |
end | |
return info | |
end | |
local function square(x, y, l, color) | |
gui.drawbox(x, y, x+l, y+l, "clear", color) | |
end | |
local function draw() | |
local info = get_info() | |
square(info.hero_x, info.hero_y, HERO_HIT_BLT, COLOR_HERO_BLT) | |
square(info.hero_x, info.hero_y, HERO_HIT_OBJ, COLOR_HERO_OBJ) | |
for _, obj in ipairs(info.objs) do | |
square(obj.x, obj.y, OBJ_HIT_BLT, COLOR_OBJ_BLT) | |
square(obj.x, obj.y, OBJ_HIT_OBJ, COLOR_OBJ_OBJ) | |
end | |
for _, blt in ipairs(info.blts) do | |
square(blt.x, blt.y, BLT_HIT, COLOR_BLT) | |
end | |
for _, myblt in ipairs(info.myblts) do | |
square(myblt.x, myblt.y, MYBLT_HIT, COLOR_MYBLT) | |
end | |
end | |
local function main() | |
emu.registerafter(draw) | |
end | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment