Compare commits
No commits in common. "804eb62ae74343892047994e31b9c2afd1d0e3ae" and "b379e47dbf69bbdcc1646ce662851a9ff67aa7bc" have entirely different histories.
804eb62ae7
...
b379e47dbf
125
vacuum_gambit.p8
125
vacuum_gambit.p8
@ -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("x h",114,59,1)
|
dropshadow("p 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.xp, primary_ship.xptarget, powcols)
|
vertmeter(115,67,118,124,primary_ship.power, primary_ship.max_power, powcols)
|
||||||
|
|
||||||
inset(120,66,125,125)
|
inset(120,66,125,125)
|
||||||
-- 57 px vertically
|
-- 57 px vertically
|
||||||
@ -425,9 +425,14 @@ 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,
|
||||||
@ -487,6 +492,7 @@ 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)
|
||||||
@ -528,7 +534,9 @@ end
|
|||||||
|
|
||||||
function ship_m:maybe_shoot(gun)
|
function ship_m:maybe_shoot(gun)
|
||||||
if (not gun) return
|
if (not gun) return
|
||||||
return gun:shoot(self.x + self.fire_off_x, self.y + self.fire_off_y)
|
if (self.power < gun.power) return
|
||||||
|
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)
|
||||||
@ -569,8 +577,10 @@ 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
|
||||||
|
|
||||||
@ -585,28 +595,6 @@ 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{
|
||||||
@ -625,8 +613,7 @@ 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.f) self.f -= 1
|
if (self.y > 128) or (self.y < -8 * self.height) then
|
||||||
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
|
||||||
@ -667,7 +654,7 @@ end
|
|||||||
|
|
||||||
zap_e = mknew(bullet_base.new{
|
zap_e = mknew(bullet_base.new{
|
||||||
--shape
|
--shape
|
||||||
sprite = 9, --index of ammo sprite
|
sprite = 9, --index of enemy 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
|
||||||
@ -696,6 +683,7 @@ 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),
|
||||||
@ -752,6 +740,7 @@ 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,
|
||||||
@ -787,6 +776,7 @@ 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,
|
||||||
@ -848,6 +838,7 @@ 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,
|
||||||
@ -889,16 +880,13 @@ player = mknew(ship_m.new{
|
|||||||
sparkodds = 2,
|
sparkodds = 2,
|
||||||
boss = true, -- dramatic special effects
|
boss = true, -- dramatic special effects
|
||||||
|
|
||||||
-- health
|
-- health and power
|
||||||
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
|
shield = 2, -- regenerates, using power
|
||||||
maxshield = 2,
|
maxshield = 2,
|
||||||
|
shieldcost = 60, -- power cost to refill shield
|
||||||
-- xp, increments of 0x0.01
|
generator = 2,
|
||||||
xp = 0,
|
|
||||||
xptarget = 0x0.05,
|
|
||||||
level = 1,
|
|
||||||
|
|
||||||
-- gun
|
-- gun
|
||||||
main_gun = nil, -- assign at spawn time
|
main_gun = nil, -- assign at spawn time
|
||||||
@ -954,7 +942,7 @@ frownie = mknew(ship_m.new{
|
|||||||
sparks = smokespark,
|
sparks = smokespark,
|
||||||
sparkodds = 8,
|
sparkodds = 8,
|
||||||
|
|
||||||
-- health
|
-- health and power
|
||||||
hp = 0.5, -- enemy ships need no max hp
|
hp = 0.5, -- enemy ships need no max hp
|
||||||
|
|
||||||
-- position
|
-- position
|
||||||
@ -996,6 +984,7 @@ 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,
|
||||||
@ -1003,11 +992,13 @@ 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, self.y > 10
|
return dx, dy, shoot_spec, true
|
||||||
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{}
|
||||||
@ -1028,6 +1019,7 @@ 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,
|
||||||
@ -1045,7 +1037,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.y > 10 and self.x - 16 < primary_ship.x and self.x + 16 > primary_ship.x
|
return 0, 0, false, 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{
|
||||||
@ -1463,6 +1455,10 @@ 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.
|
||||||
@ -1490,6 +1486,11 @@ 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.
|
||||||
@ -1576,19 +1577,39 @@ or less hp calls self:die() and
|
|||||||
tells the main game loop to
|
tells the main game loop to
|
||||||
remove it.
|
remove it.
|
||||||
|
|
||||||
shieldcooldown is the interval
|
ships have power, from 0 to
|
||||||
between restoring shield points.
|
ship.maxpower, increasing by
|
||||||
shieldpenalty is the delay
|
ship.generator per frame.
|
||||||
before restoring points after
|
in maybe_shoot, ships check that
|
||||||
any damage, reset to this value
|
they have power to fire before
|
||||||
on every damaging hit (whether
|
trying to fire (the gun itself
|
||||||
it is absorbed by the shield or
|
checks ammo and cooldown), and
|
||||||
not) -- shield behaves like
|
spend that power if they fire.
|
||||||
halo and other shooters in its
|
|
||||||
heritage, where it recovers if
|
power is also used to restore
|
||||||
you avoid damage for a while.
|
shields - ship.shieldcost per
|
||||||
not that there is any safe cover
|
point of shields. shieldcooldown
|
||||||
in this kind of game.
|
is the interval between
|
||||||
|
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
|
||||||
|
Loading…
Reference in New Issue
Block a user