Compare commits

...

3 Commits

Author SHA1 Message Date
Zoltan Timar
9014e36014 feat: moved minigames to their separate context
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-02-18 21:43:16 +01:00
Zoltan Timar
7b263bb454 fix: desition -> decision
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2026-02-18 21:42:40 +01:00
0640964ee4 Merge pull request 'feature/background-manager' (#6) from feature/background-manager into master
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
Reviewed-on: http://git.teletype.hu/games/impostor/pulls/6
2026-02-18 18:29:51 +00:00
25 changed files with 233 additions and 208 deletions

View File

@@ -3,7 +3,7 @@
globals = { globals = {
"Util", "Util",
"DesitionManager", "DecisionManager",
"ScreenManager", "ScreenManager",
"UI", "UI",
"Print", "Print",

View File

@@ -1,17 +1,18 @@
meta/meta.header.lua meta/meta.header.lua
init/init.modules.lua init/init.modules.lua
init/init.config.lua init/init.config.lua
init/init.minigames.lua
system/system.util.lua system/system.util.lua
init/init.windows.lua init/init.windows.lua
desition/desition.manager.lua decision/decision.manager.lua
desition/desition.go_to_home.lua decision/decision.go_to_home.lua
desition/desition.go_to_toilet.lua decision/decision.go_to_toilet.lua
desition/desition.go_to_walking_to_office.lua decision/decision.go_to_walking_to_office.lua
desition/desition.go_to_office.lua decision/decision.go_to_office.lua
desition/desition.go_to_walking_to_home.lua decision/decision.go_to_walking_to_home.lua
desition/desition.play_button_mash.lua decision/decision.play_button_mash.lua
desition/desition.play_rhythm.lua decision/decision.play_rhythm.lua
desition/desition.play_ddr.lua decision/decision.play_ddr.lua
map/map.manager.lua map/map.manager.lua
map/map.bedroom.lua map/map.bedroom.lua
screen/screen.manager.lua screen/screen.manager.lua

View File

@@ -1,4 +1,4 @@
DesitionManager.register({ DecisionManager.register({
id = "go_to_home", id = "go_to_home",
label = "Go to Home", label = "Go to Home",
handle = function() handle = function()

View File

@@ -1,4 +1,4 @@
DesitionManager.register({ DecisionManager.register({
id = "go_to_office", id = "go_to_office",
label = "Go to Office", label = "Go to Office",
handle = function() handle = function()

View File

@@ -1,4 +1,4 @@
DesitionManager.register({ DecisionManager.register({
id = "go_to_toilet", id = "go_to_toilet",
label = "Go to Toilet", label = "Go to Toilet",
handle = function() handle = function()

View File

@@ -1,4 +1,4 @@
DesitionManager.register({ DecisionManager.register({
id = "go_to_walking_to_home", id = "go_to_walking_to_home",
label = "Walking to home", label = "Walking to home",
handle = function() handle = function()

View File

@@ -1,4 +1,4 @@
DesitionManager.register({ DecisionManager.register({
id = "go_to_walking_to_office", id = "go_to_walking_to_office",
label = "Walking to office", label = "Walking to office",
handle = function() handle = function()

View File

@@ -0,0 +1,31 @@
local _decisions = {}
function DecisionManager.register(decision)
if not decision or not decision.id then
PopupWindow.show({"Error: Invalid decision object registered (missing id)!"})
return
end
if not decision.label then
PopupWindow.show({"Error: Invalid decision object registered (missing label)!"})
return
end
if not decision.condition then
decision.condition = function() return true end
end
if not decision.handle then
decision.handle = function() end
end
if _decisions[decision.id] then
trace("Warning: Overwriting decision with id: " .. decision.id)
end
_decisions[decision.id] = decision
end
function DecisionManager.get(id)
return _decisions[id]
end
function DecisionManager.get_all()
return _decisions
end

View File

@@ -1,4 +1,4 @@
DesitionManager.register({ DecisionManager.register({
id = "play_button_mash", id = "play_button_mash",
label = "Play Button Mash", label = "Play Button Mash",
handle = function() MinigameButtonMashWindow.start(WINDOW_GAME) end, handle = function() MinigameButtonMashWindow.start(WINDOW_GAME) end,

View File

@@ -1,4 +1,4 @@
DesitionManager.register({ DecisionManager.register({
id = "play_ddr", id = "play_ddr",
label = "Play DDR (Random)", label = "Play DDR (Random)",
handle = function() MinigameDDRWindow.start(WINDOW_GAME, nil) end, handle = function() MinigameDDRWindow.start(WINDOW_GAME, nil) end,

View File

@@ -1,4 +1,4 @@
DesitionManager.register({ DecisionManager.register({
id = "play_rhythm", id = "play_rhythm",
label = "Play Rhythm Game", label = "Play Rhythm Game",
handle = function() MinigameRhythmWindow.start(WINDOW_GAME) end, handle = function() MinigameRhythmWindow.start(WINDOW_GAME) end,

View File

@@ -1,31 +0,0 @@
local _desitions = {}
function DesitionManager.register(desition)
if not desition or not desition.id then
PopupWindow.show({"Error: Invalid desition object registered (missing id)!"})
return
end
if not desition.label then
PopupWindow.show({"Error: Invalid desition object registered (missing label)!"})
return
end
if not desition.condition then
desition.condition = function() return true end
end
if not desition.handle then
desition.handle = function() end
end
if _desitions[desition.id] then
trace("Warning: Overwriting desition with id: " .. desition.id)
end
_desitions[desition.id] = desition
end
function DesitionManager.get(id)
return _desitions[id]
end
function DesitionManager.get_all()
return _desitions
end

View File

@@ -8,6 +8,7 @@ local DEFAULT_CONFIG = {
light_grey = 13, light_grey = 13,
dark_grey = 14, dark_grey = 14,
green = 6, green = 6,
blue = 9,
item = 12 item = 12
}, },
player = { player = {

View File

@@ -39,9 +39,12 @@ on than meets the eye.]]
}, },
menu_items = {}, menu_items = {},
selected_menu_item = 1, selected_menu_item = 1,
selected_desition_index = 1, selected_decision_index = 1,
game_in_progress = false, game_in_progress = false,
screens = {} screens = {},
minigame_ddr = Minigames.get_default_ddr(),
minigame_button_mash = Minigames.get_default_button_mash(),
minigame_rhythm = Minigames.get_default_rhythm()
} }
end end
@@ -66,7 +69,8 @@ local function reset_context_to_initial_state()
local screen_data = ScreenManager.get_by_id(screen_id) local screen_data = ScreenManager.get_by_id(screen_id)
if screen_data then if screen_data then
table.insert(Context.screens, screen_data) table.insert(Context.screens, screen_data)
Context.screen_indices_by_id[screen_id] = i else Context.screen_indices_by_id[screen_id] = i
else
PopupWindow.show({"Error: Screen '" .. screen_id .. "' not registered!"}) PopupWindow.show({"Error: Screen '" .. screen_id .. "' not registered!"})
end end
end end

107
inc/init/init.minigames.lua Normal file
View File

@@ -0,0 +1,107 @@
Minigames = {}
local function apply_params(defaults, params)
if not params then return defaults end
for k, v in pairs(params) do
defaults[k] = v
end
return defaults
end
function Minigames.get_default_ddr()
local arrow_size = 12
local arrow_spacing = 30
local total_width = (4 * arrow_size) + (3 * arrow_spacing)
local start_x = (Config.screen.width - total_width) / 2
return {
bar_fill = 0,
max_fill = 100,
fill_per_hit = 10,
miss_penalty = 5,
bar_x = 20,
bar_y = 10,
bar_width = 200,
bar_height = 12,
arrow_size = arrow_size,
arrow_spawn_timer = 0,
arrow_spawn_interval = 45,
arrow_fall_speed = 1.5,
arrows = {},
target_y = 115,
target_arrows = {
{ dir = "left", x = start_x },
{ dir = "down", x = start_x + arrow_size + arrow_spacing },
{ dir = "up", x = start_x + (arrow_size + arrow_spacing) * 2 },
{ dir = "right", x = start_x + (arrow_size + arrow_spacing) * 3 }
},
hit_threshold = 8,
button_pressed_timers = {},
button_press_duration = 8,
input_cooldowns = { left = 0, down = 0, up = 0, right = 0 },
input_cooldown_duration = 10,
frame_counter = 0,
current_song = nil,
pattern_index = 1,
use_pattern = false,
return_window = nil
}
end
function Minigames.get_default_button_mash()
return {
bar_fill = 0,
max_fill = 100,
fill_per_press = 8,
base_degradation = 0.15,
degradation_multiplier = 0.006,
button_pressed_timer = 0,
button_press_duration = 8,
return_window = nil,
bar_x = 20,
bar_y = 10,
bar_width = 200,
bar_height = 12,
button_x = 20,
button_y = 110,
button_size = 12
}
end
function Minigames.get_default_rhythm()
return {
line_position = 0,
line_speed = 0.015,
line_direction = 1,
target_center = 0.5,
target_width = 0.3,
initial_target_width = 0.3,
min_target_width = 0.08,
target_shrink_rate = 0.9,
score = 0,
max_score = 10,
button_pressed_timer = 0,
button_press_duration = 10,
return_window = nil,
bar_x = 20,
bar_y = 10,
bar_width = 200,
bar_height = 12,
button_x = 210,
button_y = 110,
button_size = 10,
press_cooldown = 0,
press_cooldown_duration = 15
}
end
function Minigames.configure_ddr(params)
return apply_params(Minigames.get_default_ddr(), params)
end
function Minigames.configure_button_mash(params)
return apply_params(Minigames.get_default_button_mash(), params)
end
function Minigames.configure_rhythm(params)
return apply_params(Minigames.get_default_rhythm(), params)
end

View File

@@ -9,7 +9,8 @@ local MinigameButtonMashWindow = {}
local MinigameRhythmWindow = {} local MinigameRhythmWindow = {}
local MinigameDDRWindow = {} local MinigameDDRWindow = {}
Util = {} Util = {}
DesitionManager = {} Minigames = {}
DecisionManager = {}
ScreenManager = {} ScreenManager = {}
MapManager = {} MapManager = {}
UI = {} UI = {}

View File

@@ -84,26 +84,26 @@ function UI.create_action_item(label, action)
} }
end end
function UI.draw_desition_selector(desitions, selected_desition_index) function UI.draw_decision_selector(decisions, selected_decision_index)
local bar_height = 16 local bar_height = 16
local bar_y = Config.screen.height - bar_height local bar_y = Config.screen.height - bar_height
rect(0, bar_y, Config.screen.width, bar_height, Config.colors.dark_grey) rect(0, bar_y, Config.screen.width, bar_height, Config.colors.dark_grey)
if #desitions > 0 then if #decisions > 0 then
local selected_desition = desitions[selected_desition_index] local selected_decision = decisions[selected_decision_index]
local desition_label = selected_desition.label local decision_label = selected_decision.label
local text_width = #desition_label * 4 local text_y = bar_y + 4 local text_width = #decision_label * 4 local text_y = bar_y + 4
local text_x = (Config.screen.width - text_width) / 2 local text_x = (Config.screen.width - text_width) / 2
Print.text("<", 2, text_y, Config.colors.green) Print.text("<", 2, text_y, Config.colors.green)
Print.text(desition_label, text_x, text_y, Config.colors.item) Print.text(">", Config.screen.width - 6, text_y, Config.colors.green) end Print.text(decision_label, text_x, text_y, Config.colors.item) Print.text(">", Config.screen.width - 6, text_y, Config.colors.green) end
end end
function UI.update_desition_selector(desitions, selected_desition_index) function UI.update_decision_selector(decisions, selected_decision_index)
if Input.left() then if Input.left() then
Audio.sfx_beep() Audio.sfx_beep()
selected_desition_index = Util.safeindex(desitions, selected_desition_index - 1) selected_decision_index = Util.safeindex(decisions, selected_decision_index - 1)
elseif Input.right() then elseif Input.right() then
Audio.sfx_beep() Audio.sfx_beep()
selected_desition_index = Util.safeindex(desitions, selected_desition_index + 1) selected_decision_index = Util.safeindex(decisions, selected_decision_index + 1)
end end
return selected_desition_index return selected_decision_index
end end

View File

@@ -8,7 +8,7 @@ function Util.go_to_screen_by_id(screen_id)
local screen_index = Context.screen_indices_by_id[screen_id] local screen_index = Context.screen_indices_by_id[screen_id]
if screen_index then if screen_index then
Context.current_screen = screen_index Context.current_screen = screen_index
Context.selected_desition_index = 1 else Context.selected_decision_index = 1 else
PopupWindow.show({"Error: Screen '" .. screen_id .. "' not found or not indexed!"}) PopupWindow.show({"Error: Screen '" .. screen_id .. "' not found or not indexed!"})
end end
end end

View File

@@ -10,7 +10,7 @@ function AudioTestWindow.generate_menuitems(list_func, index_func)
return { return {
{ {
label = "Play music/sound: " .. (list_func[index_func] or "?"), label = "Play music/sound: " .. (list_func[index_func] or "?"),
desition = function() decision = function()
local current_func = Audio[list_func[index_func]] local current_func = Audio[list_func[index_func]]
if current_func then if current_func then
current_func() current_func()
@@ -21,13 +21,13 @@ function AudioTestWindow.generate_menuitems(list_func, index_func)
}, },
{ {
label = "Stop playing music", label = "Stop playing music",
desition = function() decision = function()
Audio.music_stop() Audio.music_stop()
end end
}, },
{ {
label = "Back", label = "Back",
desition = function() decision = function()
AudioTestWindow.back() AudioTestWindow.back()
end end
}, },
@@ -90,7 +90,7 @@ function AudioTestWindow.update()
AudioTestWindow.list_func, AudioTestWindow.index_func AudioTestWindow.list_func, AudioTestWindow.index_func
) )
elseif Input.menu_confirm() then elseif Input.menu_confirm() then
AudioTestWindow.menuitems[AudioTestWindow.index_menu].desition() AudioTestWindow.menuitems[AudioTestWindow.index_menu].decision()
elseif Input.menu_back() then elseif Input.menu_back() then
AudioTestWindow.back() AudioTestWindow.back()
end end

View File

@@ -5,11 +5,11 @@ ConfigurationWindow = {
function ConfigurationWindow.init() function ConfigurationWindow.init()
ConfigurationWindow.controls = { ConfigurationWindow.controls = {
UI.create_desition_item( UI.create_decision_item(
"Save", "Save",
function() Config.save() end function() Config.save() end
), ),
UI.create_desition_item( UI.create_decision_item(
"Restore Defaults", "Restore Defaults",
function() Config.restore_defaults() end function() Config.restore_defaults() end
), ),
@@ -40,7 +40,7 @@ function ConfigurationWindow.draw()
Print.text(label_text, x_start, current_y, color) Print.text(label_text, x_start, current_y, color)
Print.text(value_text, value_x, current_y, color) Print.text(value_text, value_x, current_y, color)
end end
elseif control.type == "desition_item" then elseif control.type == "decision_item" then
local label_text = control.label local label_text = control.label
if i == ConfigurationWindow.selected_control then if i == ConfigurationWindow.selected_control then
color = Config.colors.item color = Config.colors.item
@@ -82,9 +82,9 @@ function ConfigurationWindow.update()
elseif btnp(3) then local new_value = math.min(control.max, current_value + control.step) elseif btnp(3) then local new_value = math.min(control.max, current_value + control.step)
control.set(new_value) control.set(new_value)
end end
elseif control.type == "desition_item" then elseif control.type == "decision_item" then
if Input.menu_confirm() then if Input.menu_confirm() then
control.desition() control.decision()
end end
end end
end end

View File

@@ -3,15 +3,15 @@ function GameWindow.draw()
MapManager.draw(screen.background) MapManager.draw(screen.background)
UI.draw_top_bar(screen.name) UI.draw_top_bar(screen.name)
if screen and screen.decisions and #screen.decisions > 0 then if screen and screen.decisions and #screen.decisions > 0 then
local available_desitions = {} local available_decisions = {}
for _, desition_id in ipairs(screen.decisions) do for _, decision_id in ipairs(screen.decisions) do
local desition = DesitionManager.get(desition_id) local decision = DecisionManager.get(decision_id)
if desition and desition.condition() then if decision and decision.condition() then
table.insert(available_desitions, desition) table.insert(available_decisions, decision)
end end
end end
if #available_desitions > 0 then if #available_decisions > 0 then
UI.draw_desition_selector(available_desitions, Context.selected_desition_index) UI.draw_decision_selector(available_decisions, Context.selected_decision_index)
end end
end end
end end
@@ -28,36 +28,36 @@ function GameWindow.update()
if Context.current_screen < 1 then if Context.current_screen < 1 then
Context.current_screen = #Context.screens Context.current_screen = #Context.screens
end end
Context.selected_desition_index = 1 elseif Input.down() then Context.selected_decision_index = 1 elseif Input.down() then
Context.current_screen = Context.current_screen + 1 Context.current_screen = Context.current_screen + 1
if Context.current_screen > #Context.screens then if Context.current_screen > #Context.screens then
Context.current_screen = 1 Context.current_screen = 1
end end
Context.selected_desition_index = 1 end Context.selected_decision_index = 1 end
local screen = Context.screens[Context.current_screen] local screen = Context.screens[Context.current_screen]
if screen and screen.decisions and #screen.decisions > 0 then if screen and screen.decisions and #screen.decisions > 0 then
local available_desitions = {} local available_decisions = {}
for _, desition_id in ipairs(screen.decisions) do for _, decision_id in ipairs(screen.decisions) do
local desition = DesitionManager.get(desition_id) local decision = DecisionManager.get(decision_id)
if desition and desition.condition() then table.insert(available_desitions, desition) if decision and decision.condition() then table.insert(available_decisions, decision)
end end
end end
if #available_desitions == 0 then return end if #available_decisions == 0 then return end
local new_selected_desition_index = UI.update_desition_selector( local new_selected_decision_index = UI.update_decision_selector(
available_desitions, available_decisions,
Context.selected_desition_index Context.selected_decision_index
) )
if new_selected_desition_index ~= Context.selected_desition_index then if new_selected_decision_index ~= Context.selected_decision_index then
Context.selected_desition_index = new_selected_desition_index Context.selected_decision_index = new_selected_decision_index
end end
if Input.select() then if Input.select() then
local selected_desition = available_desitions[Context.selected_desition_index] local selected_decision = available_decisions[Context.selected_decision_index]
if selected_desition and selected_desition.handle then Audio.sfx_select() selected_desition.handle() if selected_decision and selected_decision.handle then Audio.sfx_select() selected_decision.handle()
end end
end end
end end

View File

@@ -8,9 +8,9 @@ function MenuWindow.update()
if Input.menu_confirm() then if Input.menu_confirm() then
local selected_item = Context.menu_items[Context.selected_menu_item] local selected_item = Context.menu_items[Context.selected_menu_item]
if selected_item and selected_item.desition then if selected_item and selected_item.decision then
Audio.sfx_select() Audio.sfx_select()
selected_item.desition() selected_item.decision()
end end
end end
end end
@@ -47,14 +47,14 @@ end
function MenuWindow.refresh_menu_items() function MenuWindow.refresh_menu_items()
Context.menu_items = {} Context.menu_items = {}
if Context.game_in_progress then if Context.game_in_progress then
table.insert(Context.menu_items, {label = "Resume Game", desition = MenuWindow.resume_game}) table.insert(Context.menu_items, {label = "Resume Game", decision = MenuWindow.resume_game})
table.insert(Context.menu_items, {label = "Save Game", desition = MenuWindow.save_game}) table.insert(Context.menu_items, {label = "Save Game", decision = MenuWindow.save_game})
end end
table.insert(Context.menu_items, {label = "New Game", desition = MenuWindow.new_game}) table.insert(Context.menu_items, {label = "New Game", decision = MenuWindow.new_game})
table.insert(Context.menu_items, {label = "Load Game", desition = MenuWindow.load_game}) table.insert(Context.menu_items, {label = "Load Game", decision = MenuWindow.load_game})
table.insert(Context.menu_items, {label = "Configuration", desition = MenuWindow.configuration}) table.insert(Context.menu_items, {label = "Configuration", decision = MenuWindow.configuration})
table.insert(Context.menu_items, {label = "Audio Test", desition = MenuWindow.audio_test}) table.insert(Context.menu_items, {label = "Audio Test", decision = MenuWindow.audio_test})
table.insert(Context.menu_items, {label = "Exit", desition = MenuWindow.exit}) table.insert(Context.menu_items, {label = "Exit", decision = MenuWindow.exit})
Context.selected_menu_item = 1 end Context.selected_menu_item = 1 end

View File

@@ -1,56 +1,9 @@
function MinigameDDRWindow.init() function MinigameDDRWindow.init(params)
-- Calculate evenly spaced arrow positions Context.minigame_ddr = Minigames.configure_ddr(params)
local arrow_size = 12
local arrow_spacing = 30
local total_width = (4 * arrow_size) + (3 * arrow_spacing)
local start_x = (Config.screen.width - total_width) / 2
Context.minigame_ddr = {
-- Progress bar (matching button mash style)
bar_fill = 0, -- 0 to 100
max_fill = 100,
fill_per_hit = 10, -- Points gained per perfect hit
miss_penalty = 5, -- Points lost per miss
bar_x = 20,
bar_y = 10,
bar_width = 200,
bar_height = 12,
-- Arrow settings
arrow_size = arrow_size,
arrow_spawn_timer = 0,
arrow_spawn_interval = 45, -- Frames between arrow spawns (for random mode)
arrow_fall_speed = 1.5, -- Pixels per frame
arrows = {}, -- Active falling arrows {dir, x, y}
-- Target arrows at bottom (evenly spaced, centered on screen)
target_y = 115, -- Y position of target arrows
target_arrows = {
{dir = "left", x = start_x},
{dir = "down", x = start_x + arrow_size + arrow_spacing},
{dir = "up", x = start_x + (arrow_size + arrow_spacing) * 2},
{dir = "right", x = start_x + (arrow_size + arrow_spacing) * 3}
},
-- Hit detection
hit_threshold = 8, -- Pixels of tolerance for perfect hit
button_pressed_timers = {}, -- Visual feedback per arrow
button_press_duration = 8,
-- Input cooldown per direction
input_cooldowns = {
left = 0,
down = 0,
up = 0,
right = 0
},
input_cooldown_duration = 10,
-- Song/Pattern system
frame_counter = 0, -- Tracks frames since start
current_song = nil, -- Current song data
pattern_index = 1, -- Current position in pattern
use_pattern = false, -- If true, use song pattern; if false, use random spawning
return_window = WINDOW_GAME
}
end end
function MinigameDDRWindow.start(return_window, song_key) function MinigameDDRWindow.start(return_window, song_key, params)
MinigameDDRWindow.init() MinigameDDRWindow.init(params)
Context.minigame_ddr.return_window = return_window or WINDOW_GAME Context.minigame_ddr.return_window = return_window or WINDOW_GAME
-- Debug: Store song_key for display -- Debug: Store song_key for display
Context.minigame_ddr.debug_song_key = song_key Context.minigame_ddr.debug_song_key = song_key
@@ -273,7 +226,7 @@ function MinigameDDRWindow.draw()
if mg.bar_fill > 66 then if mg.bar_fill > 66 then
bar_color = Config.colors.item -- yellow bar_color = Config.colors.item -- yellow
elseif mg.bar_fill > 33 then elseif mg.bar_fill > 33 then
bar_color = Config.colors.bar bar_color = Config.colors.blue
end end
rect(mg.bar_x, mg.bar_y, fill_width, mg.bar_height, bar_color) rect(mg.bar_x, mg.bar_y, fill_width, mg.bar_height, bar_color)
end end
@@ -291,7 +244,7 @@ function MinigameDDRWindow.draw()
-- Draw falling arrows (blue) -- Draw falling arrows (blue)
if mg.arrows then if mg.arrows then
for _, arrow in ipairs(mg.arrows) do for _, arrow in ipairs(mg.arrows) do
draw_arrow(arrow.x, arrow.y, arrow.dir, Config.colors.bar) -- blue color draw_arrow(arrow.x, arrow.y, arrow.dir, Config.colors.blue) -- blue color
end end
end end
-- Draw instruction text -- Draw instruction text
@@ -318,6 +271,6 @@ function MinigameDDRWindow.draw()
) )
end end
else else
Print.text_center("RANDOM MODE", Config.screen.width / 2, debug_y, Config.colors.bar) Print.text_center("RANDOM MODE", Config.screen.width / 2, debug_y, Config.colors.blue)
end end
end end

View File

@@ -1,25 +1,9 @@
function MinigameButtonMashWindow.init() function MinigameButtonMashWindow.init(params)
Context.minigame_button_mash = { Context.minigame_button_mash = Minigames.configure_button_mash(params)
bar_fill = 0, -- 0 to 100
max_fill = 100,
fill_per_press = 8,
base_degradation = 0.15, -- Base degradation per frame
degradation_multiplier = 0.006, -- Increases with bar fill
button_pressed_timer = 0, -- Visual feedback timer
button_press_duration = 8, -- Frames to show button press
return_window = WINDOW_GAME, -- Window to return to after completion
bar_x = 20,
bar_y = 10,
bar_width = 200,
bar_height = 12,
button_x = 20,
button_y = 110,
button_size = 12
}
end end
function MinigameButtonMashWindow.start(return_window) function MinigameButtonMashWindow.start(return_window, params)
MinigameButtonMashWindow.init() MinigameButtonMashWindow.init(params)
Context.minigame_button_mash.return_window = return_window or WINDOW_GAME Context.minigame_button_mash.return_window = return_window or WINDOW_GAME
Context.active_window = WINDOW_MINIGAME_BUTTON_MASH Context.active_window = WINDOW_MINIGAME_BUTTON_MASH
end end
@@ -73,7 +57,7 @@ function MinigameButtonMashWindow.draw()
if mg.bar_fill > 66 then if mg.bar_fill > 66 then
bar_color = Config.colors.item -- yellow bar_color = Config.colors.item -- yellow
elseif mg.bar_fill > 33 then elseif mg.bar_fill > 33 then
bar_color = Config.colors.bar -- medium color bar_color = Config.colors.blue
end end
rect(mg.bar_x, mg.bar_y, fill_width, bar_color) rect(mg.bar_x, mg.bar_y, fill_width, bar_color)
end end

View File

@@ -1,35 +1,9 @@
function MinigameRhythmWindow.init() function MinigameRhythmWindow.init(params)
Context.minigame_rhythm = { Context.minigame_rhythm = Minigames.configure_rhythm(params)
line_position = 0, -- Normalized position (0 to 1)
line_speed = 0.015, -- Movement speed per frame
line_direction = 1, -- 1 for left-to-right, -1 for right-to-left
target_center = 0.5, -- Center of target area (middle of bar)
target_width = 0.3, -- Width of target area (normalized)
initial_target_width = 0.3,
min_target_width = 0.08, -- Minimum width to keep game possible
target_shrink_rate = 0.9, -- Multiplier per successful hit (0.9 = 10% shrink)
score = 0,
max_score = 10,
button_pressed_timer = 0,
button_press_duration = 10,
return_window = WINDOW_GAME,
-- Visual layout (match button mash minigame dimensions)
bar_x = 20,
bar_y = 10,
bar_width = 200,
bar_height = 12,
-- Button indicator
button_x = 210,
button_y = 110,
button_size = 10,
-- Cooldown to prevent multiple presses in one frame
press_cooldown = 0,
press_cooldown_duration = 15
}
end end
function MinigameRhythmWindow.start(return_window) function MinigameRhythmWindow.start(return_window, params)
MinigameRhythmWindow.init() MinigameRhythmWindow.init(params)
Context.minigame_rhythm.return_window = return_window or WINDOW_GAME Context.minigame_rhythm.return_window = return_window or WINDOW_GAME
Context.active_window = WINDOW_MINIGAME_RHYTHM Context.active_window = WINDOW_MINIGAME_RHYTHM
end end