From 284c5aa4c86af0fb4b4a7eda03dd4b69d39b0817 Mon Sep 17 00:00:00 2001 From: Zsolt Tasnadi Date: Sun, 22 Mar 2026 19:03:05 +0100 Subject: [PATCH] time based scroll --- .luacheckrc | 1 + inc/init/init.context.lua | 2 ++ inc/screen/screen.mysterious_man.lua | 28 ++++++++++++++++------------ inc/system/system.main.lua | 9 +++++++++ inc/window/window.intro.brief.lua | 4 ++-- 5 files changed, 30 insertions(+), 14 deletions(-) diff --git a/.luacheckrc b/.luacheckrc index cbaa89f..e72da7c 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -64,6 +64,7 @@ globals = { "index_menu", "Map", "map", + "time", } diff --git a/inc/init/init.context.lua b/inc/init/init.context.lua index 4623d23..a3d9100 100644 --- a/inc/init/init.context.lua +++ b/inc/init/init.context.lua @@ -51,6 +51,8 @@ function Context.initial_data() current_situation = nil, }, day_count = 1, + delta_time = 0, + last_frame_time = 0, glitch = { enabled = false, state = "active", diff --git a/inc/screen/screen.mysterious_man.lua b/inc/screen/screen.mysterious_man.lua index 4b08fc1..413e406 100644 --- a/inc/screen/screen.mysterious_man.lua +++ b/inc/screen/screen.mysterious_man.lua @@ -68,12 +68,12 @@ end local state = STATE_TEXT local text_y = Config.screen.height -local text_speed = 0.2 +local text_speed = 12 -- pixels per second local day_timer = 0 -local day_display_frames = 120 +local day_display_seconds = 2 local text_done = false local text_done_timer = 0 -local TEXT_DONE_HOLD_FRAMES = 120 +local TEXT_DONE_HOLD_SECONDS = 2 local selected_choice = 1 local text = ASC_01_TEXT local day_text_override = nil @@ -118,7 +118,7 @@ local function go_to_day_state() return end state = STATE_DAY - day_timer = day_display_frames + day_timer = day_display_seconds end local function wake_up() @@ -146,7 +146,7 @@ end local function stay_in_bed() Day.increase() state = STATE_DAY - day_timer = day_display_frames + day_timer = day_display_seconds end --- Starts the mysterious man screen. @@ -171,7 +171,7 @@ function MysteriousManScreen.start(options) if options.skip_text then show_mysterious_screen = false state = STATE_DAY - day_timer = day_display_frames + day_timer = day_display_seconds else show_mysterious_screen = true state = STATE_TEXT @@ -194,25 +194,29 @@ Screen.register({ update = function() if state == STATE_TEXT then if not text_done then - text_y = text_y - text_speed + text_y = text_y - (text_speed * Context.delta_time) local lines = 1 for _ in string.gmatch(text, "\n") do lines = lines + 1 end - if text_y < -lines * 8 then + if text_y < -lines * 8 or Input.select() then text_done = true - text_done_timer = TEXT_DONE_HOLD_FRAMES + text_done_timer = TEXT_DONE_HOLD_SECONDS + -- If skipped by user, go to day state immediately + if Input.select() then + go_to_day_state() + end end else - text_done_timer = text_done_timer - 1 - if text_done_timer <= 0 then + text_done_timer = text_done_timer - Context.delta_time + if text_done_timer <= 0 or Input.select() then go_to_day_state() end end elseif state == STATE_DAY then - day_timer = day_timer - 1 + day_timer = day_timer - Context.delta_time if day_timer <= 0 or Input.select() then if trigger_flash_on_wake or Ascension.get_level() < 1 then diff --git a/inc/system/system.main.lua b/inc/system/system.main.lua index 5b39be2..888ef84 100644 --- a/inc/system/system.main.lua +++ b/inc/system/system.main.lua @@ -17,6 +17,15 @@ end --- @within Main function TIC() init_game() + + local now = time() + if Context.last_frame_time == 0 then + Context.delta_time = 0 + else + Context.delta_time = (now - Context.last_frame_time) / 1000 + end + Context.last_frame_time = now + cls(Config.colors.black) local handler = Window.get_current_handler() -- Get handler from Window manager if handler then diff --git a/inc/window/window.intro.brief.lua b/inc/window/window.intro.brief.lua index f1863a1..11a0f8e 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 = 0.5 +BriefIntroWindow.speed = 30 -- pixels per second BriefIntroWindow.text = [[ Norman Reds’ everyday life seems ordinary: work, @@ -24,7 +24,7 @@ end --- Updates the brief intro window logic. --- @within BriefIntroWindow function BriefIntroWindow.update() - BriefIntroWindow.y = BriefIntroWindow.y - BriefIntroWindow.speed + BriefIntroWindow.y = BriefIntroWindow.y - (BriefIntroWindow.speed * Context.delta_time) local lines = 1 for _ in string.gmatch(BriefIntroWindow.text, "\n") do