Move debug code to a separate file.
This commit is contained in:
parent
a75408fb22
commit
53896b0f0e
|
@ -1,6 +1,7 @@
|
|||
pico-8 cartridge // http://www.pico-8.com
|
||||
version 18
|
||||
__lua__
|
||||
#include debug.lua
|
||||
#include data.lua
|
||||
#include sound.lua
|
||||
#include mapgen.lua
|
||||
|
|
70
debug.lua
Normal file
70
debug.lua
Normal file
|
@ -0,0 +1,70 @@
|
|||
-- various functions to support printing debug info
|
||||
|
||||
-- debug functions toggle debug status displays along the
|
||||
-- top of the screen
|
||||
function init_debug()
|
||||
debug_res = false
|
||||
debug_map = false
|
||||
debug_sfx = false
|
||||
debug_mod_buffer = false
|
||||
end
|
||||
|
||||
function debug_t(mode)
|
||||
if mode == "res" then
|
||||
debug_res = not debug_res
|
||||
elseif mode == "map" then
|
||||
debug_map = not debug_map
|
||||
elseif mode == "sfx" then
|
||||
debug_sfx = not debug_sfx
|
||||
elseif mode == "" then
|
||||
debug_mod_buffer = not debug_mod_buffer
|
||||
end
|
||||
end
|
||||
|
||||
function debug_print()
|
||||
if debug_res then
|
||||
debug_print_res()
|
||||
end
|
||||
|
||||
if debug_map then
|
||||
debug_print_map()
|
||||
end
|
||||
|
||||
if debug_sfx then
|
||||
debug_print_sfx()
|
||||
end
|
||||
|
||||
if debug_mod_buffer then
|
||||
debug_print_mod_buffer()
|
||||
end
|
||||
end
|
||||
|
||||
function debug_print_res()
|
||||
clip(70, 0, 16, 24)
|
||||
print(stat(0), 70, 0, 15)
|
||||
print(stat(1), 70, 8, 15)
|
||||
print(stat(9) .. " / " .. stat(8), 70, 16, 15)
|
||||
clip()
|
||||
end
|
||||
|
||||
function debug_print_sfx()
|
||||
clip(64, 0, 8, 8)
|
||||
print(stat(24), 64, 0, 15)
|
||||
clip()
|
||||
end
|
||||
|
||||
function debug_print_map()
|
||||
clip(24, 0, 32, 24)
|
||||
print(camera_pos_x .. " " .. camera_pos_y, 24, 0, 15)
|
||||
print(player_pos_x .. " " .. player_pos_y, 24, 8, 15)
|
||||
print(get_biome_name(player_pos_x, player_pos_y), 24, 16, 15)
|
||||
clip()
|
||||
end
|
||||
|
||||
function debug_print_mod_buffer()
|
||||
clip(0, 0, 16, 128)
|
||||
for k,v in pairs(mod_buffer) do
|
||||
print(k .. ": " .. tostr(v))
|
||||
end
|
||||
clip()
|
||||
end
|
69
main.lua
69
main.lua
|
@ -37,72 +37,3 @@ function out_of_bounds(pos_x, pos_y)
|
|||
return pos_x < 0 or pos_x > 48 or
|
||||
pos_y < 0 or pos_y > 48
|
||||
end
|
||||
|
||||
-- debug functions toggle debug status displays along the
|
||||
-- top of the screen
|
||||
function init_debug()
|
||||
debug_res = false
|
||||
debug_map = false
|
||||
debug_sfx = false
|
||||
debug_mod_buffer = false
|
||||
end
|
||||
|
||||
function debug_t(mode)
|
||||
if mode == "res" then
|
||||
debug_res = not debug_res
|
||||
elseif mode == "map" then
|
||||
debug_map = not debug_map
|
||||
elseif mode == "sfx" then
|
||||
debug_sfx = not debug_sfx
|
||||
elseif mode == "" then
|
||||
debug_mod_buffer = not debug_mod_buffer
|
||||
end
|
||||
end
|
||||
|
||||
function debug_print()
|
||||
if debug_res then
|
||||
debug_print_res()
|
||||
end
|
||||
|
||||
if debug_map then
|
||||
debug_print_map()
|
||||
end
|
||||
|
||||
if debug_sfx then
|
||||
debug_print_sfx()
|
||||
end
|
||||
|
||||
if debug_mod_buffer then
|
||||
debug_print_mod_buffer()
|
||||
end
|
||||
end
|
||||
|
||||
function debug_print_res()
|
||||
clip(70, 0, 16, 24)
|
||||
print(stat(0), 70, 0, 15)
|
||||
print(stat(1), 70, 8, 15)
|
||||
print(stat(9) .. " / " .. stat(8), 70, 16, 15)
|
||||
clip()
|
||||
end
|
||||
|
||||
function debug_print_sfx()
|
||||
clip(64, 0, 8, 8)
|
||||
print(stat(24), 64, 0, 15)
|
||||
clip()
|
||||
end
|
||||
|
||||
function debug_print_map()
|
||||
clip(24, 0, 32, 24)
|
||||
print(camera_pos_x .. " " .. camera_pos_y, 24, 0, 15)
|
||||
print(player_pos_x .. " " .. player_pos_y, 24, 8, 15)
|
||||
print(get_biome_name(player_pos_x, player_pos_y), 24, 16, 15)
|
||||
clip()
|
||||
end
|
||||
|
||||
function debug_print_mod_buffer()
|
||||
clip(0, 0, 16, 128)
|
||||
for k,v in pairs(mod_buffer) do
|
||||
print(k .. ": " .. tostr(v))
|
||||
end
|
||||
clip()
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user