autofire and three guns
This commit is contained in:
parent
55ab256539
commit
637eed1eb8
@ -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,11 +404,13 @@ 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
|
||||
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
|
||||
@ -423,7 +425,6 @@ function draw_gun_info(lbl,fgc,x,y,gun)
|
||||
else
|
||||
line(118, y+22, 121, y+22, 2)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function vertmeter(x0,y0,x1,y1,val,maxval,cols)
|
||||
@ -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)
|
||||
@ -1951,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
|
||||
|
Loading…
x
Reference in New Issue
Block a user