Compare commits

..

2 Commits

Author SHA1 Message Date
a4590821be
pre-initialize palettes for blip. costs tokens, saves time 2023-09-30 19:45:07 -07:00
cf1e1153a3
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
2023-09-30 19:30:21 -07:00

View File

@ -118,6 +118,7 @@ function linked_list:pop_front()
end
function _init()
init_blip_pals()
wipe_level()
primary_ship.main_gun = zap_gun.new()
load_level(example_level)
@ -426,15 +427,13 @@ ship_m = {
shield = 0,
maxshield = 0,
shieldcost = 32767.9,
shieldcooldown = 180,
shieldcooldown = 0x0.00a0,
-- default generator behavior:
-- 10 seconds for a full charge
max_power = 600,
power = 600,
generator = 1, -- power gen per frame
invincible_until = -32768,
slip = true, -- most enemies slide
@ -517,7 +516,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 +862,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 +886,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 +1006,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 +1053,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 +1174,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 +1231,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 +1264,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 +1322,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 +1571,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.
@ -1754,10 +1753,19 @@ end
mknew(blip_fx)
blip_pals = {}
function init_blip_pals()
for i=0,15 do
local pp = {[0]=0}
for j=1,15 do
pp[j] = i
end
blip_pals[i]=pp
end
end
function blip(obj, col, frames)
local p = {[0]=0}
obj.fx_pal = p
for i=1,15 do p[i]=col end
obj.fx_pal = blip_pals[col]
if (obj.___fx_pal_event) obj.___fx_pal_event:abort()
events:push_back(blip_fx.new{frames=frames, obj=obj})
end
@ -1842,7 +1850,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)],