Lots of code cleanup. Start implementing mod buffer culling.
This commit is contained in:
parent
16bcbc8e00
commit
1e9c456f78
4 changed files with 56 additions and 81 deletions
24
main.lua
24
main.lua
|
@ -1,38 +1,18 @@
|
|||
function _init()
|
||||
init_sound""
|
||||
init_world""
|
||||
init_player(32, 32)
|
||||
init_player""
|
||||
init_debug""
|
||||
end
|
||||
|
||||
|
||||
function _update()
|
||||
handle_input""
|
||||
-- handle_map_update""
|
||||
end
|
||||
|
||||
function _draw()
|
||||
cls""
|
||||
-- the screen is 128x128 pixels, so it fits 16x16 sprites
|
||||
-- map(camera_pos_x, camera_pos_y, 0, 0, 16, 16)
|
||||
draw_world_segment(player_pos_x, player_pos_y)
|
||||
draw_world(player_x, player_y)
|
||||
draw_player""
|
||||
debug_print""
|
||||
end
|
||||
|
||||
-- decide whether we need to regenerate the map.
|
||||
-- if so, call generate_map appropriately and reset coordinates.
|
||||
function handle_map_update()
|
||||
if out_of_bounds(camera_pos_x, camera_pos_y) then
|
||||
-- out_of_bounds() checks all screen bounds
|
||||
-- we need to regenerate the map, so we generate a map chunk that
|
||||
-- places the player in the middle of it.
|
||||
generate_map(player_pos_x-32, player_pos_y-32)
|
||||
camera_pos_x, camera_pos_y = 24, 24
|
||||
end
|
||||
end
|
||||
|
||||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue