4 Commits

Author SHA1 Message Date
cb2d24c9d0 thrust performance is now also an option 2025-01-26 20:38:31 -08:00
67603f8496 start of normal ship upgrades
todo: thrust upgrade
2025-01-26 20:21:06 -08:00
2cebea663f make stat modifications actually work 2025-01-26 13:14:59 -08:00
eed7b6af87 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
2025-01-26 13:07:43 -08:00

View File

@ -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 = mknew(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
@ -1031,10 +1038,10 @@ player = mknew(ship_m.new{
y=96, y=96,
xmomentum = 0, xmomentum = 0,
ymomentum = 0, ymomentum = 0,
maxspd = 2.5, -- momentum cap maxspd = 1.5, -- momentum cap
thrust = 0.25, -- momentum added from button thrust = 0.1875, -- momentum added from button
ymin = 0, ymax = 120, -- stay on screen ymin = 0, ymax = 120, -- stay on screen
drag = 0.125, -- momentum lost per frame drag = 0.0625, -- momentum lost per frame
slip = false, -- does not slide down screen slip = false, -- does not slide down screen
act = function(self) -- fetch buttons act = function(self) -- fetch buttons
local b,th = btn(),self.thrust local b,th = btn(),self.thrust
@ -1061,6 +1068,75 @@ player = mknew(ship_m.new{
end, end,
}) })
function player:small_upgrade_opts()
local cdr, pr = (self.shieldcooldown - 0x0.000f) / 8, (self.shieldpenalty - 0x0.003c) / 9
if (cdr == 0 and self.shieldcooldown > 0x0.000f) cdr = 0x0.0001
if (pr == 0 and self.shieldpenalty > 0x0.003c) pr = 0x0.0001
local ret = {{
icon=53,
hdr="hull",
body=[[ armor
+2 hp]],
action=function()
self.maxhp += 2
self.hp += 2
end,
},{
icon=52,
hdr="shield",
body=[[ capacity
+1 hp]],
action=function()
self.maxshield += 1
self.shield += 1
end,
},{
icon=1,
hdr="thrusters",
body=[[performance
move faster,
steer faster]],
action=function()
--maxspd thrust drag
self.maxspd += 0.5
self.thrust += 0.0625
self.drag += 0.03125
end,
}}
if cdr > 0 then
add(ret, {
icon = 6,
hdr = "shield",
body=[[charge rate
]] .. tostr(ceil(100 * cdr / self.shieldcooldown)) .. "% faster",
action = function()
self.shieldcooldown -= cdr
end
})
end
if pr > 0 then
add(ret, {
icon = 6,
hdr = "shield",
body=[[disruption
]] .. tostr(ceil(100 * pr / self.shieldpenalty)) .. "% shorter",
action = function()
self.shieldpenalty -= pr
end
})
end
return ret
end
frownie = mknew(ship_m.new{ frownie = mknew(ship_m.new{
--shape --shape
sprite = 3, --index of ship sprite sprite = 3, --index of ship sprite
@ -1626,7 +1702,7 @@ end
-- when near player ship -- when near player ship
function xp_gem:hitship(ship) function xp_gem:hitship(ship)
if (ship ~= primary_ship) return false if (ship ~= primary_ship or primary_ship.dead) return false
primary_ship.xp += self.val primary_ship.xp += self.val
primary_ship.last_xp_frame = lframe primary_ship.last_xp_frame = lframe
return true return true
@ -1698,18 +1774,8 @@ end
-- ordinary upgrades -- ordinary upgrades
function small_opts() function small_opts()
return {{ -- todo: include gun opts
icon=1, return pick(primary_ship:small_upgrade_opts(), 2)
hdr="placeholder",
body="placeholder",
action = function() end,
},
{
icon=1,
hdr="placeholder",
body="placeholder",
action = function() end,
}}
end end
-->8 -->8