Mark
/
celeste-ai
Archived
1
0
Fork 0

Improved delays

master
Mark 2023-02-18 18:46:01 -08:00
parent e76a78d199
commit 137f8cefc1
Signed by: Mark
GPG Key ID: AD62BB059C2AAEE4
1 changed files with 55 additions and 66 deletions

View File

@ -30,10 +30,11 @@ k_jump=4
k_dash=5
-- If true, disable screensake
hack_no_shake = true
-- False until the game has initialized
hack_ready = false
hack_no_shake = true
-- Slow down frame rate
hack_frame_counter = 0
@ -277,7 +278,7 @@ player =
has_dashed=true
-- HACK: fast-forward dashes
hack_frame_foward_bonus = 8
hack_frame_foward_bonus = 10
hack_can_dash = false
this.dash_effect_time=10
@ -1209,7 +1210,7 @@ end
-- default for celeste is 30.
function _update()
-- Skip a few frames at start to initialize
-- Run at full speed until ready
if not hack_ready then
old_update()
old_draw()
@ -1221,20 +1222,14 @@ function _update()
-- Do nothing for a few frames.
-- This gives us time to run computations
if hack_frame_counter < hack_frame_freeze then
-- Freeze frames
hack_frame_counter+=1
return
elseif hack_frame_counter < (hack_frame_foward + hack_frame_freeze + hack_frame_foward_bonus) then
-- Forward frames
hack_frame_counter+=1
old_update()
old_draw()
extcmd("screen")
else
end
-- Wait for input
if (not (
btn(k_left) or
@ -1250,13 +1245,28 @@ function _update()
end
hack_frame_counter = 0
hack_frame_foward_bonus = 0
-- Delay for input to stabilize
-- Required to reliably send multiple key presses
wait(5)
-- Run a few frames
for i=1,hack_frame_foward do
old_update()
old_draw()
extcmd("screen")
end
-- Run bonus frames if we earned bonus frames
for i=1,hack_frame_foward_bonus do
old_update()
old_draw()
extcmd("screen")
end
-- Reset counters
hack_frame_counter = 0
hack_frame_foward_bonus = 0
hack_has_sent_first_message = true
out_string = "dc:" .. tostr(deaths) .. ";"
@ -1272,32 +1282,11 @@ function _update()
end
printh(out_string)
end
end
-- Called at the same rate as _update
-- Called at the same rate as _update,
-- but not necessarily at the same time.
function _draw()
--old_draw()
--[[
if not (
btn(k_left) or
btn(k_right) or
btn(k_up) or
btn(k_down) or
btn(k_jump) or
btn(k_dash)
) and hack_run_delay then
return
end
if draw_frame_counter < frame_rate_hack and hack_run_delay then
draw_frame_counter += 1
else
draw_frame_counter = 0
old_draw()
end
--]]
end
function old_update()