mirror of
https://gitlab.com/MaddoScientisto/cirnofarm.git
synced 2026-06-01 11:15:34 +00:00
Refactored code
This commit is contained in:
parent
cd9ec6cc01
commit
4407ce108b
8 changed files with 128 additions and 95 deletions
36
src/game.lua
36
src/game.lua
|
|
@ -53,6 +53,8 @@ end
|
|||
|
||||
local cirno = require(make_path("cirno"))
|
||||
local mouse_debug = require(make_path("mouse_debug"))
|
||||
local map_manager = require(make_path("map"))
|
||||
local weapons_manager = require(make_path("weapons"))
|
||||
|
||||
tile_width = 16
|
||||
tile_height = 16
|
||||
|
|
@ -63,9 +65,41 @@ end
|
|||
|
||||
function _update()
|
||||
cirno.update()
|
||||
|
||||
weapons_manager.update()
|
||||
end
|
||||
|
||||
LAYERS = {
|
||||
{index=4, name="background", render=true, render_objects=false, spawn_objects=false},
|
||||
{index=3, name="solid", render=true, render_objects=true, spawn_objects=false},
|
||||
{index=2, name="foreground", render=true, render_objects=false, spawn_objects=false},
|
||||
{index=1, name="objects", render=false, render_objects=false, spawn_objects=true}
|
||||
}
|
||||
|
||||
function _draw()
|
||||
cirno.draw()
|
||||
cls(0)
|
||||
|
||||
foreach(LAYERS, render_layer)
|
||||
|
||||
mouse_debug.draw(4, tile_width, tile_height)
|
||||
weapons_manager.debug_draw()
|
||||
end
|
||||
|
||||
function render_layer(layer)
|
||||
if (layer.render) then
|
||||
-- todo move function in map manager
|
||||
map(fetch("map/".. map_manager.get_current_map() .. ".map")[layer.index].bmp)
|
||||
end
|
||||
|
||||
if (layer.render_objects) then
|
||||
-- Render all objects here
|
||||
cirno.draw()
|
||||
|
||||
weapons_manager.draw()
|
||||
|
||||
-- for b in all(bullets) do
|
||||
-- b:draw()
|
||||
-- end
|
||||
end
|
||||
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue