Compare commits
No commits in common. "f9e28fa0e280aa0a03dc3c53218699de609fc221" and "2a61e8b5d6aba26cc6ab44c602bab867ac2bb9ad" have entirely different histories.
f9e28fa0e2
...
2a61e8b5d6
120
updatedshmup.p8
120
updatedshmup.p8
@ -118,7 +118,7 @@ function _init()
|
||||
init_blip_pals()
|
||||
wipe_level()
|
||||
primary_ship.main_gun = zap_gun.new()
|
||||
load_level(example_level_csv)
|
||||
load_level(example_level)
|
||||
state = game
|
||||
pal(2,129)
|
||||
pal()
|
||||
@ -691,7 +691,7 @@ spewy = frownie.new{
|
||||
}
|
||||
mknew(spewy, function(ship)
|
||||
ship.main_gun=ship.main_gun or protron_gun.new{enemy=true}
|
||||
end})
|
||||
end}
|
||||
|
||||
chasey = ship_m.new{
|
||||
sprite = 5,
|
||||
@ -857,22 +857,18 @@ 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
|
||||
for row in all(csv(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
|
||||
row[1] = eol
|
||||
else
|
||||
row.next = x
|
||||
currentlevel[row[1]]=row
|
||||
add(x, row)
|
||||
end
|
||||
row[1]=x
|
||||
end
|
||||
assert found_eol
|
||||
leveldone = false
|
||||
end
|
||||
|
||||
function level_frame()
|
||||
@ -886,12 +882,9 @@ function level_frame()
|
||||
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
|
||||
for c in all(cbs) do
|
||||
assert(c[1] == distance)
|
||||
level_events[c[2]](unpack(c.params, 3))
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1007,9 +1000,17 @@ function spawn_blocking_boss_chasey()
|
||||
return c
|
||||
end
|
||||
|
||||
spawns = {
|
||||
chasey = chasey,
|
||||
frownie = frownie,
|
||||
blocky = blocky,
|
||||
spewy = spewy,
|
||||
spewy_xl=spewy_xl,
|
||||
-- TODO: populate this
|
||||
}
|
||||
function std_spawn(tnm, n, blocking, goodie,altspr)
|
||||
local typ = _ENV[tnm]
|
||||
assert(typ and typ.new, tostr(tnm).." not a class")
|
||||
local typ = spawns[tnm]
|
||||
assert(typ, tostr(tnm).." not a spawnable")
|
||||
for i=1,(n or 1) do
|
||||
spawn_rnd(typ, blocking, goodie,altspr)
|
||||
end
|
||||
@ -1042,9 +1043,14 @@ function spawn_goodie(goodie_name, x, y, sz)
|
||||
goodies[goodie_name].new{}:spawn_at(x+sh,y+sh)
|
||||
end
|
||||
|
||||
-- TODO: populate level_events
|
||||
|
||||
-- to implement: multi(times, interval, f, ...)
|
||||
-- once on this frame, then times-1 times after that spaced interval
|
||||
-- frames apart, f(...). schedule this like the one-off written in
|
||||
-- example_level.
|
||||
function multi(times, interval, fnm, ...)
|
||||
local f,irm = _ENV[fnm],interval
|
||||
assert(type(f) == "function", fnm.." not a function")
|
||||
local f,irm = level_events[fnm],interval
|
||||
fnm(...)
|
||||
events:push_back{move=function()
|
||||
irm-=1
|
||||
@ -1063,33 +1069,51 @@ end
|
||||
-- each row of level csv is offset,event,event-args...
|
||||
-- where offset,eol is a special case.
|
||||
|
||||
example_level_csv=[[1,spawn_frownie
|
||||
60,spawn_bonus_vulcan_chasey
|
||||
61,spawn_blocky
|
||||
85,spawn_spewy
|
||||
100,spawn_spewy
|
||||
115,spawn_spewy
|
||||
130,spawn_bonus_frownie
|
||||
145,spawn_spewy
|
||||
200,spawn_chasey
|
||||
250,spawn_blocking_blocky
|
||||
285,spawn_spec_gun_at,35,-11,blast_gun
|
||||
310,spawn_blocking_blocky
|
||||
310,spawn_blocking_blocky
|
||||
310,spawn_blocking_blocky
|
||||
311,spawn_frownie
|
||||
350,spawn_main_gun_at,70,-11,protron_gun
|
||||
401,spawn_frownie
|
||||
420,spawn_blocking_frownie
|
||||
430,spawn_bonus_vulcan_chasey
|
||||
450,spawn_frownie
|
||||
465,spawn_bonus_frownie
|
||||
480,spawn_chasey
|
||||
500,multi,20,12,spawn_blocking_blocky
|
||||
501,spawn_bonus_frownie
|
||||
620,spawn_blocking_blocky
|
||||
700,spawn_blocking_boss_chasey
|
||||
701,eol]]
|
||||
example_level = {
|
||||
[1]=spawn_frownie,
|
||||
[60]=spawn_bonus_vulcan_chasey,
|
||||
[61]=spawn_blocky,
|
||||
[85]=spawn_spewy,
|
||||
[100]=spawn_spewy,
|
||||
[115]=spawn_spewy,
|
||||
[130]=spawn_bonus_frownie,
|
||||
[145]=spawn_spewy,
|
||||
[200]=spawn_chasey,
|
||||
[250]=spawn_blocking_blocky,
|
||||
[285]=function()
|
||||
spawn_spec_gun_at(35, -11, blast_gun)
|
||||
end,
|
||||
[310]=function()
|
||||
spawn_blocking_blocky()
|
||||
spawn_blocking_blocky()
|
||||
spawn_blocking_blocky()
|
||||
end,
|
||||
[311]=spawn_frownie,
|
||||
[350]=function()
|
||||
spawn_main_gun_at(70, -11, protron_gun)
|
||||
end,
|
||||
[401]=spawn_frownie,
|
||||
[420]=spawn_blocking_frownie,
|
||||
[430]=spawn_bonus_vulcan_chasey,
|
||||
[450]=spawn_frownie,
|
||||
[465]=spawn_bonus_frownie,
|
||||
[480]=spawn_chasey,
|
||||
[500]=function()
|
||||
local tnext = lframe
|
||||
local remain = 20
|
||||
events:push_back{move=function()
|
||||
if (lframe < tnext) return false
|
||||
spawn_blocking_blocky()
|
||||
tnext = lframe + 0x0.000c
|
||||
remain -= 1
|
||||
return (remain <= 0)
|
||||
end}
|
||||
end,
|
||||
[501]=spawn_bonus_frownie,
|
||||
[620]=spawn_blocking_blocky,
|
||||
[700]=spawn_blocking_boss_chasey,
|
||||
[701]=eol
|
||||
}
|
||||
|
||||
-->8
|
||||
-- bullet and gun behaviors
|
||||
|
Loading…
Reference in New Issue
Block a user