Add interactability with some map objects, and store changed map tiles in a buffer for persistence.
This commit is contained in:
parent
89a63f59b8
commit
c6dd13d332
6 changed files with 120 additions and 92 deletions
56
main.lua
56
main.lua
|
@ -1,5 +1,5 @@
|
|||
function _init()
|
||||
init_constants()
|
||||
init_data()
|
||||
init_sound()
|
||||
init_mapgen()
|
||||
init_player(32, 32)
|
||||
|
@ -11,7 +11,6 @@ end
|
|||
function _update()
|
||||
handle_input()
|
||||
handle_map_update()
|
||||
debug_input()
|
||||
end
|
||||
|
||||
function _draw()
|
||||
|
@ -41,41 +40,24 @@ function out_of_bounds(pos_x, pos_y)
|
|||
pos_y < 0 or pos_y > 48
|
||||
end
|
||||
|
||||
function debug_input()
|
||||
if btn"5" and btn"4" then
|
||||
if (btnp"0") debug = "res"
|
||||
if (btnp"1") debug = "sfx"
|
||||
if (btnp"2") debug = "map"
|
||||
if (btnp"3") debug = nil
|
||||
end
|
||||
|
||||
function debug_res()
|
||||
print("mem: " + stat(0))
|
||||
print("cpu: " + stat(1))
|
||||
print("fps: " .. stat(9) .. " / " .. stat(8))
|
||||
end
|
||||
|
||||
function render_debug_info()
|
||||
if debug == "res" then
|
||||
clip(0, 0, 32, 24)
|
||||
rectfill(0, 0, 32, 24, 0)
|
||||
|
||||
print(stat(0), 0, 0, 15)
|
||||
print(stat(1), 0, 8, 15)
|
||||
print(stat(9), 0, 16, 15)
|
||||
print("/", 12, 16, 15)
|
||||
print(stat(8), 20, 16, 15)
|
||||
elseif debug == "sfx" then
|
||||
clip(0, 0, 16, 8)
|
||||
rectfill(0, 0, 16, 8, 0)
|
||||
|
||||
print(stat(24), 0, 0, 15)
|
||||
elseif debug == "map" then
|
||||
clip(0, 0, 32, 24)
|
||||
rectfill(0, 0, 32, 24, 0)
|
||||
|
||||
print(camera_pos_x, 0, 0, 15)
|
||||
print(camera_pos_y, 16, 0, 15)
|
||||
print(player_pos_x, 0, 8, 15)
|
||||
print(player_pos_y, 16, 8, 15)
|
||||
print(get_biome_name(player_pos_x, player_pos_y), 0, 16, 15)
|
||||
end
|
||||
|
||||
clip()
|
||||
function debug_sfx()
|
||||
print("Music pattern: " .. stat(24))
|
||||
end
|
||||
|
||||
function debug_map()
|
||||
print("Local: " .. camera_pos_x .. " " .. camera_pos_y)
|
||||
print("Global: " .. player_pos_x .. " " .. player_pos_y)
|
||||
print(get_biome_name(player_pos_x, player_pos_y))
|
||||
end
|
||||
|
||||
function debug_mod_buffer()
|
||||
for k,v in pairs(mod_buffer) do
|
||||
print(k .. ": " .. tostr(v))
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue