feat: added new functionality with focus, added base background to screens, created Focus.close(), Focus.start(), Focus.driven() methods for different use-cases, added focus to screens
This commit is contained in:
@@ -6,17 +6,23 @@ local _selected_decision_index = 1
|
||||
--- @within GameWindow
|
||||
function GameWindow.draw()
|
||||
local screen = Screen.get_by_id(Context.game.current_screen)
|
||||
if screen.background then Map.draw(screen.background) end
|
||||
if screen.background then
|
||||
Map.draw(screen.background)
|
||||
elseif screen.background_color then
|
||||
rect(0, 0, Config.screen.width, Config.screen.height, screen.background_color)
|
||||
end
|
||||
UI.draw_top_bar(screen.name)
|
||||
if #_available_decisions > 0 then
|
||||
UI.draw_decision_selector(_available_decisions, _selected_decision_index)
|
||||
end
|
||||
Sprite.draw()
|
||||
Focus.draw()
|
||||
end
|
||||
|
||||
--- Updates the game window logic.
|
||||
--- @within GameWindow
|
||||
function GameWindow.update()
|
||||
Focus.update()
|
||||
if Input.menu_back() then
|
||||
Window.set_current("menu")
|
||||
MenuWindow.refresh_menu_items()
|
||||
@@ -60,6 +66,8 @@ function GameWindow.update()
|
||||
selected_decision.handle()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
--- Sets the active window.
|
||||
|
||||
@@ -13,7 +13,13 @@ end
|
||||
--- @param[opt] params table Optional parameters for minigame configuration.
|
||||
function MinigameButtonMashWindow.start(return_window, params)
|
||||
MinigameButtonMashWindow.init(params)
|
||||
Context.minigame_button_mash.return_window = return_window or "game"
|
||||
local mg = Context.minigame_button_mash
|
||||
mg.return_window = return_window or "game"
|
||||
if mg.focus_center_x then
|
||||
Focus.start_driven(mg.focus_center_x, mg.focus_center_y, {
|
||||
initial_radius = mg.focus_initial_radius
|
||||
})
|
||||
end
|
||||
Window.set_current("minigame_button_mash")
|
||||
end
|
||||
|
||||
@@ -31,6 +37,7 @@ function MinigameButtonMashWindow.update()
|
||||
if mg.bar_fill >= mg.max_fill then
|
||||
Meter.on_minigame_complete()
|
||||
Meter.show()
|
||||
if mg.focus_center_x then Focus.stop() end
|
||||
Window.set_current(mg.return_window)
|
||||
return
|
||||
end
|
||||
@@ -42,6 +49,9 @@ function MinigameButtonMashWindow.update()
|
||||
if mg.button_pressed_timer > 0 then
|
||||
mg.button_pressed_timer = mg.button_pressed_timer - 1
|
||||
end
|
||||
if mg.focus_center_x then
|
||||
Focus.set_percentage(mg.bar_fill / mg.max_fill)
|
||||
end
|
||||
end
|
||||
|
||||
--- Draws button mash minigame.
|
||||
@@ -51,7 +61,9 @@ function MinigameButtonMashWindow.draw()
|
||||
if mg.return_window == "game" then
|
||||
GameWindow.draw()
|
||||
end
|
||||
rect(0, 0, Config.screen.width, Config.screen.height, Config.colors.black)
|
||||
if not mg.focus_center_x then
|
||||
rect(0, 0, Config.screen.width, Config.screen.height, Config.colors.black)
|
||||
end
|
||||
rect(mg.bar_x - 2, mg.bar_y - 2, mg.bar_width + 4, mg.bar_height + 4, Config.colors.light_grey)
|
||||
rectb(mg.bar_x - 2, mg.bar_y - 2, mg.bar_width + 4, mg.bar_height + 4, Config.colors.dark_grey)
|
||||
local fill_width = (mg.bar_fill / mg.max_fill) * mg.bar_width
|
||||
|
||||
@@ -13,7 +13,13 @@ end
|
||||
--- @param[opt] params table Optional parameters for minigame configuration.
|
||||
function MinigameRhythmWindow.start(return_window, params)
|
||||
MinigameRhythmWindow.init(params)
|
||||
Context.minigame_rhythm.return_window = return_window or "game"
|
||||
local mg = Context.minigame_rhythm
|
||||
mg.return_window = return_window or "game"
|
||||
if mg.focus_center_x then
|
||||
Focus.start_driven(mg.focus_center_x, mg.focus_center_y, {
|
||||
initial_radius = mg.focus_initial_radius
|
||||
})
|
||||
end
|
||||
Window.set_current("minigame_rhythm")
|
||||
end
|
||||
|
||||
@@ -53,12 +59,16 @@ function MinigameRhythmWindow.update()
|
||||
if mg.score >= mg.max_score then
|
||||
Meter.on_minigame_complete()
|
||||
Meter.show()
|
||||
if mg.focus_center_x then Focus.stop() end
|
||||
Window.set_current(mg.return_window)
|
||||
return
|
||||
end
|
||||
if mg.button_pressed_timer > 0 then
|
||||
mg.button_pressed_timer = mg.button_pressed_timer - 1
|
||||
end
|
||||
if mg.focus_center_x then
|
||||
Focus.set_percentage(1 - mg.score / mg.max_score)
|
||||
end
|
||||
end
|
||||
|
||||
--- Draws rhythm minigame.
|
||||
@@ -68,7 +78,9 @@ function MinigameRhythmWindow.draw()
|
||||
if mg.return_window == "game" then
|
||||
GameWindow.draw()
|
||||
end
|
||||
rect(0, 0, Config.screen.width, Config.screen.height, Config.colors.black)
|
||||
if not mg.focus_center_x then
|
||||
rect(0, 0, Config.screen.width, Config.screen.height, Config.colors.black)
|
||||
end
|
||||
rect(mg.bar_x - 2, mg.bar_y - 2, mg.bar_width + 4, mg.bar_height + 4, Config.colors.light_grey)
|
||||
rectb(mg.bar_x - 2, mg.bar_y - 2, mg.bar_width + 4, mg.bar_height + 4, Config.colors.dark_grey)
|
||||
rect(mg.bar_x, mg.bar_y, mg.bar_width, mg.bar_height, Config.colors.dark_grey)
|
||||
|
||||
Reference in New Issue
Block a user