Compare commits

..

No commits in common. "a4590821be8861c786204e5f7fab5bd70586cc56" and "f3ac1f492c5cfc4f05a3d426d04a0b7ac45e0468" have entirely different histories.

View File

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