migrate ships to mknew style
This commit is contained in:
parent
f49407baca
commit
bad8452f3c
@ -153,7 +153,7 @@ function init_hpcols()
|
||||
end
|
||||
|
||||
function wipe_level()
|
||||
primary_ship = new_p1()
|
||||
primary_ship = player.new()
|
||||
init_hpcols()
|
||||
pships = linked_list.new()
|
||||
pships:push_back(primary_ship)
|
||||
@ -466,10 +466,7 @@ ship_m = {
|
||||
xmomentum = 0,
|
||||
ymomentum = 0,
|
||||
}
|
||||
|
||||
ship_t = {
|
||||
__index = ship_m,
|
||||
}
|
||||
mknew(ship_m)
|
||||
|
||||
function ship_m:die()
|
||||
self.dead = true
|
||||
@ -583,17 +580,10 @@ end
|
||||
-->8
|
||||
--ships, including player
|
||||
|
||||
function init_ship_mt()
|
||||
setmetatable(player, ship_t)
|
||||
setmetatable(frownie, ship_t)
|
||||
setmetatable(blocky, frownie_t)
|
||||
setmetatable(chasey, ship_t)
|
||||
end
|
||||
|
||||
firespark = split"9, 8, 2, 5, 1"
|
||||
smokespark = split"13, 13, 5, 5"
|
||||
|
||||
player = {
|
||||
player = ship_m.new{
|
||||
--shape
|
||||
sprite = 1, --index of ship sprite
|
||||
size = 1, --all ships are square; how many 8x8 sprites?
|
||||
@ -642,20 +632,13 @@ player = {
|
||||
return butts
|
||||
end
|
||||
}
|
||||
mknew(player,
|
||||
function(p)
|
||||
p.main_gun = new_gun_of(zap_gun_t, false)
|
||||
end
|
||||
)
|
||||
|
||||
player_t = {
|
||||
__index = player
|
||||
}
|
||||
|
||||
function new_p1()
|
||||
p = {
|
||||
main_gun = new_gun_of(zap_gun_t, false)
|
||||
}
|
||||
setmetatable(p, player_t)
|
||||
return p
|
||||
end
|
||||
|
||||
frownie = {
|
||||
frownie = ship_m.new{
|
||||
--shape
|
||||
sprite = 3, --index of ship sprite
|
||||
size = 1, --all ships are square; how many 8x8 sprites?
|
||||
@ -693,11 +676,9 @@ frownie = {
|
||||
return butts
|
||||
end, -- button fetch algorithm
|
||||
}
|
||||
frownie_t = {
|
||||
__index = frownie
|
||||
}
|
||||
mknew(frownie)
|
||||
|
||||
blocky = {
|
||||
blocky = frownie.new{
|
||||
sprite = 10,
|
||||
hp = 2,
|
||||
hurt = {
|
||||
@ -713,16 +694,13 @@ blocky = {
|
||||
else
|
||||
self.sprite = 10
|
||||
end
|
||||
ship_t.__index.ow(self)
|
||||
ship_m.ow(self)
|
||||
end
|
||||
}
|
||||
|
||||
blocky_t = {
|
||||
__index = blocky
|
||||
}
|
||||
mknew(blocky)
|
||||
|
||||
function spawn_spewy_at(x, y)
|
||||
local spewy = {
|
||||
local spewy = frownie.new{
|
||||
x = x,
|
||||
y = y,
|
||||
sprite = 26,
|
||||
@ -746,12 +724,11 @@ function spawn_spewy_at(x, y)
|
||||
return butts
|
||||
end,
|
||||
}
|
||||
setmetatable(spewy, frownie_t)
|
||||
eships:push_back(spewy)
|
||||
return spewy
|
||||
end
|
||||
|
||||
chasey = {
|
||||
chasey = ship_m.new{
|
||||
sprite = 5,
|
||||
size = 1,
|
||||
hurt = {
|
||||
@ -784,22 +761,20 @@ chasey = {
|
||||
return butts
|
||||
end,
|
||||
}
|
||||
chasey_t = {
|
||||
__index = chasey
|
||||
}
|
||||
mknew(chasey)
|
||||
|
||||
function spawn_chasey_at(x, y)
|
||||
local c = {
|
||||
local c = chasey.new{
|
||||
x = x,
|
||||
y = y,
|
||||
main_gun = new_gun_of(zap_gun_t, true)
|
||||
}
|
||||
setmetatable(c, chasey_t)
|
||||
eships:push_back(c)
|
||||
return c
|
||||
end
|
||||
|
||||
function spawn_xl_chasey_at(x, y)
|
||||
local c = {
|
||||
local c = chasey.new{
|
||||
x = x,
|
||||
y = y,
|
||||
size = 2,
|
||||
@ -826,7 +801,6 @@ function spawn_xl_chasey_at(x, y)
|
||||
pal()
|
||||
end,
|
||||
}
|
||||
setmetatable(c, chasey_t)
|
||||
eships:push_back(c)
|
||||
return c
|
||||
end
|
||||
@ -962,19 +936,18 @@ end
|
||||
-->8
|
||||
-- example level
|
||||
|
||||
function spawn_rnd_x(mt)
|
||||
s = {
|
||||
function spawn_rnd_x(typ)
|
||||
s = typ.new{
|
||||
x = rnd(104),
|
||||
y = -(mt.__index.size * 8 - 1)
|
||||
}
|
||||
setmetatable(s, mt)
|
||||
eships:push_back(s)
|
||||
return s
|
||||
end
|
||||
|
||||
function spawn_blocking_rnd_x(mt)
|
||||
function spawn_blocking_rnd_x(typ)
|
||||
freeze += 1
|
||||
s = {
|
||||
s = typ.new{
|
||||
x = rnd(104),
|
||||
y = -7,
|
||||
ice = 1,
|
||||
@ -984,25 +957,24 @@ function spawn_blocking_rnd_x(mt)
|
||||
mt.__index.die(self)
|
||||
end
|
||||
}
|
||||
setmetatable(s, mt)
|
||||
eships:push_back(s)
|
||||
return s
|
||||
end
|
||||
|
||||
function spawn_frownie()
|
||||
return spawn_rnd_x(frownie_t)
|
||||
return spawn_rnd_x(frownie)
|
||||
end
|
||||
|
||||
function spawn_blocking_frownie()
|
||||
spawn_blocking_rnd_x(frownie_t)
|
||||
spawn_blocking_rnd_x(frownie)
|
||||
end
|
||||
|
||||
function spawn_blocky()
|
||||
spawn_rnd_x(blocky_t)
|
||||
spawn_rnd_x(blocky)
|
||||
end
|
||||
|
||||
function spawn_blocking_blocky()
|
||||
spawn_blocking_rnd_x(blocky_t)
|
||||
spawn_blocking_rnd_x(blocky)
|
||||
end
|
||||
|
||||
function spawn_spewy()
|
||||
@ -1020,7 +992,7 @@ function spawn_blocking_spewy()
|
||||
s.die = function(self)
|
||||
freeze -= self.ice
|
||||
self.ice = 0
|
||||
frownie_t.__index.die(self)
|
||||
frownie.die(self)
|
||||
end
|
||||
end
|
||||
|
||||
@ -1029,7 +1001,7 @@ function spawn_bonus_frownie()
|
||||
f.sprite = 7
|
||||
f.die = function(self)
|
||||
spawn_repair_at(self.x+4, self.y+4)
|
||||
frownie_t.__index.die(self)
|
||||
frownie.die(self)
|
||||
end
|
||||
end
|
||||
|
||||
@ -1061,7 +1033,7 @@ function spawn_blocking_boss_chasey()
|
||||
c.die = function(self)
|
||||
freeze -= self.ice
|
||||
self.ice = 0
|
||||
chasey_t.__index.die(self)
|
||||
chasey.die(self)
|
||||
end
|
||||
|
||||
local nextspawn = lframe + 120
|
||||
|
Loading…
Reference in New Issue
Block a user