diff --git a/infimap.lua b/infimap.lua index 5ff8bb2..6b15255 100644 --- a/infimap.lua +++ b/infimap.lua @@ -29,6 +29,6 @@ function render_debug_info() print(camera_pos[2], 16, 8, 15) print(facing[1], 0, 16, 15) print(facing[2], 16, 16, 15) - print(player_lookup[facing], 0, 24, 15) + print(fget(mget(camera_pos[1]+8, camera_pos[2]+8)), 0, 24, 15) clip() end diff --git a/movement.lua b/movement.lua index 61c6b19..4e8dd17 100644 --- a/movement.lua +++ b/movement.lua @@ -7,15 +7,21 @@ function init_movement() -- this is a constant for looking up player sprites by facing player_lookup = { - [{0, 0}] = -1, -- this state is an error - [{-1, 0}] = 120, -- up - [{1, 0}] = 121, -- down - [{0, -1}] = 122, -- left - [{0, 1}] = 123, -- right - [{-1, -1}] = 124, -- up-left - [{-1, 1}] = 125, -- up-right - [{1, -1}] = 126, -- down-left - [{1, 1}] = 127 -- down-right + [0] = { + [0] = -1, -- error state + [-1] = 122, -- left + [1] = 123, -- right + }, + [-1] = { + [0] = 120, -- up + [-1] = 124, -- up-left + [1] = 125, -- up-right + }, + [1] = { + [0] = 121, -- down + [-1] = 126, -- down-left + [1] = 127, -- down-right + }, } end @@ -57,12 +63,12 @@ function handle_input() end function draw_player() - spr(player_lookup[facing], 64, 64) + spr(player_lookup[facing[1]][facing[2]], 64, 64) -- todo: animate the character on move end --- pos is a camera position, meaning the player position is --- pos + {8, 8} +-- pos is camera position, meaning the player position is +-- pos + {8, 8}. function legal_move(pos) return fget(mget(pos[1]+8, pos[2]+8), 0) end