docs
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
2026-02-21 23:53:36 +01:00
parent 3b137fd48e
commit 787b6656b0
6 changed files with 101 additions and 9 deletions

View File

@@ -1,3 +1,6 @@
--- Draws the main game window content.
-- This includes the current screen's background, top bar, decisions, and all active sprites.
-- @function GameWindow.draw
function GameWindow.draw()
local screen = Context.screens[Context.current_screen]
Map.draw(screen.background)
@@ -17,7 +20,13 @@ function GameWindow.draw()
Sprite.draw()
end
--- Updates the logic for the main game window.
-- Handles input, navigates between screens, calls the current screen's and situation's update functions,
-- and processes player decisions.
-- @function GameWindow.update
function GameWindow.update()
local previous_screen_index = Context.current_screen
if Input.menu_back() then
Context.active_window = WINDOW_MENU
MenuWindow.refresh_menu_items()
@@ -37,6 +46,19 @@ function GameWindow.update()
Context.selected_decision_index = 1 end
local screen = Context.screens[Context.current_screen]
screen.update()
if previous_screen_index ~= Context.current_screen then
screen.init()
end
if Context.current_situation then
local current_situation_obj = Situation.get(Context.current_situation)
if current_situation_obj and current_situation_obj.update then
current_situation_obj.update()
end
end
if screen and screen.decisions and #screen.decisions > 0 then
local available_decisions = {}
for _, decision_id in ipairs(screen.decisions) do
@@ -64,6 +86,10 @@ function GameWindow.update()
end
end
--- Sets the active window state for the game.
-- This function is typically called when transitioning between different game states (e.g., to a minigame).
-- @param new_state number The ID of the new active window (e.g., `WINDOW_MENU`, `WINDOW_GAME`).
-- @function GameWindow.set_state
function GameWindow.set_state(new_state)
Context.active_window = new_state
end
end