unique bullet base instances
peel off new copies of ammo when using a new gun so we can upgrade it without screwing up the base stats
This commit is contained in:
parent
26c3a5b91e
commit
eed7b6af87
@ -126,8 +126,7 @@ end
|
|||||||
function _init()
|
function _init()
|
||||||
mode = game_mode
|
mode = game_mode
|
||||||
init_blip_pals()
|
init_blip_pals()
|
||||||
wipe_level()
|
wipe_game() -- redundant?
|
||||||
primary_ship.main_gun = zap_gun_p.new() -- redundant?
|
|
||||||
load_level(example_level_csv)
|
load_level(example_level_csv)
|
||||||
game_state = game
|
game_state = game
|
||||||
pal(2,129)
|
pal(2,129)
|
||||||
@ -157,7 +156,7 @@ function init_hpcols()
|
|||||||
hpcols = hpcols_lut[min(primary_ship.maxhp,6)]
|
hpcols = hpcols_lut[min(primary_ship.maxhp,6)]
|
||||||
end
|
end
|
||||||
|
|
||||||
function wipe_level()
|
function wipe_game()
|
||||||
xpwhoosh = nil
|
xpwhoosh = nil
|
||||||
primary_ship = player.new()
|
primary_ship = player.new()
|
||||||
init_hpcols()
|
init_hpcols()
|
||||||
@ -170,6 +169,8 @@ function wipe_level()
|
|||||||
intangibles_bg = linked_list.new()
|
intangibles_bg = linked_list.new()
|
||||||
events = linked_list.new()
|
events = linked_list.new()
|
||||||
new_events = linked_list.new()
|
new_events = linked_list.new()
|
||||||
|
primary_ship.main_gun = zap_gun_p.new()
|
||||||
|
primary_ship.main_gun:peel()
|
||||||
end
|
end
|
||||||
|
|
||||||
function _update60()
|
function _update60()
|
||||||
@ -689,6 +690,7 @@ gun_base = mknew{
|
|||||||
-- themselves to the player
|
-- themselves to the player
|
||||||
function gun_base:action()
|
function gun_base:action()
|
||||||
local item = self.new()
|
local item = self.new()
|
||||||
|
item:peel()
|
||||||
item.ammo = item.maxammo
|
item.ammo = item.maxammo
|
||||||
if not primary_ship.special_guns then
|
if not primary_ship.special_guns then
|
||||||
primary_ship.special_guns = {item}
|
primary_ship.special_guns = {item}
|
||||||
@ -697,6 +699,19 @@ function gun_base:action()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- make shot type unique so
|
||||||
|
-- stat modifications do not
|
||||||
|
-- damage base data
|
||||||
|
function gun_base:peel()
|
||||||
|
self.munition = self.munition.new()
|
||||||
|
end
|
||||||
|
|
||||||
|
-- default firing behavior:
|
||||||
|
-- single shot
|
||||||
|
function gun_base:actually_shoot(x, y)
|
||||||
|
self.munition.new{}:spawn_at(x, y)
|
||||||
|
end
|
||||||
|
|
||||||
function bullet_base:hitship(_)
|
function bullet_base:hitship(_)
|
||||||
self:die()
|
self:die()
|
||||||
return true
|
return true
|
||||||
@ -720,14 +735,6 @@ function bullet_base:draw()
|
|||||||
spr(self.sprite, self.x, self.y, self.width, self.height)
|
spr(self.sprite, self.x, self.y, self.width, self.height)
|
||||||
end
|
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)
|
function bullet_base:spawn_at(x, y)
|
||||||
self.x = x - self.x_off
|
self.x = x - self.x_off
|
||||||
self.y = y - self.y_off
|
self.y = y - self.y_off
|
||||||
@ -780,11 +787,11 @@ zap_p = mknew(zap_e.new{
|
|||||||
|
|
||||||
zap_gun_e = mknew(gun_base.new{
|
zap_gun_e = mknew(gun_base.new{
|
||||||
cooldown = 0x0.0020, -- frames between shots
|
cooldown = 0x0.0020, -- frames between shots
|
||||||
actually_shoot = spawn_one(zap_e),
|
munition = zap_e,
|
||||||
})
|
})
|
||||||
|
|
||||||
zap_gun_p = mknew(zap_gun_e.new{
|
zap_gun_p = mknew(zap_gun_e.new{
|
||||||
actually_shoot = spawn_one(zap_p),
|
munition = zap_p,
|
||||||
hdr = "mAIN gUN",
|
hdr = "mAIN gUN",
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -843,7 +850,7 @@ blast_gun = mknew(gun_base.new{
|
|||||||
cooldown = 0x0.0078, -- 120 frames between shots
|
cooldown = 0x0.0078, -- 120 frames between shots
|
||||||
ammo = 5,
|
ammo = 5,
|
||||||
maxammo = 5,
|
maxammo = 5,
|
||||||
actually_shoot = spawn_one(blast),
|
munition = blast,
|
||||||
hdr = "bLASTER",
|
hdr = "bLASTER",
|
||||||
body= [[plasma orb
|
body= [[plasma orb
|
||||||
cuts through
|
cuts through
|
||||||
|
Loading…
x
Reference in New Issue
Block a user