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(127,1,127,127,5)
|
||||||
line(113,127)
|
line(113,127)
|
||||||
|
|
||||||
draw_gun_info("❎",1,116,3,primary_ship.main_gun)
|
draw_gun_info("❎",1,116,3,1)
|
||||||
draw_gun_info("🅾️",1,116,29,primary_ship.special_gun)
|
draw_gun_info("🅾️",1,116,29,2)
|
||||||
|
|
||||||
inset(114,57,119,118)
|
inset(114,57,119,118)
|
||||||
rectfill(119,57,124,58,13)
|
rectfill(119,57,124,58,13)
|
||||||
@ -404,25 +404,26 @@ function drawhud()
|
|||||||
fillp(0)
|
fillp(0)
|
||||||
end
|
end
|
||||||
|
|
||||||
function draw_gun_info(lbl,fgc,x,y,gun)
|
function draw_gun_info(lbl,fgc,x,y,gn)
|
||||||
dropshadow(lbl,x,y,fgc)
|
dropshadow(lbl,x,y,fgc)
|
||||||
inset(114,y+7,125,y+18)
|
inset(114,y+7,125,y+18)
|
||||||
inset(114,y+20,125,y+24)
|
inset(114,y+20,125,y+24)
|
||||||
if(gun) then
|
if (not primary_ship.special_guns) return
|
||||||
spr(gun.icon,116,y+9,1,1)
|
local gun = primary_ship.special_guns[gn]
|
||||||
--115 to 124 - ammo bar. round up
|
if (not gun) return
|
||||||
if gun.ammo == nil then
|
spr(gun.icon,116,y+9,1,1)
|
||||||
fillp(0xa5a5)
|
--115 to 124 - ammo bar. round up
|
||||||
rectfill(115,y+21,124,y+23,0xea)
|
if gun.ammo == nil then
|
||||||
fillp(0)
|
fillp(0xa5a5)
|
||||||
elseif gun.ammo > 0 then
|
rectfill(115,y+21,124,y+23,0xea)
|
||||||
rectfill(
|
fillp(0)
|
||||||
115,y+21,
|
elseif gun.ammo > 0 then
|
||||||
115+flr(9*gun.ammo/gun.maxammo),
|
rectfill(
|
||||||
y+23,10)
|
115,y+21,
|
||||||
else
|
115+flr(9*gun.ammo/gun.maxammo),
|
||||||
line(118, y+22, 121, y+22, 2)
|
y+23,10)
|
||||||
end
|
else
|
||||||
|
line(118, y+22, 121, y+22, 2)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -554,11 +555,12 @@ end
|
|||||||
|
|
||||||
function ship_m:move()
|
function ship_m:move()
|
||||||
self:refresh_shield()
|
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)
|
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)
|
||||||
if (shoot_main) self:maybe_shoot(self.main_gun)
|
self:maybe_shoot(self.main_gun)
|
||||||
if (shoot_spec) self:maybe_shoot(self.special_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)
|
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.xmomentum = self:calc_velocity(self.xmomentum, dx)
|
||||||
self.ymomentum = self:calc_velocity(self.ymomentum, dy)
|
self.ymomentum = self:calc_velocity(self.ymomentum, dy)
|
||||||
@ -970,7 +972,7 @@ player = mknew(ship_m.new{
|
|||||||
|
|
||||||
-- gun
|
-- gun
|
||||||
main_gun = nil, -- assign at spawn time
|
main_gun = nil, -- assign at spawn time
|
||||||
special_gun = nil,
|
special_guns = nil,
|
||||||
fire_off_x = 4, -- offset where bullets come from
|
fire_off_x = 4, -- offset where bullets come from
|
||||||
fire_off_y = 0,
|
fire_off_y = 0,
|
||||||
|
|
||||||
@ -1744,7 +1746,16 @@ function spawn_spec_gun_at(x, y, gunt)
|
|||||||
gun = gunt.new(),
|
gun = gunt.new(),
|
||||||
hitship = function(self, ship)
|
hitship = function(self, ship)
|
||||||
if (ship ~= primary_ship) return false
|
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
|
return true
|
||||||
end,
|
end,
|
||||||
draw = function(self)
|
draw = function(self)
|
||||||
@ -1951,7 +1962,11 @@ function rearm_mode:update()
|
|||||||
-- todo: sound: rearm
|
-- todo: sound: rearm
|
||||||
primary_ship.shield = primary_ship.maxshield
|
primary_ship.shield = primary_ship.maxshield
|
||||||
-- todo: rewrite for three guns
|
-- 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.hp = min(primary_ship.maxhp, primary_ship.hp + primary_ship.maxhp/2)
|
||||||
primary_ship.xp -= primary_ship.xptarget / 2
|
primary_ship.xp -= primary_ship.xptarget / 2
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user