6 Commits

View File

@ -466,6 +466,14 @@ end
-->8 -->8
--ship behavior --ship behavior
-- generic full sprite hurtbox
box8 = {
x_off = 0,
y_off = 1,
width = 8,
height = 8
}
scrollrate = 0.25 --in px/frame scrollrate = 0.25 --in px/frame
ship_m = mknew{ ship_m = mknew{
@ -1347,7 +1355,6 @@ chasey = mknew(ship_m.new{
end end
}) })
-- todo: use constraints
function chasey:act() function chasey:act()
self.xmin = max(primary_ship.x-8, 0) self.xmin = max(primary_ship.x-8, 0)
self.xmax = min(primary_ship.x + 8, 112 - 8*self.size) self.xmax = min(primary_ship.x + 8, 112 - 8*self.size)
@ -1385,6 +1392,53 @@ xl_chasey=mknew(chasey.new{
end, end,
}) })
-- flotilla ships
ship_f = mknew(ship_m.new{
-- sprite required
size = 1,
hurt = box8,
-- no sparks
hp = 0.5,
xp = 0x0.0001,
maxspd = 3,
thrust = 0.1,
drag = 0.05,
slip = false,
act = function(self)
local wx,wy=self.want_x,self.want_y
self.xmin,self.xmax,self.ymin,self.ymax = wx,wx,wy,wy
return 0,0,false,false
end,
})
ship_mook = mknew(ship_f.new{
sprite=103
})
ship_defender = mknew(ship_f.new{
sprite=105,
hp = 2.5,
xp = 0x0.0003,
})
ship_turret = mknew(ship_f.new{
sprite=106,
xp = 0x0.0002,
})
ship_skirmisher = mknew(ship_f.new{
sprite=107,
xp = 0x0.0004,
spark = smokespark,
sparkodds = 4,
})
function rnd_spawn_loc()
local x,y = flr(rnd(304)), flr(rnd(32))
if (x<184) return x-40,-y-8
if (x<244) return -y-8,x-184
return 112+y, x-244
end
-->8 -->8
-- collisions -- collisions
@ -1449,6 +1503,108 @@ function collider:get_collisions(item)
end end
return found return found
end end
-->8
-- flotillas
-- a template for a wave, read
-- from the map. each ship can
-- alternate between "attack"
-- and "formation" modes, like
-- galaxian or galaga. ships
-- with different roles have
-- different rules for becoming
-- aggressive, but aggression
-- ramps up during the wave.
-- flotilla placeholders are
-- defined by sprite flags.
-- see obsidian vault for
-- full docs.
flotilla = mknew{
use_var = 0x0001,
opt_odds = split"0.5,0.5,0.5,0.5",
init=function(this)
this.ship_bases={
[0]=mknew(ship_mook.new{ship_t=0}),
[1]=mknew(ship_mook.new{ship_t=1}),
[4]=mknew(ship_defender.new{ship_t=4}),
[5]=mknew(ship_defender.new{ship_t=5}),
[8]=mknew(ship_turret.new{ship_t=8}),
[9]=mknew(ship_turret.new{ship_t=9}),
[12]=mknew(ship_skirmisher.new{ship_t=12}),
[13]=mknew(ship_skirmisher.new{ship_t=13}),
}
end,
}
function flotilla:load(ulc_cx, ulc_cy, lvl)
local rows,cy,uv,counts={},ulc_cy,self.use_var+0xc840,{
[0]=0,
[1]=0,
[4]=0,
[5]=0,
[8]=0,
[9]=0,
[12]=0,
[13]=0,
}
repeat
local row,cx,opt,f = {},ulc_cx,{},0
for i,v in ipairs(self.opt_odds) do
opt[i*4-4]=rnd()<v
end
repeat
f=fget(mget(cx, cy))
-- bits 0x03: control mark or ship?
local 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{column=cx-ulc_cx})
end
end
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
end
add(rows, row)
end
-- control mark bit 0x04: end of flotilla
until f&0x04 == 1
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()
-- TODO: assign new want_x, want_y to everyone who isn't dead
end
-->8 -->8
-- level and event system -- level and event system
@ -1653,6 +1809,18 @@ function multi(times, interval, fnm, ...)
end} 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. -- then convert sample_level to csv.
-- spawn_spec_gun_at and spawn_main_gun_at will need parsed forms. -- 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. -- the boss also needs to be reachable, but one-off is fine.
@ -1660,10 +1828,14 @@ end
-- where offset,eol is a special case. -- where offset,eol is a special case.
example_level_csv=[[1,spawn_frownie example_level_csv=[[1,spawn_frownie
60,spawn_vulcan_chasey 20,demo_spawn_f,ship_mook
61,spawn_blocky 25,demo_spawn_f,ship_defender
85,spawn_spewy 30,demo_spawn_f,ship_turret
115,spawn_spewy 35,demo_spawn_f,ship_skirmisher
80,spawn_vulcan_chasey
81,spawn_blocky
100,spawn_spewy
125,spawn_spewy
130,spawn_frownie 130,spawn_frownie
145,spawn_frownie 145,spawn_frownie
180,spawn_spewy 180,spawn_spewy
@ -2106,21 +2278,21 @@ cddddddddddd0000cddddddddddd0000cddddddddddd0000cddddddddddd0000cddddddddddd0000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
04444400044444440000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 044444000444444400000000000000000000000000000000000000000000000000000000000000000000000000000000000bb000000aa0000009900000088000
447777700477777a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 447777700477777a0000000000000000000000000000000000000000000666000077700008888800000ab00006000060000bb000000aa0000009900000088000
477aaa7a0477aaaa0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 477aaa7a0477aaaa0000000000000000000000000000000000000000006ddd5007fff70008eeee20000ab00006c006d0000bb000000aa0000009900000088000
47a0047a047a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 47a0047a047a0000000000000000000000000000000000000000000006dd7d5007ffff4008eeee200aaabbb006ccccd0000bb000000aa0000009900000088000
47a0447a047a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 47a0447a047a0000000000000000000000000000000000000000000006d7dd5007ffff4008eeee200bbb333006ccccd0000bb000000aa0000009900000088000
47a4477a047a44400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 47a4477a047a4440000000000000000000000000000000000000000006ddd500004fff4008eeee20000b300006d00cd0000bb000000aa0000009900000088000
477777a00477777a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 477777a00477777a0000000000000000000000000000000000000000005550000004440002222200000b30000d0000d0000bb000000aa0000009900000088000
477770000422aaaa2222000200000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 477770000422aaaa22220002000002000000000000000000000000000000000000000000000000000000000000000000000bb000000aa0000009900000088000
47a77700022ee0002eeee002e00022e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 47a77700022ee0002eeee002e00022e00000000000000000000000000000000000000000000000000000000000000000000bb000000aa0000009900000088000
47a4777002ea2e002e002e02ee022ee0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 47a4777002ea2e002e002e02ee022ee00000000000000000000000000005600000474000028282000004b000060000000bbbbbb00aaaaaa00999999008888880
47a0477a22ea2e002e002e02e2e2e2e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 47a0477a22ea2e002e002e02e2e2e2e0000000000000000000000000005d0d0004f0f400080e0e00000a000000c000d00b0000b00a0000a00900009008000080
47a0047a2e2222e02e222e02e02e02e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 47a0047a2e2222e02e222e02e02e02e000000000000000000000000005d07050070f0f2002e0e02004a0b0b0060c0c000b0bb0b00a0aa0a00909909008088080
47a0047a2eeeeeea2eeee002e02e02e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 47a0047a2eeeeeea2eeee002e02e02e000000000000000000000000006070d1004f0f040080e0e000b0b035000c0c0d00b0bb0b00a0aa0a00909909008088080
0aa000aa2e7aa2ea2e00e002e02e02e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0aa000aa2e7aa2ea2e00e002e02e02e000000000000000000000000000d0d100002f0f2002e0e0200000300006000c000b0000b00a0000a00900009008000080
000000002e0002e02e002e02e02e02e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 000000002e0002e02e002e02e02e02e0000000000000000000000000000510000002420002020200000b5000000000d00bbbbbb00aaaaaa00999999008888880
000000000e0000e00e000e00e00e00e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 000000000e0000e00e000e00e00e00e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
__label__ __label__
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007777777777777777 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007777777777777777
@ -2252,3 +2424,12 @@ __label__
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007666666666666665 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007666666666666665
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007555555555555555 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007555555555555555
__gff__
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000212060a0e01091119000000000000002232363a3e050d151d
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
__map__
00006b6b00006f00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
7b6a00006a7b6e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
7778686878776c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
6767777767676c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
7877676777787d00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000