Compare commits

..

2 Commits

Author SHA1 Message Date
804eb62ae7
p is now x in ui
"x" looks pretty bad with a drop shadow! will tweak soon anyway
2024-09-07 16:07:40 -07:00
303148876d
Remove power mechanics. Replace with XP stub.
Also a few random comments and cleanups along the way.
2024-09-07 16:04:01 -07:00

View File

@ -339,10 +339,10 @@ function drawhud()
draw_gun_info("❎",1,116,3,primary_ship.main_gun) draw_gun_info("❎",1,116,3,primary_ship.main_gun)
draw_gun_info("🅾️",1,116,31,primary_ship.special_gun) draw_gun_info("🅾️",1,116,31,primary_ship.special_gun)
dropshadow("p h",114,59,1) dropshadow("x h",114,59,1)
inset(114,66,119,125) inset(114,66,119,125)
fillp(0x5a5a) fillp(0x5a5a)
vertmeter(115,67,118,124,primary_ship.power, primary_ship.max_power, powcols) vertmeter(115,67,118,124,primary_ship.xp, primary_ship.xptarget, powcols)
inset(120,66,125,125) inset(120,66,125,125)
-- 57 px vertically -- 57 px vertically
@ -425,14 +425,9 @@ ship_m = mknew{
-- ships have no shield by default -- ships have no shield by default
shield = 0, shield = 0,
maxshield = 0, maxshield = 0,
shieldcost = 32767.9,
shieldcooldown = 0x0.003c,--1s shieldcooldown = 0x0.003c,--1s
shieldpenalty = 0x0.012c, --5s shieldpenalty = 0x0.012c, --5s
max_power = 120,
power = 120,
generator = 2, -- power gen per frame
slip = true, -- most enemies slide slip = true, -- most enemies slide
xmomentum = 0, xmomentum = 0,
@ -492,7 +487,6 @@ end
function ship_m:move() function ship_m:move()
self:refresh_shield() self:refresh_shield()
self.power = min(self.max_power, self.power + self.generator)
local dx, dy, shoot_spec, shoot_main = self:act() local dx, dy, shoot_spec, shoot_main = self:act()
dx = self:constrain(self.x, self.xmomentum, self.xmin, self.xmax, dx) dx = self:constrain(self.x, self.xmomentum, self.xmin, self.xmax, dx)
dy = self:constrain(self.y, self.ymomentum, self.ymin, self.ymax, dy) dy = self:constrain(self.y, self.ymomentum, self.ymin, self.ymax, dy)
@ -534,9 +528,7 @@ end
function ship_m:maybe_shoot(gun) function ship_m:maybe_shoot(gun)
if (not gun) return if (not gun) return
if (self.power < gun.power) return return gun:shoot(self.x + self.fire_off_x, self.y + self.fire_off_y)
if (not gun:shoot(self.x + self.fire_off_x, self.y + self.fire_off_y)) return
self.power -= gun.power
end end
function ship_m:hitship(other) function ship_m:hitship(other)
@ -577,10 +569,8 @@ end
function ship_m:refresh_shield() function ship_m:refresh_shield()
if (self.shield >= self.maxshield) return if (self.shield >= self.maxshield) return
if (lframe < self.shield_refresh_ready) return if (lframe < self.shield_refresh_ready) return
if (self.power < self.shieldcost) return
self.shield += 1 self.shield += 1
self.shield = min(self.shield, self.maxshield) self.shield = min(self.shield, self.maxshield)
self.power -= self.shieldcost
self.shield_refresh_ready = lframe + self.shieldcooldown self.shield_refresh_ready = lframe + self.shieldcooldown
end end
@ -595,6 +585,28 @@ function enemy_blt_cat()
return ebullets return ebullets
end end
-- x, y: position
-- dx, dy: movement (linear)
-- f: frames remaining; nil for no limit
-- sprite: what sprite to draw
-- hurt -- hurtbox
-- width, height -- in sprites
-- x_off, y_off -- how to
-- initially position relative
-- to firing point. weird
-- details, check impl
-- damage -- damage to do to
-- a ship that gets hit
-- category -- function that
-- returns which bullet list
-- to spawn onto
-- hitship -- event handler,
-- takes ship as argument.
-- default: die, return true.
-- returns whether to delete
-- the bullet
-- die -- on-removal event,
-- default no-op
bullet_base = mknew{ } bullet_base = mknew{ }
gun_base = mknew{ gun_base = mknew{
@ -613,7 +625,8 @@ end
function bullet_base:move() function bullet_base:move()
self.x += self.dx self.x += self.dx
self.y += self.dy self.y += self.dy
if (self.y > 128) or (self.y < -8 * self.height) then if (self.f) self.f -= 1
if (self.y > 128) or (self.y < -8 * self.height) or (self.f and self.f < 0) then
self:die() self:die()
return true return true
end end
@ -654,7 +667,7 @@ end
zap_e = mknew(bullet_base.new{ zap_e = mknew(bullet_base.new{
--shape --shape
sprite = 9, --index of enemy ammo sprite sprite = 9, --index of ammo sprite
width = 1, --in 8x8 blocks width = 1, --in 8x8 blocks
height = 1, height = 1,
hurt = { -- hurtbox - where this ship can be hit hurt = { -- hurtbox - where this ship can be hit
@ -683,7 +696,6 @@ zap_p = mknew(zap_e.new{
}) })
zap_gun_e = mknew(gun_base.new{ zap_gun_e = mknew(gun_base.new{
power = 20, -- power consumed per shot
cooldown = 0x0.000a, -- frames between shots cooldown = 0x0.000a, -- frames between shots
ammo = nil, -- unlimited ammo - main gun ammo = nil, -- unlimited ammo - main gun
actually_shoot = spawn_one(zap_e), actually_shoot = spawn_one(zap_e),
@ -740,7 +752,6 @@ blast = mknew(bullet_base.new{
blast_gun = mknew(gun_base.new{ blast_gun = mknew(gun_base.new{
icon = 13, icon = 13,
power = 0, -- only cost is ammo
cooldown = 0x0.0020, -- frames between shots cooldown = 0x0.0020, -- frames between shots
ammo = 5, ammo = 5,
maxammo = 5, maxammo = 5,
@ -776,7 +787,6 @@ protron_p = mknew(protron_e.new{
protron_gun_e = mknew(gun_base.new{ protron_gun_e = mknew(gun_base.new{
icon = 25, icon = 25,
power = 60,
cooldown = 0x0.000f, -- frames between shots cooldown = 0x0.000f, -- frames between shots
ammo = nil, ammo = nil,
maxammo = nil, maxammo = nil,
@ -838,7 +848,6 @@ vulcan_p = mknew(vulcan_e.new{
vulcan_gun_e = mknew(gun_base.new{ vulcan_gun_e = mknew(gun_base.new{
icon = 37, icon = 37,
enemy = false, enemy = false,
power = 8,
cooldown = 0x0.0002, -- frames between shots cooldown = 0x0.0002, -- frames between shots
ammo = nil, ammo = nil,
maxammo = nil, maxammo = nil,
@ -880,13 +889,16 @@ player = mknew(ship_m.new{
sparkodds = 2, sparkodds = 2,
boss = true, -- dramatic special effects boss = true, -- dramatic special effects
-- health and power -- health
hp = 3, -- current health, non-regenerating hp = 3, -- current health, non-regenerating
maxhp = 3, -- player only; other ships never heal maxhp = 3, -- player only; other ships never heal
shield = 2, -- regenerates, using power shield = 2, -- regenerates
maxshield = 2, maxshield = 2,
shieldcost = 60, -- power cost to refill shield
generator = 2, -- xp, increments of 0x0.01
xp = 0,
xptarget = 0x0.05,
level = 1,
-- gun -- gun
main_gun = nil, -- assign at spawn time main_gun = nil, -- assign at spawn time
@ -942,7 +954,7 @@ frownie = mknew(ship_m.new{
sparks = smokespark, sparks = smokespark,
sparkodds = 8, sparkodds = 8,
-- health and power -- health
hp = 0.5, -- enemy ships need no max hp hp = 0.5, -- enemy ships need no max hp
-- position -- position
@ -984,7 +996,6 @@ blocky = mknew(frownie.new{
spewy = mknew(frownie.new{ spewy = mknew(frownie.new{
sprite=26, sprite=26,
power=-20,
hurt = { hurt = {
x_off=0, x_off=0,
y_off=1, y_off=1,
@ -992,13 +1003,11 @@ spewy = mknew(frownie.new{
height=5 height=5
}, },
hp=0.5, hp=0.5,
maxpower=70,
generator=0.5,
fire_off_x=4, fire_off_x=4,
fire_off_y = 7, fire_off_y=7,
act=function(self) act=function(self)
local dx,dy,shoot_spec=frownie.act(self) local dx,dy,shoot_spec=frownie.act(self)
return dx, dy, shoot_spec, true return dx, dy, shoot_spec, self.y > 10
end, end,
init = function(ship) init = function(ship)
ship.main_gun=ship.main_gun or protron_gun_e.new{} ship.main_gun=ship.main_gun or protron_gun_e.new{}
@ -1019,7 +1028,6 @@ chasey = mknew(ship_m.new{
hp = 1.5, hp = 1.5,
shield = 1, shield = 1,
maxshield = 1, maxshield = 1,
shieldcost = 180,
fire_off_x = 4, fire_off_x = 4,
fire_off_y = 7, fire_off_y = 7,
@ -1037,7 +1045,7 @@ chasey = mknew(ship_m.new{
function chasey:act() function chasey:act()
self.xmin = max(primary_ship.x-8, 0) self.xmin = max(primary_ship.x-8, 0)
self.xmax = min(primary_ship.x + 8, 112 - 8*self.size) self.xmax = min(primary_ship.x + 8, 112 - 8*self.size)
return 0, 0, false, self.x - 16 < primary_ship.x and self.x + 16 > primary_ship.x return 0, 0, false, self.y > 10 and self.x - 16 < primary_ship.x and self.x + 16 > primary_ship.x
end end
xl_chasey=mknew(chasey.new{ xl_chasey=mknew(chasey.new{
@ -1455,10 +1463,6 @@ algorithm expressed.
guns guns
---- ----
* power - cost in generator
power to fire. may be 0.
field directly read by ships;
required in all guns.
* t - metatable for bullet type. * t - metatable for bullet type.
fired once in the bullet's fired once in the bullet's
default direction per shot. default direction per shot.
@ -1486,11 +1490,6 @@ actually_shoot to change
projectile logic while keeping projectile logic while keeping
cooldown and ammo logic. cooldown and ammo logic.
ships manage generator power
before asking the gun to shoot.
this behavior is in
ship_m:maybe_shoot.
bullets bullets
------- -------
* dx, dy - movement per frame. * dx, dy - movement per frame.
@ -1577,39 +1576,19 @@ or less hp calls self:die() and
tells the main game loop to tells the main game loop to
remove it. remove it.
ships have power, from 0 to shieldcooldown is the interval
ship.maxpower, increasing by between restoring shield points.
ship.generator per frame. shieldpenalty is the delay
in maybe_shoot, ships check that before restoring points after
they have power to fire before any damage, reset to this value
trying to fire (the gun itself on every damaging hit (whether
checks ammo and cooldown), and it is absorbed by the shield or
spend that power if they fire. not) -- shield behaves like
halo and other shooters in its
power is also used to restore heritage, where it recovers if
shields - ship.shieldcost per you avoid damage for a while.
point of shields. shieldcooldown not that there is any safe cover
is the interval between in this kind of game.
restoring shield points, which
is reset to shieldpenalty when a
ship takes damage (regardless of
whether that damage is stopped
by the shield or not).
shieldpenalty is much worse than
shieldcooldown (hALO shield).
therefore:
* damaged ships spend power
repairing shields, which may
affect ability to fire guns.
this looks like a slow firing
rate because the ship will
eventually recover enough
energy to fire.
* a ship firing nonstop will
typically be unable to recover
any shields because it will
not have energy to do so.
ships do not repair hp on their ships do not repair hp on their
own. negative-damage bullets own. negative-damage bullets