Compare commits
No commits in common. "571412b15e11c85dc54c4e38d527842746129ea4" and "60b685d94b8bd1ca058c1e3da98705784717a15e" have entirely different histories.
571412b15e
...
60b685d94b
277
vacuum_gambit.p8
277
vacuum_gambit.p8
@ -1,5 +1,5 @@
|
||||
pico-8 cartridge // http://www.pico-8.com
|
||||
version 42
|
||||
version 41
|
||||
__lua__
|
||||
-- vacuum gambit
|
||||
-- by kistaro windrider
|
||||
@ -18,11 +18,6 @@ function csv(s)
|
||||
end
|
||||
return ret
|
||||
end
|
||||
function const_fxn(x)
|
||||
return function()
|
||||
return x
|
||||
end
|
||||
end
|
||||
|
||||
-- generate standard "overlay"
|
||||
-- constructor for type tt.
|
||||
@ -123,7 +118,7 @@ end
|
||||
function _init()
|
||||
init_blip_pals()
|
||||
wipe_level()
|
||||
primary_ship.main_gun = zap_gun_p.new() -- redundant?
|
||||
primary_ship.main_gun = zap_gun.new()
|
||||
load_level(example_level_csv)
|
||||
state = game
|
||||
pal(2,129)
|
||||
@ -585,15 +580,9 @@ end
|
||||
-->8
|
||||
-- bullet and gun behaviors
|
||||
|
||||
function player_blt_cat()
|
||||
return pbullets
|
||||
end
|
||||
|
||||
function enemy_blt_cat()
|
||||
return ebullets
|
||||
end
|
||||
|
||||
bullet_base = { }
|
||||
bullet_base = {
|
||||
enemyspd = 0.5
|
||||
}
|
||||
mknew(bullet_base)
|
||||
|
||||
gun_base = {
|
||||
@ -612,10 +601,18 @@ end
|
||||
|
||||
function bullet_base:move()
|
||||
self.x += self.dx
|
||||
self.y += self.dy
|
||||
if (self.y > 128) or (self.y < -8 * self.height) then
|
||||
self:die()
|
||||
return true
|
||||
if self.enemy then
|
||||
self.y += self.dy
|
||||
if self.y > 128 then
|
||||
self:die()
|
||||
return true
|
||||
end
|
||||
else
|
||||
self.y -= self.dy
|
||||
if self.y < -8*self.height then
|
||||
self:die()
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
@ -624,18 +621,17 @@ function bullet_base:draw()
|
||||
spr(self.sprite, self.x, self.y, self.width, self.height)
|
||||
end
|
||||
|
||||
-- An `actually_shoot` factory
|
||||
-- for trivial guns
|
||||
function spawn_one(t)
|
||||
return function(gun, x, y)
|
||||
t.new{}:spawn_at(x, y)
|
||||
end
|
||||
end
|
||||
|
||||
function bullet_base:spawn_at(x, y)
|
||||
self.x = x - self.x_off
|
||||
self.y = y - self.y_off
|
||||
self.category():push_back(self)
|
||||
self.x = x - self.center_x_off
|
||||
if self.enemy then
|
||||
self.dx *= self.enemyspd
|
||||
self.dy *= self.enemyspd
|
||||
self.y = y + self.top_y_off
|
||||
ebullets:push_back(self)
|
||||
else
|
||||
self.y = y - (8 * self.height) + self.bottom_y_off
|
||||
pbullets:push_back(self)
|
||||
end
|
||||
end
|
||||
|
||||
function gun_base:shoot(x, y)
|
||||
@ -649,12 +645,23 @@ function gun_base:shoot(x, y)
|
||||
return true
|
||||
end
|
||||
|
||||
function gun_base:actually_shoot(x, y)
|
||||
local typ = self.t
|
||||
local b = typ.new{
|
||||
enemy = self.enemy,
|
||||
sprite = self.enemy and typ.esprite or typ.psprite,
|
||||
}
|
||||
b:spawn_at(x, y)
|
||||
return true
|
||||
end
|
||||
|
||||
-->8
|
||||
-- bullets and guns
|
||||
|
||||
zap_e = bullet_base.new{
|
||||
zap = bullet_base.new{
|
||||
--shape
|
||||
sprite = 9, --index of enemy ammo sprite
|
||||
psprite = 8, --index of player ammo sprite
|
||||
esprite = 9, -- index of enemy ammo sprite
|
||||
width = 1, --in 8x8 blocks
|
||||
height = 1,
|
||||
hurt = { -- hurtbox - where this ship can be hit
|
||||
@ -663,43 +670,33 @@ zap_e = bullet_base.new{
|
||||
width = 2,
|
||||
height = 8
|
||||
},
|
||||
x_off = 1, -- how to position by ship
|
||||
y_off = 8,
|
||||
center_x_off = 1, -- how to position by ship
|
||||
bottom_y_off = 0,
|
||||
top_y_off = 0,
|
||||
|
||||
damage = 1,
|
||||
dx = 0, -- px/frame
|
||||
dy = 4,
|
||||
dy = 8,
|
||||
|
||||
hitship = const_fxn(true),
|
||||
|
||||
category = enemy_blt_cat,
|
||||
hitship = function(_, _)
|
||||
return true
|
||||
end
|
||||
}
|
||||
mknew(zap_e)
|
||||
mknew(zap)
|
||||
|
||||
zap_p = zap_e.new{
|
||||
sprite = 8,
|
||||
dy = -8,
|
||||
y_off = 0,
|
||||
category = player_blt_cat,
|
||||
}
|
||||
mknew(zap_p)
|
||||
|
||||
zap_gun_e = gun_base.new{
|
||||
zap_gun = gun_base.new{
|
||||
enemy = false,
|
||||
power = 20, -- power consumed per shot
|
||||
cooldown = 0x0.000a, -- frames between shots
|
||||
ammo = nil, -- unlimited ammo - main gun
|
||||
actually_shoot = spawn_one(zap_e),
|
||||
t = zap -- metatable of bullet to fire
|
||||
}
|
||||
mknew(zap_gun_e)
|
||||
|
||||
zap_gun_p = zap_gun_e.new{
|
||||
actually_shoot = spawn_one(zap_p),
|
||||
}
|
||||
mknew(zap_gun_p)
|
||||
mknew(zap_gun)
|
||||
|
||||
blast = bullet_base.new{
|
||||
--shape
|
||||
sprite = 12, --index of player ammo sprite
|
||||
psprite = 12, --index of player ammo sprite
|
||||
esprite = 3, -- index of enemy ammo sprite
|
||||
width = 1, --in 8x8 blocks
|
||||
height = 1,
|
||||
hurt = { -- hurtbox - where this ship can be hit
|
||||
@ -708,12 +705,13 @@ blast = bullet_base.new{
|
||||
width = 6,
|
||||
height = 6
|
||||
},
|
||||
x_off = 4, -- how to position by ship
|
||||
y_off = 0,
|
||||
center_x_off = 4, -- how to position by ship
|
||||
bottom_y_off = 0,
|
||||
top_y_off = 0,
|
||||
|
||||
damage = 4,
|
||||
dx = 0, -- px/frame
|
||||
dy = -2,
|
||||
dy = 2,
|
||||
awaitcancel = false,
|
||||
|
||||
-- disable damage for 2 frames
|
||||
@ -738,24 +736,25 @@ blast = bullet_base.new{
|
||||
self.awaitcancel = false
|
||||
end)
|
||||
end
|
||||
end,
|
||||
category=player_blt_cat
|
||||
end
|
||||
}
|
||||
mknew(blast)
|
||||
|
||||
blast_gun = gun_base.new{
|
||||
icon = 13,
|
||||
power = 0, -- only cost is ammo
|
||||
enemy = false,
|
||||
power = 0, -- ammo, not power
|
||||
cooldown = 0x0.0020, -- frames between shots
|
||||
ammo = 5,
|
||||
maxammo = 5,
|
||||
actually_shoot = spawn_one(blast),
|
||||
t = blast -- type of bullet to fire
|
||||
}
|
||||
mknew(blast_gun)
|
||||
|
||||
protron_e = bullet_base.new{
|
||||
protron = bullet_base.new{
|
||||
--shape
|
||||
sprite = 24,
|
||||
psprite = 23, --index of player ammo sprite
|
||||
esprite = 24, -- index of enemy ammo sprite
|
||||
width = 1, --in 8x8 blocks
|
||||
height = 1,
|
||||
hurt = { -- hurtbox - where this ship can be hit
|
||||
@ -764,63 +763,56 @@ protron_e = bullet_base.new{
|
||||
width = 2,
|
||||
height = 2
|
||||
},
|
||||
x_off = 1, -- how to position by ship
|
||||
y_off = 4,
|
||||
center_x_off = 1, -- how to position by ship
|
||||
bottom_y_off = 4,
|
||||
top_y_off = 0,
|
||||
|
||||
damage = 1,
|
||||
dym = 0.5, -- gun sets dy;
|
||||
-- this is mult
|
||||
category = enemy_blt_cat,
|
||||
dx = 0, -- px/frame
|
||||
dy = 3,
|
||||
}
|
||||
mknew(protron_e)
|
||||
mknew(protron)
|
||||
|
||||
protron_p = protron_e.new{
|
||||
sprite=23,
|
||||
dym = -1,
|
||||
y_off = 0,
|
||||
category=player_blt_cat,
|
||||
}
|
||||
mknew(protron_p)
|
||||
|
||||
protron_gun_e = gun_base.new{
|
||||
protron_gun = gun_base.new{
|
||||
icon = 25,
|
||||
enemy = false,
|
||||
power = 60,
|
||||
cooldown = 0x0.000f, -- frames between shots
|
||||
ammo = nil,
|
||||
maxammo = nil,
|
||||
munition = protron_e
|
||||
}
|
||||
mknew(protron_gun_e)
|
||||
|
||||
function protron_gun_e:actually_shoot(x, y)
|
||||
local m = self.munition.dym
|
||||
for i=1,3 do
|
||||
local b = self.munition.new{
|
||||
dx = i*m,
|
||||
dy = (4-i)*m,
|
||||
actually_shoot = function(self, x, y)
|
||||
local sprite = protron.psprite
|
||||
if (self.enemy) sprite=protron.esprite
|
||||
for i=1,3 do
|
||||
local b = protron.new{
|
||||
enemy=self.enemy,
|
||||
sprite=sprite,
|
||||
dx = i,
|
||||
dy = 4-i
|
||||
}
|
||||
b:spawn_at(x,y)
|
||||
local b2 = protron.new{
|
||||
enemy=self.enemy,
|
||||
sprite=sprite,
|
||||
dx = -i,
|
||||
dy = 4-i
|
||||
}
|
||||
b2:spawn_at(x,y)
|
||||
end
|
||||
local bup = protron.new{
|
||||
enemy=self.enemy,
|
||||
sprite=sprite,
|
||||
dy=4
|
||||
}
|
||||
b:spawn_at(x,y)
|
||||
local b2 = self.munition.new{
|
||||
dx = -i*m,
|
||||
dy = (4-i)*m,
|
||||
}
|
||||
b2:spawn_at(x,y)
|
||||
bup:spawn_at(x,y)
|
||||
end
|
||||
local bup = self.munition.new{
|
||||
dx=0,
|
||||
dy=4*m,
|
||||
}
|
||||
bup:spawn_at(x,y)
|
||||
end
|
||||
|
||||
protron_gun_p = protron_gun_e.new{
|
||||
munition = protron_p,
|
||||
}
|
||||
mknew(protron_gun_p)
|
||||
mknew(protron_gun)
|
||||
|
||||
vulcan_e = bullet_base.new{
|
||||
vulcan = bullet_base.new{
|
||||
--shape
|
||||
sprite = 21,
|
||||
psprite = 22, --index of player ammo sprite
|
||||
esprite = 21, -- index of enemy ammo sprite
|
||||
width = 1, --in 8x8 blocks
|
||||
height = 1,
|
||||
hurt = { -- hurtbox - where this ship can be hit
|
||||
@ -829,37 +821,31 @@ vulcan_e = bullet_base.new{
|
||||
width = 1,
|
||||
height = 4
|
||||
},
|
||||
x_off = 0.5, -- how to position by ship
|
||||
y_off = 0,
|
||||
center_x_off = 0.5, -- how to position by ship
|
||||
bottom_y_off = 4,
|
||||
top_y_off = 0,
|
||||
|
||||
damage = 0.5,
|
||||
-- dx from gun
|
||||
dy = 2,
|
||||
category=enemy_blt_cat
|
||||
dx = 0, -- px/frame
|
||||
dy = 4,
|
||||
}
|
||||
mknew(vulcan_e)
|
||||
mknew(vulcan)
|
||||
|
||||
vulcan_p = vulcan_e.new{
|
||||
sprite=22,
|
||||
y_off = 4,
|
||||
dy = -4,
|
||||
category=player_blt_cat
|
||||
}
|
||||
mknew(vulcan_e)
|
||||
|
||||
vulcan_gun_e = gun_base.new{
|
||||
vulcan_gun = gun_base.new{
|
||||
icon = 37,
|
||||
enemy = false,
|
||||
power = 8,
|
||||
cooldown = 0x0.0002, -- frames between shots
|
||||
ammo = nil,
|
||||
maxammo = nil,
|
||||
munition=vulcan_p,
|
||||
dxs = {0.35, -0.35, -0.7, 0.7, 0.35, -0.35},
|
||||
xoffs = {1, 0, -1, 1, 0, -1},
|
||||
dxidx = 1,
|
||||
actually_shoot = function(self, x, y)
|
||||
local b = self.munition.new{
|
||||
local sprite = self.enemy and vulcan.esprite or vulcan.psprite
|
||||
local b = vulcan.new{
|
||||
enemy=self.enemy,
|
||||
sprite=sprite,
|
||||
dx = self.dxs[self.dxidx],
|
||||
}
|
||||
b:spawn_at(self.xoffs[self.dxidx]+x,y)
|
||||
@ -867,11 +853,7 @@ vulcan_gun_e = gun_base.new{
|
||||
if (self.dxidx > #self.dxs) self.dxidx = 1
|
||||
end
|
||||
}
|
||||
mknew(vulcan_gun_e)
|
||||
|
||||
vulcan_gun_p = vulcan_gun_e.new{
|
||||
munition=vulcan_p,
|
||||
}
|
||||
mknew(vulcan_gun)
|
||||
|
||||
-->8
|
||||
--ships, including player
|
||||
@ -933,7 +915,7 @@ player = ship_m.new{
|
||||
}
|
||||
mknew(player,
|
||||
function(p)
|
||||
p.main_gun = zap_gun_p.new()
|
||||
p.main_gun = zap_gun.new()
|
||||
-- ONE HIT MODE
|
||||
--
|
||||
-- p.hp = 0
|
||||
@ -1018,7 +1000,7 @@ spewy = frownie.new{
|
||||
end
|
||||
}
|
||||
mknew(spewy, function(ship)
|
||||
ship.main_gun=ship.main_gun or protron_gun_e.new{enemy=true}
|
||||
ship.main_gun=ship.main_gun or protron_gun.new{enemy=true}
|
||||
end)
|
||||
|
||||
chasey = ship_m.new{
|
||||
@ -1046,7 +1028,7 @@ chasey = ship_m.new{
|
||||
slip = true,
|
||||
}
|
||||
mknew(chasey, function(ship)
|
||||
ship.main_gun=ship.main_gun or zap_gun_e.new{}
|
||||
ship.main_gun=ship.main_gun or zap_gun.new{enemy=true}
|
||||
end)
|
||||
|
||||
function chasey:act()
|
||||
@ -1064,8 +1046,6 @@ xl_chasey=chasey.new{
|
||||
width = 12,
|
||||
height = 10
|
||||
},
|
||||
fire_off_x = 8,
|
||||
fire_off_y = 15,
|
||||
hp = 19.5,
|
||||
shield = 5,
|
||||
boss = true,
|
||||
@ -1082,7 +1062,7 @@ xl_chasey=chasey.new{
|
||||
end,
|
||||
}
|
||||
mknew(xl_chasey, function(ship)
|
||||
ship.main_gun=ship.main_gun or zap_gun_e.new{}
|
||||
ship.main_gun=ship.main_gun or zap_gun.new{enemy=true}
|
||||
end)
|
||||
-->8
|
||||
-- collisions
|
||||
@ -1291,9 +1271,9 @@ end
|
||||
|
||||
function spawn_bonus_vulcan_chasey()
|
||||
local c = spawn_chasey()
|
||||
c.main_gun=vulcan_gun_e.new{enemy=true}
|
||||
c.main_gun=vulcan_gun.new{enemy=true}
|
||||
c.die = function(self)
|
||||
spawn_main_gun_at(self.x-1, self.y-1, vulcan_gun_p)
|
||||
spawn_main_gun_at(self.x-1, self.y-1, vulcan_gun)
|
||||
chasey.die(self)
|
||||
end
|
||||
c.sprite=4
|
||||
@ -1396,7 +1376,7 @@ example_level_csv=[[1,spawn_frownie
|
||||
310,spawn_blocking_blocky
|
||||
310,spawn_blocking_blocky
|
||||
311,spawn_frownie
|
||||
350,spawn_main_gun_at,70,-11,protron_gun_p
|
||||
350,spawn_main_gun_at,70,-11,protron_gun
|
||||
401,spawn_frownie
|
||||
420,spawn_blocking_frownie
|
||||
430,spawn_bonus_vulcan_chasey
|
||||
@ -1506,9 +1486,8 @@ bullets
|
||||
shots much easier to dodge
|
||||
* damage - damage per hit;
|
||||
used by ships
|
||||
* sprite - sprite index.
|
||||
* x_off, y_off - renamed for
|
||||
the next two vars. may revert
|
||||
* psprite, esprite - index of
|
||||
player or enemy sprite.
|
||||
* center_off_x - the horizontal
|
||||
centerpoint of the bullet,
|
||||
for positioning when firing.
|
||||
@ -1897,7 +1876,7 @@ powerup = bullet_base.new{
|
||||
-- easy to pick up
|
||||
dx = 0,
|
||||
dy = 1.5, -- 0.75 after enemyspd
|
||||
category = enemy_blt_cat, -- collides with player ship
|
||||
enemy = true, -- collides with player ship
|
||||
damage = 0,
|
||||
|
||||
anim_speed = 2,
|
||||
@ -1930,8 +1909,9 @@ repair = powerup.new{
|
||||
width = 12,
|
||||
height = 12
|
||||
},
|
||||
x_off = 4,
|
||||
y_off = 0,
|
||||
center_x_off = 4,
|
||||
top_y_off = 0,
|
||||
bottom_y_off = 0,
|
||||
sprites = sheen8x8,
|
||||
hitship = function(self, ship)
|
||||
if (ship ~= primary_ship) return false
|
||||
@ -1957,8 +1937,9 @@ gun_swap = powerup.new{
|
||||
height = 16
|
||||
},
|
||||
-- gun = gun_type.new{}
|
||||
x_off = 6,
|
||||
y_off = 0,
|
||||
center_x_off = 6,
|
||||
top_y_off = 0,
|
||||
bottom_y_off = 4,
|
||||
width = 2,
|
||||
height = 2,
|
||||
sprites = {64, 66, 68, 70, 72, 74, 76, 78},
|
||||
|
Loading…
Reference in New Issue
Block a user