Compare commits
16 Commits
d13290f438
...
flotillas
Author | SHA1 | Date | |
---|---|---|---|
3151db5430
|
|||
2964159858
|
|||
95d4b6eb37
|
|||
96312e3adf
|
|||
bf9a45d87e
|
|||
36f7c6572f
|
|||
45b70d3aca
|
|||
35980d801a
|
|||
734811bd62
|
|||
4fddbea82c
|
|||
f675e31967
|
|||
0bd1463416
|
|||
267f8a3667
|
|||
fa206c37c5
|
|||
928e7f7418
|
|||
2439fda068
|
520
vacuum_gambit.p8
520
vacuum_gambit.p8
@ -127,7 +127,6 @@ function _init()
|
|||||||
mode = game_mode
|
mode = game_mode
|
||||||
init_blip_pals()
|
init_blip_pals()
|
||||||
wipe_game() -- redundant?
|
wipe_game() -- redundant?
|
||||||
load_level(example_level_csv)
|
|
||||||
game_state = game
|
game_state = game
|
||||||
pal(2,129)
|
pal(2,129)
|
||||||
pal()
|
pal()
|
||||||
@ -171,6 +170,10 @@ function wipe_game()
|
|||||||
new_events = linked_list.new()
|
new_events = linked_list.new()
|
||||||
primary_ship.main_gun = zap_gun_p.new()
|
primary_ship.main_gun = zap_gun_p.new()
|
||||||
primary_ship.main_gun:peel()
|
primary_ship.main_gun:peel()
|
||||||
|
gframe = 0
|
||||||
|
interlude = 0
|
||||||
|
waves_complete = 0
|
||||||
|
current_wave = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
function _update60()
|
function _update60()
|
||||||
@ -185,12 +188,44 @@ function call_move(x)
|
|||||||
return x:move()
|
return x:move()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function ones(n)
|
||||||
|
local ret = 0
|
||||||
|
while n != 0 do
|
||||||
|
if (n&0x0.0001) ret += 1
|
||||||
|
n >>= 1
|
||||||
|
end
|
||||||
|
return ret
|
||||||
|
end
|
||||||
|
|
||||||
function updategame()
|
function updategame()
|
||||||
if (primary_ship.xp >= primary_ship.xptarget) and (lframe - primary_ship.last_xp_frame > 0x0.000f) and (not primary_ship.dead) then
|
if (primary_ship.xp >= primary_ship.xptarget) and (gframe - primary_ship.last_xp_frame > 0x0.000f) and (not primary_ship.dead) then
|
||||||
mode = rearm_mode.new()
|
mode = rearm_mode.new()
|
||||||
return _update60()
|
return _update60()
|
||||||
end
|
end
|
||||||
leveldone = level_frame()
|
gframe += 0x0.0001
|
||||||
|
if current_wave then
|
||||||
|
if current_wave:update() then
|
||||||
|
-- end of stage
|
||||||
|
waves_complete += 1
|
||||||
|
current_wave = nil
|
||||||
|
if waves_complete < 32767 then
|
||||||
|
interlude = 59 -- plus one dead frame with load_level but no update
|
||||||
|
else
|
||||||
|
-- you maxed out the level
|
||||||
|
-- counter. what the fuck
|
||||||
|
-- is wrong with you?
|
||||||
|
-- go outside.
|
||||||
|
--
|
||||||
|
-- do not spawn more levels.
|
||||||
|
interlude = 32767
|
||||||
|
end
|
||||||
|
end
|
||||||
|
elseif interlude > 0 then
|
||||||
|
interlude -= 1
|
||||||
|
else
|
||||||
|
current_wave = flotilla.new()
|
||||||
|
current_wave:load(0, 0, min(ones(waves_complete)\2, 4))
|
||||||
|
end
|
||||||
events:vore(new_events)
|
events:vore(new_events)
|
||||||
events:strip(call_move)
|
events:strip(call_move)
|
||||||
for _, lst in ipairs{intangibles_bg, pships, eships, pbullets, ebullets} do
|
for _, lst in ipairs{intangibles_bg, pships, eships, pbullets, ebullets} do
|
||||||
@ -254,7 +289,7 @@ function updategame()
|
|||||||
|
|
||||||
intangibles_fg:strip(call_move)
|
intangibles_fg:strip(call_move)
|
||||||
|
|
||||||
if leveldone and not eships.next and not ebullets.next and not events.next then
|
if waves_complete == 32767 and not eships.next and not ebullets.next and not events.next then
|
||||||
game_state = win
|
game_state = win
|
||||||
end
|
end
|
||||||
if (not pships.next) game_state = lose
|
if (not pships.next) game_state = lose
|
||||||
@ -619,7 +654,7 @@ end
|
|||||||
|
|
||||||
function ship_m:hitsomething(dmg)
|
function ship_m:hitsomething(dmg)
|
||||||
if (dmg <= 0) return false
|
if (dmg <= 0) return false
|
||||||
self.shield_refresh_ready = lframe + self.shieldpenalty
|
self.shield_refresh_ready = gframe + self.shieldpenalty
|
||||||
if self.shield > 0 then
|
if self.shield > 0 then
|
||||||
self.shield -= dmg
|
self.shield -= dmg
|
||||||
if self.shield > 0 then
|
if self.shield > 0 then
|
||||||
@ -641,10 +676,10 @@ end
|
|||||||
|
|
||||||
function ship_m:refresh_shield()
|
function ship_m:refresh_shield()
|
||||||
if (self.shield >= self.maxshield) return
|
if (self.shield >= self.maxshield) return
|
||||||
if (lframe < self.shield_refresh_ready) return
|
if (gframe < self.shield_refresh_ready) return
|
||||||
self.shield += 1
|
self.shield += 1
|
||||||
self.shield = min(self.shield, self.maxshield)
|
self.shield = min(self.shield, self.maxshield)
|
||||||
self.shield_refresh_ready = lframe + self.shieldcooldown
|
self.shield_refresh_ready = gframe + self.shieldcooldown
|
||||||
end
|
end
|
||||||
|
|
||||||
-->8
|
-->8
|
||||||
@ -813,12 +848,12 @@ function bullet_base:spawn_at(x, y)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function gun_base:shoot(x, y)
|
function gun_base:shoot(x, y)
|
||||||
if (lframe < self.shoot_ready) return false
|
if (gframe < self.shoot_ready) return false
|
||||||
if self.ammo then
|
if self.ammo then
|
||||||
if (self.ammo <= 0) return false
|
if (self.ammo <= 0) return false
|
||||||
self.ammo -= 1
|
self.ammo -= 1
|
||||||
end
|
end
|
||||||
self.shoot_ready = lframe + self.cooldown
|
self.shoot_ready = gframe + self.cooldown
|
||||||
self:actually_shoot(x, y)
|
self:actually_shoot(x, y)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
@ -1251,81 +1286,10 @@ shield will
|
|||||||
return ret
|
return ret
|
||||||
end
|
end
|
||||||
|
|
||||||
frownie = mknew(ship_m.new{
|
-- original prototype leftover;
|
||||||
--shape
|
-- likely to be the basis of a
|
||||||
sprite = 3, --index of ship sprite
|
-- standard raider type, so
|
||||||
size = 1, --all ships are square; how many 8x8 sprites?
|
-- i am keeping it around
|
||||||
hurt = { -- hurtbox - where this ship can be hit
|
|
||||||
x_off = 0, -- upper left corner
|
|
||||||
y_off = 1, -- relative to ship ulc
|
|
||||||
width = 8,
|
|
||||||
height = 6
|
|
||||||
},
|
|
||||||
sparks = smokespark,
|
|
||||||
sparkodds = 8,
|
|
||||||
|
|
||||||
hp = 0.5, -- enemy ships need no max hp
|
|
||||||
xp = 0x0.0001,
|
|
||||||
|
|
||||||
-- position
|
|
||||||
x=60, -- x and y are for upper left corner
|
|
||||||
y=8,
|
|
||||||
xmomentum = 0,
|
|
||||||
ymomentum = 0,
|
|
||||||
maxspd = 2, -- momentum cap
|
|
||||||
thrust = 0.12, -- momentum added from button
|
|
||||||
drag = 0.07, -- momentum lost per frame
|
|
||||||
slip = true,
|
|
||||||
act = function(self)
|
|
||||||
local tstate,dx = (1 + flr(4*t() + 0.5)) % 6,0
|
|
||||||
if (tstate==1 or tstate==2) dx=-self.thrust
|
|
||||||
if (tstate>=4) dx=self.thrust
|
|
||||||
return dx,0,false,false
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
|
|
||||||
blocky = mknew(frownie.new{
|
|
||||||
sprite = 10,
|
|
||||||
hp = 1.5,
|
|
||||||
xp = 0x0.0002,
|
|
||||||
hurt = {
|
|
||||||
x_off = 0,
|
|
||||||
y_off = 0,
|
|
||||||
width = 8,
|
|
||||||
height = 7
|
|
||||||
},
|
|
||||||
|
|
||||||
ow = function(self)
|
|
||||||
if self.hp < 1 then
|
|
||||||
self.sprite = 11
|
|
||||||
else
|
|
||||||
self.sprite = 10
|
|
||||||
end
|
|
||||||
ship_m.ow(self)
|
|
||||||
end
|
|
||||||
})
|
|
||||||
|
|
||||||
spewy = mknew(frownie.new{
|
|
||||||
sprite=26,
|
|
||||||
xp = 0x0.0003,
|
|
||||||
hurt = {
|
|
||||||
x_off=0,
|
|
||||||
y_off=1,
|
|
||||||
width=8,
|
|
||||||
height=5
|
|
||||||
},
|
|
||||||
hp=0.5,
|
|
||||||
fire_off_x=4,
|
|
||||||
fire_off_y=7,
|
|
||||||
act=function(self)
|
|
||||||
local dx,dy,shoot_spec=frownie.act(self)
|
|
||||||
return dx, dy, shoot_spec, self.y > 10
|
|
||||||
end,
|
|
||||||
init = function(ship)
|
|
||||||
ship.main_gun=ship.main_gun or protron_gun_e.new{}
|
|
||||||
end
|
|
||||||
})
|
|
||||||
|
|
||||||
chasey = mknew(ship_m.new{
|
chasey = mknew(ship_m.new{
|
||||||
sprite = 5,
|
sprite = 5,
|
||||||
xp = 0x0.0004,
|
xp = 0x0.0004,
|
||||||
@ -1403,7 +1367,7 @@ ship_f = mknew(ship_m.new{
|
|||||||
xp = 0x0.0001,
|
xp = 0x0.0001,
|
||||||
|
|
||||||
maxspd = 3,
|
maxspd = 3,
|
||||||
thrust = 0.15,
|
thrust = 0.1,
|
||||||
drag = 0.05,
|
drag = 0.05,
|
||||||
slip = false,
|
slip = false,
|
||||||
act = function(self)
|
act = function(self)
|
||||||
@ -1428,6 +1392,8 @@ ship_turret = mknew(ship_f.new{
|
|||||||
ship_skirmisher = mknew(ship_f.new{
|
ship_skirmisher = mknew(ship_f.new{
|
||||||
sprite=107,
|
sprite=107,
|
||||||
xp = 0x0.0004,
|
xp = 0x0.0004,
|
||||||
|
spark = smokespark,
|
||||||
|
sparkodds = 4,
|
||||||
})
|
})
|
||||||
|
|
||||||
function rnd_spawn_loc()
|
function rnd_spawn_loc()
|
||||||
@ -1520,259 +1486,145 @@ end
|
|||||||
-- see obsidian vault for
|
-- see obsidian vault for
|
||||||
-- full docs.
|
-- full docs.
|
||||||
|
|
||||||
-->8
|
flotilla = mknew{
|
||||||
-- level and event system
|
use_var = 0x1111,
|
||||||
|
opt_odds = split"0.5,0.5,0.5,0.5",
|
||||||
-- a level is a map from
|
init=function(this)
|
||||||
-- effective frame number to
|
this.ship_bases={
|
||||||
-- a list of actions for that
|
[0]=mknew(ship_mook.new{ship_t=0}),
|
||||||
-- frame. an action is a
|
[1]=mknew(ship_mook.new{ship_t=1, sprite=104}),
|
||||||
-- method name and its args.
|
[4]=mknew(ship_defender.new{ship_t=4}),
|
||||||
|
[5]=mknew(ship_defender.new{ship_t=5, sprite=10}),
|
||||||
-- effective frame number stops
|
[8]=mknew(ship_turret.new{ship_t=8}),
|
||||||
-- when freeze count is nonzero
|
[9]=mknew(ship_turret.new{ship_t=9, sprite=4}),
|
||||||
|
[12]=mknew(ship_skirmisher.new{ship_t=12}),
|
||||||
-- a level is won when it hits
|
[13]=mknew(ship_skirmisher.new{ship_t=13, sprite=26}),
|
||||||
-- the end-of-level sentinel
|
}
|
||||||
-- and there are no more
|
end,
|
||||||
-- tracked enemies.
|
|
||||||
-- lost when there are no
|
|
||||||
-- player ships left.
|
|
||||||
|
|
||||||
-- effective frame
|
|
||||||
distance = 0
|
|
||||||
-- actual frame count since
|
|
||||||
-- start of level times 0x0.0001
|
|
||||||
lframe = 0
|
|
||||||
|
|
||||||
-- do not advance distance when
|
|
||||||
-- nonzero
|
|
||||||
freeze = 0
|
|
||||||
|
|
||||||
eol = {}
|
|
||||||
|
|
||||||
function load_level(levelfile)
|
|
||||||
distance = 0
|
|
||||||
lframe = 0
|
|
||||||
freeze = 0
|
|
||||||
leveldone = false
|
|
||||||
current_level = {}
|
|
||||||
local found_eol = false
|
|
||||||
if (type(levelfile)=="string") levelfile = csv(levelfile)
|
|
||||||
for row in all(levelfile) do
|
|
||||||
local x = current_level[row[1]]
|
|
||||||
if row[2] == "eol" then
|
|
||||||
found_eol = true
|
|
||||||
assert(x==nil, "events on eol frame")
|
|
||||||
current_level[row[1]] = eol
|
|
||||||
else
|
|
||||||
row.next = x
|
|
||||||
current_level[row[1]]=row
|
|
||||||
end
|
|
||||||
end
|
|
||||||
assert(found_eol)
|
|
||||||
end
|
|
||||||
|
|
||||||
function level_frame()
|
|
||||||
lframe += 0x0.0001
|
|
||||||
if (current_level == nil) return true
|
|
||||||
if freeze == 0 then
|
|
||||||
distance += 1
|
|
||||||
local cbs = current_level[distance]
|
|
||||||
if cbs ~= nil then
|
|
||||||
if cbs == eol then
|
|
||||||
current_level = nil
|
|
||||||
return true
|
|
||||||
else
|
|
||||||
while cbs do
|
|
||||||
assert(cbs[1] == distance)
|
|
||||||
local f = _ENV[cbs[2]]
|
|
||||||
assert(type(f) == "function", cbs[2].." at "..distance.." is not a function")
|
|
||||||
f(unpack(cbs, 3))
|
|
||||||
cbs=cbs.next
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
-->8
|
|
||||||
-- example level
|
|
||||||
|
|
||||||
function spawn_blocking_rnd_x(typ)
|
|
||||||
freeze += 1
|
|
||||||
s = typ.new{
|
|
||||||
x = rnd(104),
|
|
||||||
y = -7,
|
|
||||||
ice = 1,
|
|
||||||
orig_die = typ.die,
|
|
||||||
die = function(self)
|
|
||||||
freeze -= self.ice
|
|
||||||
self.ice = 0
|
|
||||||
self:orig_die()
|
|
||||||
end,
|
|
||||||
}
|
|
||||||
eships:push_back(s)
|
|
||||||
return s
|
|
||||||
end
|
|
||||||
|
|
||||||
function spawn_frownie()
|
|
||||||
return spawn_rnd(frownie)
|
|
||||||
end
|
|
||||||
|
|
||||||
function spawn_blocking_frownie()
|
|
||||||
spawn_blocking_rnd_x(frownie)
|
|
||||||
end
|
|
||||||
|
|
||||||
function spawn_blocky()
|
|
||||||
spawn_rnd(blocky)
|
|
||||||
end
|
|
||||||
|
|
||||||
function spawn_blocking_blocky()
|
|
||||||
spawn_rnd(blocky, 1)
|
|
||||||
end
|
|
||||||
|
|
||||||
function spawn_spewy()
|
|
||||||
return spawn_rnd(spewy)
|
|
||||||
end
|
|
||||||
|
|
||||||
function spawn_chasey()
|
|
||||||
return spawn_rnd(chasey)
|
|
||||||
end
|
|
||||||
|
|
||||||
function spawn_blocking_spewy()
|
|
||||||
freeze += 1
|
|
||||||
local s = spawn_spewy()
|
|
||||||
s.ice = 1
|
|
||||||
s.die = function(self)
|
|
||||||
freeze -= self.ice
|
|
||||||
self.ice = 0
|
|
||||||
frownie.die(self)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function spawn_vulcan_chasey()
|
|
||||||
local c = spawn_chasey()
|
|
||||||
c.main_gun=vulcan_gun_e.new{enemy=true}
|
|
||||||
c.sprite=4
|
|
||||||
return c
|
|
||||||
end
|
|
||||||
|
|
||||||
helpers = {
|
|
||||||
spawn_frownie,
|
|
||||||
spawn_frownie,
|
|
||||||
spawn_frownie,
|
|
||||||
spawn_blocky,
|
|
||||||
spawn_blocky,
|
|
||||||
spawn_chasey,
|
|
||||||
spawn_spewy,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function spawn_blocking_boss_chasey()
|
function flotilla:load(ulc_cx, ulc_cy, lvl)
|
||||||
local c = spawn_rnd(xl_chasey, 1)
|
local rows,cy,uv,counts={},ulc_cy,self.use_var,{
|
||||||
local nextspawn = lframe + 0x0.0080
|
[0]=0,
|
||||||
events:push_back{move=function()
|
[1]=0,
|
||||||
if lframe >= nextspawn then
|
[4]=0,
|
||||||
helpers[flr(rnd(#helpers))+1]()
|
[5]=0,
|
||||||
nextspawn += 0x0.0040
|
[8]=0,
|
||||||
|
[9]=0,
|
||||||
|
[12]=0,
|
||||||
|
[13]=0,
|
||||||
|
}
|
||||||
|
repeat
|
||||||
|
local row,cx,opt,f,mode= {},ulc_cx,{},0,0
|
||||||
|
for i,v in ipairs(self.opt_odds) do
|
||||||
|
opt[i*4-4]=rnd()<v
|
||||||
end
|
end
|
||||||
return c.dead
|
repeat
|
||||||
end}
|
f=fget(mget(cx, cy))
|
||||||
|
-- bits 0x03: control mark or ship?
|
||||||
|
mode = f&0x03
|
||||||
|
if mode==2 then
|
||||||
|
-- bits 0x0c: ship class
|
||||||
|
local ship_t = f&0x0c
|
||||||
|
-- bit 0x20: optional?
|
||||||
|
if f&0x20 == 0 or opt[ship_t] then
|
||||||
|
-- bit 0x10: alternate ship?
|
||||||
|
-- increment ship id if
|
||||||
|
-- alternate is requested
|
||||||
|
-- and we allow alternates
|
||||||
|
-- for this type of ship
|
||||||
|
ship_t+=(uv>>ship_t&0x1)&((f&0x10)>>4)
|
||||||
|
add(row, self.ship_bases[ship_t].new{col=cx-ulc_cx})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
cx += 1
|
||||||
|
until mode==1
|
||||||
|
-- mode 1: end of line control mark
|
||||||
|
-- bits 0x18: what size flotilla is this row used for?
|
||||||
|
if (f&0x18)>>3 <= lvl then
|
||||||
|
-- keep the row; count it
|
||||||
|
for s in all(row) do
|
||||||
|
counts[s.ship_t] += 1
|
||||||
|
s.x,s.y=rnd_spawn_loc()
|
||||||
|
eships:push_back(s)
|
||||||
|
end
|
||||||
|
add(rows, row)
|
||||||
|
end
|
||||||
|
cy += 1
|
||||||
|
-- control mark bit 0x04: end of flotilla
|
||||||
|
until f&0x04 > 0
|
||||||
|
self.rows=rows
|
||||||
|
self:statisfy(counts)
|
||||||
|
end
|
||||||
|
|
||||||
|
function flotilla:statisfy(counts)
|
||||||
|
-- TODO: now that we know how
|
||||||
|
-- many ships of each kind
|
||||||
|
-- exist, build ships to match
|
||||||
|
-- difficulty target
|
||||||
|
--
|
||||||
|
-- no difficulty model is yet
|
||||||
|
-- implemented, though, so
|
||||||
|
-- just use base ships only
|
||||||
|
-- for this prototype
|
||||||
|
end
|
||||||
|
|
||||||
|
function flotilla:update()
|
||||||
|
-- algorithm: redistribute
|
||||||
|
-- TODO: alternate flotilla movement algorithms
|
||||||
|
|
||||||
|
-- find effective width and height
|
||||||
|
local min_col,max_col,live_rows=999,0,0
|
||||||
|
for row in all(self.rows) do
|
||||||
|
local row_alive=false
|
||||||
|
for ship in all(row) do
|
||||||
|
if not ship.dead then
|
||||||
|
row_alive=true
|
||||||
|
local col=ship.col
|
||||||
|
if (col < min_col) min_col = col
|
||||||
|
if (col > max_col) max_col = col
|
||||||
|
end
|
||||||
|
end -- scanned row
|
||||||
|
if (row_alive) live_rows += 1
|
||||||
|
end -- extent search
|
||||||
|
|
||||||
|
if (live_rows == 0) return true -- done
|
||||||
|
|
||||||
|
-- distribute across box:
|
||||||
|
-- x = [4, 100)
|
||||||
|
-- y = [4, 60)
|
||||||
|
|
||||||
return c
|
local x_interval,x_offset = 0,52
|
||||||
end
|
if min_col < max_col then
|
||||||
|
x_interval=96/(max_col-min_col)
|
||||||
function std_spawn(tnm, n, blocking, goodie,altspr)
|
x_offset = 4-min_col*x_interval
|
||||||
local typ = _ENV[tnm]
|
|
||||||
assert(typ and typ.new, tostr(tnm).." not a class")
|
|
||||||
for i=1,(n or 1) do
|
|
||||||
spawn_rnd(typ, blocking, goodie,altspr)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local y_interval,y_offset=0,40
|
||||||
|
if live_rows > 1 then
|
||||||
|
y_interval=52/(live_rows-1)
|
||||||
|
y_offset=4-y_interval
|
||||||
|
end
|
||||||
|
|
||||||
|
-- now assign target locations
|
||||||
|
local real_row=0
|
||||||
|
for row in all(self.rows) do
|
||||||
|
local row_alive = false
|
||||||
|
for ship in all(row) do
|
||||||
|
if not ship.dead then
|
||||||
|
if not row_alive then
|
||||||
|
real_row += 1
|
||||||
|
row_alive = true
|
||||||
|
end
|
||||||
|
ship.want_x = ship.col * x_interval + x_offset
|
||||||
|
ship.want_y = real_row * y_interval + y_offset
|
||||||
|
end -- ship updated
|
||||||
|
end -- row updated
|
||||||
|
end -- table updated
|
||||||
|
|
||||||
|
return false -- some ships remain
|
||||||
end
|
end
|
||||||
|
|
||||||
-- blocking: 1 or 0
|
|
||||||
function spawn_rnd(typ, blocking, goodie,altspr)
|
|
||||||
blocking = blocking or 0
|
|
||||||
freeze += blocking
|
|
||||||
s = typ.new{
|
|
||||||
x = rnd(104),
|
|
||||||
y = -(typ.size * 8 - 1),
|
|
||||||
ice=blocking,
|
|
||||||
die=function(self)
|
|
||||||
freeze -= self.ice
|
|
||||||
self.ice=0
|
|
||||||
typ.die(self)
|
|
||||||
end,
|
|
||||||
}
|
|
||||||
if (altspr) s.spr = altspr
|
|
||||||
eships:push_back(s)
|
|
||||||
return s
|
|
||||||
end
|
|
||||||
|
|
||||||
function multi(times, interval, fnm, ...)
|
|
||||||
local f,irm,vargs = _ENV[fnm],interval,pack(...)
|
|
||||||
assert(type(f) == "function", fnm.." not a function")
|
|
||||||
f(...)
|
|
||||||
events:push_back{move=function()
|
|
||||||
irm-=1
|
|
||||||
if irm <= 0 then
|
|
||||||
irm=interval
|
|
||||||
times-=1
|
|
||||||
f(unpack(vargs))
|
|
||||||
return times <= 1
|
|
||||||
end
|
|
||||||
end}
|
|
||||||
end
|
|
||||||
|
|
||||||
function demo_spawn_f(ttn)
|
|
||||||
local spx,spy=rnd_spawn_loc()
|
|
||||||
local s = _ENV[ttn].new{
|
|
||||||
x = spx,
|
|
||||||
y = spy,
|
|
||||||
want_x = 8 + rnd(96),
|
|
||||||
want_y = 8 + rnd(64)
|
|
||||||
}
|
|
||||||
eships:push_back(s)
|
|
||||||
return s
|
|
||||||
end
|
|
||||||
|
|
||||||
-- then convert sample_level to csv.
|
|
||||||
-- spawn_spec_gun_at and spawn_main_gun_at will need parsed forms.
|
|
||||||
-- the boss also needs to be reachable, but one-off is fine.
|
|
||||||
-- each row of level csv is offset,event,event-args...
|
|
||||||
-- where offset,eol is a special case.
|
|
||||||
|
|
||||||
example_level_csv=[[1,spawn_frownie
|
|
||||||
20,demo_spawn_f,ship_mook
|
|
||||||
25,demo_spawn_f,ship_defender
|
|
||||||
30,demo_spawn_f,ship_turret
|
|
||||||
35,demo_spawn_f,ship_skirmisher
|
|
||||||
60,spawn_vulcan_chasey
|
|
||||||
61,spawn_blocky
|
|
||||||
85,spawn_spewy
|
|
||||||
115,spawn_spewy
|
|
||||||
130,spawn_frownie
|
|
||||||
145,spawn_frownie
|
|
||||||
180,spawn_spewy
|
|
||||||
230,spawn_chasey
|
|
||||||
250,spawn_blocking_blocky
|
|
||||||
310,spawn_blocking_blocky
|
|
||||||
310,spawn_blocking_blocky
|
|
||||||
310,spawn_blocking_blocky
|
|
||||||
311,spawn_frownie
|
|
||||||
401,spawn_frownie
|
|
||||||
420,spawn_blocking_frownie
|
|
||||||
430,spawn_vulcan_chasey
|
|
||||||
450,spawn_frownie
|
|
||||||
465,spawn_frownie
|
|
||||||
480,spawn_chasey
|
|
||||||
500,multi,20,12,spawn_blocking_blocky
|
|
||||||
501,spawn_frownie
|
|
||||||
620,spawn_blocking_blocky
|
|
||||||
630,spawn_vulcan_chasey
|
|
||||||
720,spawn_blocking_boss_chasey
|
|
||||||
721,eol]]
|
|
||||||
|
|
||||||
-->8
|
-->8
|
||||||
-- standard events
|
-- standard events
|
||||||
|
|
||||||
@ -1879,10 +1731,10 @@ function xp_gem:draw()
|
|||||||
-- sprite map position:
|
-- sprite map position:
|
||||||
-- sprite id to x and y,
|
-- sprite id to x and y,
|
||||||
-- offset shifts specific low
|
-- offset shifts specific low
|
||||||
-- bits of lframe up to the the
|
-- bits of gframe up to the the
|
||||||
-- bit with value 4 as a cheap
|
-- bit with value 4 as a cheap
|
||||||
-- way to pick an anim frame
|
-- way to pick an anim frame
|
||||||
if (lframe&0x0.003 == 0) qx, qy = (lframe&0x0.0004)<<16, (lframe&0x0.0008)<<15
|
if (gframe&0x0.003 == 0) qx, qy = (gframe&0x0.0004)<<16, (gframe&0x0.0008)<<15
|
||||||
sspr(
|
sspr(
|
||||||
(s%16<<3)+qx,
|
(s%16<<3)+qx,
|
||||||
(s\16<<3)+qy,
|
(s\16<<3)+qy,
|
||||||
@ -1908,7 +1760,7 @@ end
|
|||||||
function xp_gem:hitship(ship)
|
function xp_gem:hitship(ship)
|
||||||
if (ship ~= primary_ship or primary_ship.dead) return false
|
if (ship ~= primary_ship or primary_ship.dead) return false
|
||||||
primary_ship.xp += self.val
|
primary_ship.xp += self.val
|
||||||
primary_ship.last_xp_frame = lframe
|
primary_ship.last_xp_frame = gframe
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user