From 6055b74ccf3fd28d153e58890d9d0d661fd40d87 Mon Sep 17 00:00:00 2001 From: Zsolt Tasnadi Date: Thu, 7 May 2026 21:46:46 +0200 Subject: [PATCH] timedeltafix --- inc/logic/logic.ascension.lua | 4 ++-- inc/logic/logic.focus.lua | 4 ++-- inc/logic/logic.glitch.lua | 2 +- inc/logic/logic.meter.lua | 2 +- inc/logic/logic.timer.lua | 2 +- inc/logic/logic.trigger.lua | 2 +- inc/screen/screen.mysterious_man.lua | 2 +- inc/system/system.main.lua | 1 + inc/window/window.discussion.lua | 6 +++--- inc/window/window.intro.brief.lua | 2 +- inc/window/window.minigame.ddr.lua | 15 ++++++++------- inc/window/window.minigame.mash.lua | 9 +++++---- inc/window/window.minigame.rhythm.lua | 13 +++++++------ 13 files changed, 34 insertions(+), 30 deletions(-) diff --git a/inc/logic/logic.ascension.lua b/inc/logic/logic.ascension.lua index 4e9fac1..74c8b04 100644 --- a/inc/logic/logic.ascension.lua +++ b/inc/logic/logic.ascension.lua @@ -135,7 +135,7 @@ end --- @within Ascension function Ascension.draw_flash() if not _flash_active then return end - _flash_timer = _flash_timer + 1 + _flash_timer = _flash_timer + Context.dt60 local sw = Config.screen.width local sh = Config.screen.height @@ -160,7 +160,7 @@ end --- @within Ascension function Ascension.update_fade() if not _fade_active then return end - _fade_timer = _fade_timer + 1 + _fade_timer = _fade_timer + Context.dt60 if _fade_timer >= FADE_DURATION then _fade_active = false end diff --git a/inc/logic/logic.focus.lua b/inc/logic/logic.focus.lua index d37d00f..3273bc7 100644 --- a/inc/logic/logic.focus.lua +++ b/inc/logic/logic.focus.lua @@ -105,14 +105,14 @@ function Focus.update() if driven then return end if closing then - radius = radius - speed + radius = radius - speed * Context.dt60 if radius <= 0 then local cb = on_complete Focus.stop() if cb then cb() end end else - radius = radius + speed + radius = radius + speed * Context.dt60 if radius >= max_radius(center_x, center_y) then local cb = on_complete Focus.stop() diff --git a/inc/logic/logic.glitch.lua b/inc/logic/logic.glitch.lua index 500bfab..a42ddd9 100644 --- a/inc/logic/logic.glitch.lua +++ b/inc/logic/logic.glitch.lua @@ -23,7 +23,7 @@ function Glitch.draw() if not Context or not Context.glitch or not Context.glitch.enabled then return end -- Update state timer - Context.glitch.timer = Context.glitch.timer - 1 + Context.glitch.timer = Context.glitch.timer - Context.dt60 if Context.glitch.timer <= 0 then if Context.glitch.state == "active" then Context.glitch.state = "waiting" diff --git a/inc/logic/logic.meter.lua b/inc/logic/logic.meter.lua index c9b8994..181baf1 100644 --- a/inc/logic/logic.meter.lua +++ b/inc/logic/logic.meter.lua @@ -96,7 +96,7 @@ function Meter.update() local in_minigame = string.find(Window.get_current_id(), "^minigame_") ~= nil if not in_minigame then if m.combo > 0 then - m.combo_timer = m.combo_timer + 1 + m.combo_timer = m.combo_timer + Context.dt60 if m.combo_timer >= COMBO_TIMEOUT_FRAMES then m.combo = 0 m.combo_timer = 0 diff --git a/inc/logic/logic.timer.lua b/inc/logic/logic.timer.lua index 7345749..67fce2b 100644 --- a/inc/logic/logic.timer.lua +++ b/inc/logic/logic.timer.lua @@ -28,7 +28,7 @@ function Timer.update() local in_minigame = string.find(Window.get_current_id(), "^minigame_") ~= nil if not in_minigame then - t.progress = t.progress + (1 / timer_duration) + t.progress = t.progress + (Context.delta_time / (timer_duration / 60)) if t.progress >= 1 then t.progress = t.progress - 1 end diff --git a/inc/logic/logic.trigger.lua b/inc/logic/logic.trigger.lua index 7f15c8a..5b27475 100644 --- a/inc/logic/logic.trigger.lua +++ b/inc/logic/logic.trigger.lua @@ -110,7 +110,7 @@ function Trigger.update() for id, state in pairs(Context.triggers) do local trigger = triggers[id] if trigger then - state.elapsed = state.elapsed + 1 + state.elapsed = state.elapsed + Context.dt60 if state.elapsed >= trigger.duration then table.insert(fired, id) end diff --git a/inc/screen/screen.mysterious_man.lua b/inc/screen/screen.mysterious_man.lua index d60d708..5fc2cc6 100644 --- a/inc/screen/screen.mysterious_man.lua +++ b/inc/screen/screen.mysterious_man.lua @@ -177,7 +177,7 @@ end local state = STATE_TEXT local text_y = Config.screen.height -local text_speed = 12 -- pixels per second +local text_speed = 25 -- pixels per second local day_timer = 0 local day_display_seconds = 2 local text_done = false diff --git a/inc/system/system.main.lua b/inc/system/system.main.lua index 69b4f86..34f5559 100644 --- a/inc/system/system.main.lua +++ b/inc/system/system.main.lua @@ -26,6 +26,7 @@ function TIC() Context.delta_time = (now - Context.last_frame_time) / 1000 end Context.last_frame_time = now + Context.dt60 = Context.delta_time * 60 cls(Config.colors.black) local handler = Window.get_current_handler() -- Get handler from Window manager diff --git a/inc/window/window.discussion.lua b/inc/window/window.discussion.lua index e51db29..ae74f13 100644 --- a/inc/window/window.discussion.lua +++ b/inc/window/window.discussion.lua @@ -7,8 +7,8 @@ local TEXTBOX_Y = math.floor((Config.screen.height - TEXTBOX_H) / 2 - 8) local TEXTBOX_MAX_CHARS = 30 local DISCUSSION_LINE_HEIGHT = 8 local PADDING = 4 -local AUTO_SCROLL_DELAY = 12 -local AUTO_SCROLL_STEP = 1 +local AUTO_SCROLL_DELAY = 8 +local AUTO_SCROLL_STEP = 2 --- Draws the discussion window. --- @within DiscussionWindow @@ -61,7 +61,7 @@ function DiscussionWindow.update() if max_scroll > 0 then if Context.discussion.auto_scroll then - Context.discussion.scroll_timer = Context.discussion.scroll_timer + 1 + Context.discussion.scroll_timer = Context.discussion.scroll_timer + Context.dt60 if Context.discussion.scroll_timer >= AUTO_SCROLL_DELAY then Context.discussion.scroll_timer = 0 Context.discussion.scroll_y = Context.discussion.scroll_y + AUTO_SCROLL_STEP diff --git a/inc/window/window.intro.brief.lua b/inc/window/window.intro.brief.lua index 1d75389..86aee3a 100644 --- a/inc/window/window.intro.brief.lua +++ b/inc/window/window.intro.brief.lua @@ -1,6 +1,6 @@ --- @section BriefIntroWindow BriefIntroWindow.y = Config.screen.height -BriefIntroWindow.speed = 30 -- pixels per second +BriefIntroWindow.speed = 45 -- pixels per second BriefIntroWindow.text = [[ Norman Reds’ everyday life seems ordinary: work, diff --git a/inc/window/window.minigame.ddr.lua b/inc/window/window.minigame.ddr.lua index 1231206..2422ce2 100644 --- a/inc/window/window.minigame.ddr.lua +++ b/inc/window/window.minigame.ddr.lua @@ -339,8 +339,9 @@ function MinigameDDRWindow.update() local mg = Context.minigame_ddr if mg.win_timer > 0 then - mg.win_timer = mg.win_timer - 1 - if mg.win_timer == 0 then + mg.win_timer = mg.win_timer - Context.dt60 + if mg.win_timer <= 0 then + mg.win_timer = 0 Audio.music_stop() Meter.apply_ddr_reward(mg.total_misses) if not Context.game_in_progress then return end @@ -359,7 +360,7 @@ function MinigameDDRWindow.update() return end - mg.frame_counter = mg.frame_counter + 1 + mg.frame_counter = mg.frame_counter + Context.dt60 if mg.use_pattern and mg.current_song and mg.current_song.end_frame then if mg.frame_counter > mg.current_song.end_frame and #mg.arrows == 0 then @@ -381,7 +382,7 @@ function MinigameDDRWindow.update() end end else - mg.arrow_spawn_timer = mg.arrow_spawn_timer + 1 + mg.arrow_spawn_timer = mg.arrow_spawn_timer + Context.dt60 if mg.arrow_spawn_timer >= mg.arrow_spawn_interval then spawn_arrow() mg.arrow_spawn_timer = 0 @@ -391,7 +392,7 @@ function MinigameDDRWindow.update() -- move arrow downwards local arrows_to_remove = {} for i, arrow in ipairs(mg.arrows) do - arrow.y = arrow.y + mg.arrow_fall_speed + arrow.y = arrow.y + mg.arrow_fall_speed * Context.dt60 if check_miss(arrow) then table.insert(arrows_to_remove, i) mg.bar_fill = math.max(0, mg.bar_fill - mg.miss_penalty) @@ -406,13 +407,13 @@ function MinigameDDRWindow.update() for dir, _ in pairs(mg.input_cooldowns) do if mg.input_cooldowns[dir] > 0 then - mg.input_cooldowns[dir] = mg.input_cooldowns[dir] - 1 + mg.input_cooldowns[dir] = mg.input_cooldowns[dir] - Context.dt60 end end for dir, _ in pairs(mg.button_pressed_timers) do if mg.button_pressed_timers[dir] > 0 then - mg.button_pressed_timers[dir] = mg.button_pressed_timers[dir] - 1 + mg.button_pressed_timers[dir] = mg.button_pressed_timers[dir] - Context.dt60 end end diff --git a/inc/window/window.minigame.mash.lua b/inc/window/window.minigame.mash.lua index 980c881..2d4e760 100644 --- a/inc/window/window.minigame.mash.lua +++ b/inc/window/window.minigame.mash.lua @@ -103,8 +103,9 @@ function MinigameButtonMashWindow.update() local mg = Context.minigame_button_mash if mg.win_timer > 0 then - mg.win_timer = mg.win_timer - 1 - if mg.win_timer == 0 then + mg.win_timer = mg.win_timer - Context.dt60 + if mg.win_timer <= 0 then + mg.win_timer = 0 if mg.meter_on_complete then mg.meter_on_complete(mg.elapsed_sec or 0) else @@ -142,13 +143,13 @@ function MinigameButtonMashWindow.update() mg.win_timer = Config.timing.minigame_win_duration return end - local degradation = mg.base_degradation + (mg.bar_fill * mg.degradation_multiplier) + local degradation = (mg.base_degradation + (mg.bar_fill * mg.degradation_multiplier)) * Context.dt60 mg.bar_fill = mg.bar_fill - degradation if mg.bar_fill < 0 then mg.bar_fill = 0 end if mg.button_pressed_timer > 0 then - mg.button_pressed_timer = mg.button_pressed_timer - 1 + mg.button_pressed_timer = mg.button_pressed_timer - Context.dt60 end if mg.focus_center_x then Focus.set_percentage(mg.bar_fill / mg.target_points) diff --git a/inc/window/window.minigame.rhythm.lua b/inc/window/window.minigame.rhythm.lua index dd2eee6..891d92e 100644 --- a/inc/window/window.minigame.rhythm.lua +++ b/inc/window/window.minigame.rhythm.lua @@ -71,8 +71,9 @@ function MinigameRhythmWindow.update() local mg = Context.minigame_rhythm if mg.win_timer > 0 then - mg.win_timer = mg.win_timer - 1 - if mg.win_timer == 0 then + mg.win_timer = mg.win_timer - Context.dt60 + if mg.win_timer <= 0 then + mg.win_timer = 0 Meter.on_minigame_complete(false) if not Context.game_in_progress then return end if mg.focus_center_x then Focus.stop() end @@ -86,7 +87,7 @@ function MinigameRhythmWindow.update() return end - mg.line_position = mg.line_position + (mg.line_speed * mg.line_direction) + mg.line_position = mg.line_position + (mg.line_speed * mg.line_direction * Context.dt60) if mg.line_position > 1 then mg.line_position = 1 mg.line_direction = -1 @@ -95,11 +96,11 @@ function MinigameRhythmWindow.update() mg.line_direction = 1 end if mg.press_cooldown > 0 then - mg.press_cooldown = mg.press_cooldown - 1 + mg.press_cooldown = mg.press_cooldown - Context.dt60 end local mouse_on_button = Mouse.zone_circle({ x = mg.button_x, y = mg.button_y, r = mg.button_size }) - if (Input.select() or mouse_on_button) and mg.press_cooldown == 0 then + if (Input.select() or mouse_on_button) and mg.press_cooldown <= 0 then mg.button_pressed_timer = mg.button_press_duration mg.press_cooldown = mg.press_cooldown_duration local target_left = mg.target_center - (mg.target_width / 2) @@ -123,7 +124,7 @@ function MinigameRhythmWindow.update() return end if mg.button_pressed_timer > 0 then - mg.button_pressed_timer = mg.button_pressed_timer - 1 + mg.button_pressed_timer = mg.button_pressed_timer - Context.dt60 end if mg.focus_center_x then Focus.set_percentage(1 - mg.score / mg.max_score)