Compare commits
3 Commits
do_rearm
...
637eed1eb8
Author | SHA1 | Date | |
---|---|---|---|
637eed1eb8
|
|||
55ab256539
|
|||
22d13121a9
|
142
vacuum_gambit.p8
142
vacuum_gambit.p8
@ -363,8 +363,8 @@ function drawhud()
|
||||
line(127,1,127,127,5)
|
||||
line(113,127)
|
||||
|
||||
draw_gun_info("❎",1,116,3,primary_ship.main_gun)
|
||||
draw_gun_info("🅾️",1,116,29,primary_ship.special_gun)
|
||||
draw_gun_info("❎",1,116,3,1)
|
||||
draw_gun_info("🅾️",1,116,29,2)
|
||||
|
||||
inset(114,57,119,118)
|
||||
rectfill(119,57,124,58,13)
|
||||
@ -404,25 +404,26 @@ function drawhud()
|
||||
fillp(0)
|
||||
end
|
||||
|
||||
function draw_gun_info(lbl,fgc,x,y,gun)
|
||||
function draw_gun_info(lbl,fgc,x,y,gn)
|
||||
dropshadow(lbl,x,y,fgc)
|
||||
inset(114,y+7,125,y+18)
|
||||
inset(114,y+20,125,y+24)
|
||||
if(gun) then
|
||||
spr(gun.icon,116,y+9,1,1)
|
||||
--115 to 124 - ammo bar. round up
|
||||
if gun.ammo == nil then
|
||||
fillp(0xa5a5)
|
||||
rectfill(115,y+21,124,y+23,0xea)
|
||||
fillp(0)
|
||||
elseif gun.ammo > 0 then
|
||||
rectfill(
|
||||
115,y+21,
|
||||
115+flr(9*gun.ammo/gun.maxammo),
|
||||
y+23,10)
|
||||
else
|
||||
line(118, y+22, 121, y+22, 2)
|
||||
end
|
||||
if (not primary_ship.special_guns) return
|
||||
local gun = primary_ship.special_guns[gn]
|
||||
if (not gun) return
|
||||
spr(gun.icon,116,y+9,1,1)
|
||||
--115 to 124 - ammo bar. round up
|
||||
if gun.ammo == nil then
|
||||
fillp(0xa5a5)
|
||||
rectfill(115,y+21,124,y+23,0xea)
|
||||
fillp(0)
|
||||
elseif gun.ammo > 0 then
|
||||
rectfill(
|
||||
115,y+21,
|
||||
115+flr(9*gun.ammo/gun.maxammo),
|
||||
y+23,10)
|
||||
else
|
||||
line(118, y+22, 121, y+22, 2)
|
||||
end
|
||||
end
|
||||
|
||||
@ -554,11 +555,12 @@ end
|
||||
|
||||
function ship_m:move()
|
||||
self:refresh_shield()
|
||||
local dx, dy, shoot_spec, shoot_main = self:act()
|
||||
local dx, dy, shoot_spec1, shoot_spec2 = self:act()
|
||||
dx = self:constrain(self.x, self.xmomentum, self.xmin, self.xmax, dx)
|
||||
dy = self:constrain(self.y, self.ymomentum, self.ymin, self.ymax, dy)
|
||||
if (shoot_main) self:maybe_shoot(self.main_gun)
|
||||
if (shoot_spec) self:maybe_shoot(self.special_gun)
|
||||
self:maybe_shoot(self.main_gun)
|
||||
if (shoot_spec1 and self.special_guns) self:maybe_shoot(self.special_guns[1])
|
||||
if (shoot_spec2 and self.special_guns) self:maybe_shoot(self.special_guns[2])
|
||||
if (dx ~= 0 or dy ~= 0) spark(self.sparks, self.x + 4*self.size, self.y + 4*self.size, dx*2.5, dy*2.5, self.sparkodds)
|
||||
self.xmomentum = self:calc_velocity(self.xmomentum, dx)
|
||||
self.ymomentum = self:calc_velocity(self.ymomentum, dy)
|
||||
@ -970,7 +972,7 @@ player = mknew(ship_m.new{
|
||||
|
||||
-- gun
|
||||
main_gun = nil, -- assign at spawn time
|
||||
special_gun = nil,
|
||||
special_guns = nil,
|
||||
fire_off_x = 4, -- offset where bullets come from
|
||||
fire_off_y = 0,
|
||||
|
||||
@ -1744,7 +1746,16 @@ function spawn_spec_gun_at(x, y, gunt)
|
||||
gun = gunt.new(),
|
||||
hitship = function(self, ship)
|
||||
if (ship ~= primary_ship) return false
|
||||
ship.special_gun = self.gun
|
||||
local specs = ship.special_guns
|
||||
if specs == nil then
|
||||
specs = {self.gun}
|
||||
elseif #specs == 1 then
|
||||
add(specs, self.gun)
|
||||
else
|
||||
specs[1]=specs[2]
|
||||
specs[2]=self.gun
|
||||
end
|
||||
ship.special_guns = specs
|
||||
return true
|
||||
end,
|
||||
draw = function(self)
|
||||
@ -1757,6 +1768,66 @@ function spawn_spec_gun_at(x, y, gunt)
|
||||
gun_p:spawn_at(x, y)
|
||||
end
|
||||
|
||||
-->8
|
||||
-- upgrade options
|
||||
|
||||
-- all these return
|
||||
-- a [2] of rearm_t:
|
||||
--
|
||||
-- s: sprite id
|
||||
-- hdr: title text
|
||||
-- body: text
|
||||
-- action: callback
|
||||
-- (method)
|
||||
|
||||
-- add a new gun
|
||||
function spec_gun_opts()
|
||||
return {{
|
||||
s=1,
|
||||
hdr="placeholder",
|
||||
body="placeholder",
|
||||
action = function() end,
|
||||
},
|
||||
{
|
||||
s=1,
|
||||
hdr="placeholder",
|
||||
body="placeholder",
|
||||
action = function() end,
|
||||
}}
|
||||
end
|
||||
|
||||
-- major upgrades
|
||||
function big_opts()
|
||||
return {{
|
||||
s=1,
|
||||
hdr="placeholder",
|
||||
body="placeholder",
|
||||
action = function() end,
|
||||
},
|
||||
{
|
||||
s=1,
|
||||
hdr="placeholder",
|
||||
body="placeholder",
|
||||
action = function() end,
|
||||
}}
|
||||
end
|
||||
|
||||
-- ordinary upgrades
|
||||
function small_opts()
|
||||
return {{
|
||||
s=1,
|
||||
hdr="placeholder",
|
||||
body="placeholder",
|
||||
action = function() end,
|
||||
},
|
||||
{
|
||||
s=1,
|
||||
hdr="placeholder",
|
||||
body="placeholder",
|
||||
action = function() end,
|
||||
}}
|
||||
end
|
||||
|
||||
-->8
|
||||
-- rearm screen
|
||||
|
||||
@ -1828,17 +1899,14 @@ function rearm_mode:shuffle()
|
||||
-- these will be placeholders
|
||||
-- until the upgrade deck
|
||||
-- is a thing that exists
|
||||
self.options = {{
|
||||
s=1,
|
||||
hdr=" hull",
|
||||
body = "\n +1\n max\n health",
|
||||
action = function() end,
|
||||
},{
|
||||
s=37,
|
||||
hdr=" vulc",
|
||||
body = "\nplaceholder",
|
||||
action = function() end,
|
||||
}}
|
||||
local lev = primary_ship.level + 1
|
||||
if lev == 4 or lev == 12 then
|
||||
self.options = spec_gun_opts()
|
||||
elseif lev % 4 == 0 then
|
||||
self.options = big_opts()
|
||||
else
|
||||
self.options = small_opts()
|
||||
end
|
||||
end
|
||||
|
||||
function rearm_mode:draw()
|
||||
@ -1894,7 +1962,11 @@ function rearm_mode:update()
|
||||
-- todo: sound: rearm
|
||||
primary_ship.shield = primary_ship.maxshield
|
||||
-- todo: rewrite for three guns
|
||||
if (primary_ship.special_gun) primary_ship.special_gun.ammo = primary_ship.special_gun.max_ammo
|
||||
local specs = primary_ship.special_guns
|
||||
if specs then
|
||||
specs[1].ammo = specs[1].max_ammo
|
||||
if (specs[2]) specs[2].ammo = specs[2].max_ammo
|
||||
end
|
||||
primary_ship.hp = min(primary_ship.maxhp, primary_ship.hp + primary_ship.maxhp/2)
|
||||
primary_ship.xp -= primary_ship.xptarget / 2
|
||||
else
|
||||
|
Reference in New Issue
Block a user