lframe increment is now 0x0.0001

avoids time rollover! not doing this for `distance` because I don't intend any level script to exceed five minutes, but freeze time could be much longer
This commit is contained in:
Kistaro Windrider 2023-09-30 19:30:21 -07:00
parent f3ac1f492c
commit cf1e1153a3
Signed by: kistaro
SSH Key Fingerprint: SHA256:TBE2ynfmJqsAf0CP6gsflA0q5X5wD5fVKWPsZ7eVUg8

View File

@ -426,7 +426,7 @@ ship_m = {
shield = 0,
maxshield = 0,
shieldcost = 32767.9,
shieldcooldown = 180,
shieldcooldown = 0x0.00a0,
-- default generator behavior:
-- 10 seconds for a full charge
@ -434,8 +434,6 @@ ship_m = {
power = 600,
generator = 1, -- power gen per frame
invincible_until = -32768,
slip = true, -- most enemies slide
xmomentum = 0,
@ -517,7 +515,6 @@ end
function ship_m:hitsomething(dmg)
if (dmg <= 0) return false
if (lframe < self.invincible_until) return false
self.shield_refresh_ready = lframe + self.shieldcooldown
if self.shield >= dmg then
self.shield -= dmg
@ -864,7 +861,7 @@ end
-- effective frame
distance = 0
-- actual frame count since
-- start of level
-- start of level times 0x0.0001
lframe = 0
-- do not advance distance when
@ -888,7 +885,7 @@ function load_level(lvltbl)
end
function level_frame()
lframe += 1
lframe += 0x0.0001
if (current_level == nil) return true
if freeze == 0 then
distance += 1
@ -1008,11 +1005,11 @@ function spawn_blocking_boss_chasey()
chasey.die(self)
end
local nextspawn = lframe + 120
local nextspawn = lframe + 0x0.0080
events:push_back{move=function()
if lframe >= nextspawn then
helpers[flr(rnd(#helpers))+1]()
nextspawn += 60
nextspawn += 0x0.0040
end
return c.dead
end}
@ -1055,7 +1052,7 @@ example_level = {
events:push_back{move=function()
if (lframe < tnext) return false
spawn_blocking_blocky()
tnext = lframe + 12
tnext = lframe + 0x0.000c
remain -= 1
return (remain <= 0)
end}
@ -1176,7 +1173,7 @@ mknew(zap)
zap_gun = gun_base.new{
enemy = false,
power = 20, -- power consumed per shot
cooldown = 10, -- frames between shots
cooldown = 0x0.000a, -- frames between shots
ammo = nil, -- unlimited ammo - main gun
t = zap -- metatable of bullet to fire
}
@ -1233,7 +1230,7 @@ blast_gun = gun_base.new{
icon = 13,
enemy = false,
power = 0, -- ammo, not power
cooldown = 30, -- frames between shots
cooldown = 0x0.0020, -- frames between shots
ammo = 5,
maxammo = 5,
t = blast -- type of bullet to fire
@ -1266,7 +1263,7 @@ protron_gun = gun_base.new{
icon = 25,
enemy = false,
power = 35,
cooldown = 15, -- frames between shots
cooldown = 0x0.000f, -- frames between shots
ammo = nil,
maxammo = nil,
actually_shoot = function(self, x, y)
@ -1324,7 +1321,7 @@ vulcan_gun = gun_base.new{
icon = 37,
enemy = false,
power = 8,
cooldown = 2, -- frames between shots
cooldown = 0x0.0002, -- frames between shots
ammo = nil,
maxammo = nil,
dxs = {0.35, -0.35, -0.7, 0.7, 0.35, -0.35},
@ -1573,21 +1570,22 @@ it sets lframe ("level frame")
and distance to 0.
every frame, level_frame
increments lframe. then if the
level is not frozen (more on
that later), it increments
distance and runs the function
in the level table for exactly
that frame number (if any).
distance is therefore "nonfrozen
frames", and is used to trigger
level progress. lframe always
increments lframe by 0x0.0001.
then if the level is not frozen,
it increments distance by 1.0
and runs the function in the
level table for exactly that
frame number (if any). distance
is therefore "nonfrozen frames",
and is used to trigger level
progress. lframe always
increments. ships are encouraged
to use lframe to control
animation and movement, and may
use distance to react to level
progress separately from overall
time.
time. remember to multiply
lframe-related stuff by 0x0001.
a special sentinel value, eol,
marks the end of the level.
@ -1842,7 +1840,7 @@ sheen8x8 = split"2,54,55,56,57,58,59,60,61"
function powerup:draw()
spr(self.sprites[max(1,
(lframe\self.anim_speed)
((lframe<<16)\self.anim_speed)
%(#self.sprites+self.loop_pause)
-self.loop_pause
+1)],