feat: added intro sequence, fixed norman's sprite, placed him in various places
This commit is contained in:
@@ -4,12 +4,14 @@
|
||||
function MinigameButtonMashWindow.init_context()
|
||||
return {
|
||||
bar_fill = 0,
|
||||
max_fill = 100,
|
||||
target_points = 100,
|
||||
fill_per_press = 8,
|
||||
base_degradation = 0.15,
|
||||
degradation_multiplier = 0.006,
|
||||
button_pressed_timer = 0,
|
||||
button_press_duration = 8,
|
||||
instruction_text = "MASH Z!",
|
||||
show_progress_text = true,
|
||||
return_window = nil,
|
||||
bar_x = 20,
|
||||
bar_y = 10,
|
||||
@@ -35,6 +37,9 @@ function MinigameButtonMashWindow.init(params)
|
||||
for k, v in pairs(params) do
|
||||
defaults[k] = v
|
||||
end
|
||||
if params.max_fill and not params.target_points then
|
||||
defaults.target_points = params.max_fill
|
||||
end
|
||||
end
|
||||
Context.minigame_button_mash = defaults
|
||||
end
|
||||
@@ -78,11 +83,11 @@ function MinigameButtonMashWindow.update()
|
||||
if Input.select() then
|
||||
mg.bar_fill = mg.bar_fill + mg.fill_per_press
|
||||
mg.button_pressed_timer = mg.button_press_duration
|
||||
if mg.bar_fill > mg.max_fill then
|
||||
mg.bar_fill = mg.max_fill
|
||||
if mg.bar_fill > mg.target_points then
|
||||
mg.bar_fill = mg.target_points
|
||||
end
|
||||
end
|
||||
if mg.bar_fill >= mg.max_fill then
|
||||
if mg.bar_fill >= mg.target_points then
|
||||
mg.win_timer = Config.timing.minigame_win_duration
|
||||
return
|
||||
end
|
||||
@@ -95,7 +100,7 @@ function MinigameButtonMashWindow.update()
|
||||
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)
|
||||
Focus.set_percentage(mg.bar_fill / mg.target_points)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -104,14 +109,16 @@ end
|
||||
function MinigameButtonMashWindow.draw()
|
||||
local mg = Context.minigame_button_mash
|
||||
if mg.return_window == "game" then
|
||||
GameWindow.draw()
|
||||
GameWindow.draw_with_underlay(function()
|
||||
Sprite.draw_at("sleeping_norman", (Config.screen.width / 2) - 30, (Config.screen.height / 2) - 22)
|
||||
end)
|
||||
end
|
||||
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
|
||||
local fill_width = (mg.bar_fill / mg.target_points) * mg.bar_width
|
||||
if fill_width > 0 then
|
||||
local bar_color = Config.colors.light_blue
|
||||
if mg.bar_fill > 66 then
|
||||
@@ -130,9 +137,11 @@ function MinigameButtonMashWindow.draw()
|
||||
circ(mg.button_x, mg.button_y, mg.button_size - 2, button_color)
|
||||
end
|
||||
Print.text_center("Z", mg.button_x, mg.button_y - 3, button_color)
|
||||
Print.text_center("MASH Z!", Config.screen.width / 2, mg.bar_y + mg.bar_height + 10, Config.colors.light_grey)
|
||||
local percentage = math.floor((mg.bar_fill / mg.max_fill) * 100)
|
||||
Print.text_center(percentage .. "%", mg.bar_x + mg.bar_width / 2, mg.bar_y + 2, Config.colors.black)
|
||||
Print.text_center(mg.instruction_text, Config.screen.width / 2, mg.bar_y + mg.bar_height + 10, Config.colors.light_grey)
|
||||
if mg.show_progress_text then
|
||||
local points_text = math.floor(mg.bar_fill) .. "/" .. mg.target_points
|
||||
Print.text_center(points_text, mg.bar_x + mg.bar_width / 2, mg.bar_y + 2, Config.colors.black)
|
||||
end
|
||||
|
||||
if mg.win_timer > 0 then
|
||||
Minigame.draw_win_overlay()
|
||||
|
||||
Reference in New Issue
Block a user