Fix player sprite rendering.
This commit is contained in:
parent
d9714fb284
commit
98707059b6
|
@ -29,6 +29,6 @@ function render_debug_info()
|
||||||
print(camera_pos[2], 16, 8, 15)
|
print(camera_pos[2], 16, 8, 15)
|
||||||
print(facing[1], 0, 16, 15)
|
print(facing[1], 0, 16, 15)
|
||||||
print(facing[2], 16, 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()
|
clip()
|
||||||
end
|
end
|
||||||
|
|
30
movement.lua
30
movement.lua
|
@ -7,15 +7,21 @@ function init_movement()
|
||||||
|
|
||||||
-- this is a constant for looking up player sprites by facing
|
-- this is a constant for looking up player sprites by facing
|
||||||
player_lookup = {
|
player_lookup = {
|
||||||
[{0, 0}] = -1, -- this state is an error
|
[0] = {
|
||||||
[{-1, 0}] = 120, -- up
|
[0] = -1, -- error state
|
||||||
[{1, 0}] = 121, -- down
|
[-1] = 122, -- left
|
||||||
[{0, -1}] = 122, -- left
|
[1] = 123, -- right
|
||||||
[{0, 1}] = 123, -- right
|
},
|
||||||
[{-1, -1}] = 124, -- up-left
|
[-1] = {
|
||||||
[{-1, 1}] = 125, -- up-right
|
[0] = 120, -- up
|
||||||
[{1, -1}] = 126, -- down-left
|
[-1] = 124, -- up-left
|
||||||
[{1, 1}] = 127 -- down-right
|
[1] = 125, -- up-right
|
||||||
|
},
|
||||||
|
[1] = {
|
||||||
|
[0] = 121, -- down
|
||||||
|
[-1] = 126, -- down-left
|
||||||
|
[1] = 127, -- down-right
|
||||||
|
},
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -57,12 +63,12 @@ function handle_input()
|
||||||
end
|
end
|
||||||
|
|
||||||
function draw_player()
|
function draw_player()
|
||||||
spr(player_lookup[facing], 64, 64)
|
spr(player_lookup[facing[1]][facing[2]], 64, 64)
|
||||||
-- todo: animate the character on move
|
-- todo: animate the character on move
|
||||||
end
|
end
|
||||||
|
|
||||||
-- pos is a camera position, meaning the player position is
|
-- pos is camera position, meaning the player position is
|
||||||
-- pos + {8, 8}
|
-- pos + {8, 8}.
|
||||||
function legal_move(pos)
|
function legal_move(pos)
|
||||||
return fget(mget(pos[1]+8, pos[2]+8), 0)
|
return fget(mget(pos[1]+8, pos[2]+8), 0)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user