time based scroll
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
2026-03-22 19:03:05 +01:00
parent 93df710d14
commit 284c5aa4c8
5 changed files with 30 additions and 14 deletions

View File

@@ -64,6 +64,7 @@ globals = {
"index_menu",
"Map",
"map",
"time",
}

View File

@@ -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",

View File

@@ -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

View File

@@ -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

View File

@@ -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