Compare commits
16 Commits
33fede4ed8
...
gun_picker
Author | SHA1 | Date | |
---|---|---|---|
26c3a5b91e
|
|||
44c70a028f
|
|||
a90caeba85
|
|||
cd5b79ef4a
|
|||
637eed1eb8
|
|||
55ab256539
|
|||
22d13121a9
|
|||
58da8e6dc3
|
|||
8ff0732cbc
|
|||
c88e7c0657
|
|||
ff3552bc45
|
|||
2dcb95b0cd
|
|||
87451bbd3a
|
|||
89a42e6c8b
|
|||
e2be11a2da
|
|||
175099d778
|
563
vacuum_gambit.p8
563
vacuum_gambit.p8
@ -185,6 +185,10 @@ function call_move(x)
|
||||
end
|
||||
|
||||
function updategame()
|
||||
if (primary_ship.xp >= primary_ship.xptarget) and (lframe - primary_ship.last_xp_frame > 0x0.000f) and (not primary_ship.dead) then
|
||||
mode = rearm_mode.new()
|
||||
return _update60()
|
||||
end
|
||||
leveldone = level_frame()
|
||||
events:vore(new_events)
|
||||
events:strip(call_move)
|
||||
@ -271,6 +275,7 @@ function _draw()
|
||||
end
|
||||
|
||||
function drawgame_top()
|
||||
camera()
|
||||
fillp(0)
|
||||
drawgame()
|
||||
if (game_state == game) fadelvl = -45
|
||||
@ -358,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)
|
||||
@ -399,33 +404,38 @@ 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
|
||||
|
||||
function vertmeter(x0,y0,x1,y1,val,maxval,cols)
|
||||
if ((val <= 0) or (maxval <= 0)) return
|
||||
if val < 0x0.001 or maxval < 0x0.001 then
|
||||
val *= 16
|
||||
maxval *= 16
|
||||
end
|
||||
val=min(val, maxval)
|
||||
local h = y1-y0
|
||||
local px = val/maxval * h \ 1
|
||||
local px = val*h/maxval \ 1
|
||||
local ncols = #cols
|
||||
local firstcol = ((h-px)*ncols\h)+1
|
||||
local lastbottom = y0+(h*firstcol\ncols)
|
||||
@ -490,8 +500,8 @@ function ship_m:die()
|
||||
if xp > 0x0.01f3 then -- dec 499
|
||||
-- spawn a huge gem with all
|
||||
-- overage XP, min 100
|
||||
spawn_xp_at(cx, cy, 0, xp-0x0.18f)
|
||||
xp = 0x0.18f -- dec 399
|
||||
spawn_xp_at(cx, cy, 0, xp-0x0.018f)
|
||||
xp = 0x0.018f -- dec 399
|
||||
z += 1
|
||||
end
|
||||
-- 100, 25, 5, 1
|
||||
@ -545,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)
|
||||
@ -672,6 +683,20 @@ gun_base = mknew{
|
||||
icon = 20
|
||||
}
|
||||
|
||||
-- gun_base subtypes are
|
||||
-- level-up options that,
|
||||
-- as an action, assign
|
||||
-- themselves to the player
|
||||
function gun_base:action()
|
||||
local item = self.new()
|
||||
item.ammo = item.maxammo
|
||||
if not primary_ship.special_guns then
|
||||
primary_ship.special_guns = {item}
|
||||
else
|
||||
add(primary_ship.special_guns, item)
|
||||
end
|
||||
end
|
||||
|
||||
function bullet_base:hitship(_)
|
||||
self:die()
|
||||
return true
|
||||
@ -754,13 +779,13 @@ zap_p = mknew(zap_e.new{
|
||||
})
|
||||
|
||||
zap_gun_e = mknew(gun_base.new{
|
||||
cooldown = 0x0.000a, -- frames between shots
|
||||
ammo = nil, -- unlimited ammo - main gun
|
||||
cooldown = 0x0.0020, -- frames between shots
|
||||
actually_shoot = spawn_one(zap_e),
|
||||
})
|
||||
|
||||
zap_gun_p = mknew(zap_gun_e.new{
|
||||
actually_shoot = spawn_one(zap_p),
|
||||
hdr = "mAIN gUN",
|
||||
})
|
||||
|
||||
blast = mknew(bullet_base.new{
|
||||
@ -779,17 +804,22 @@ blast = mknew(bullet_base.new{
|
||||
|
||||
damage = 4,
|
||||
dx = 0, -- px/frame
|
||||
dy = -2,
|
||||
dy = -1,
|
||||
awaitcancel = false,
|
||||
|
||||
-- disable damage for 2 frames
|
||||
-- disable damage for 4 frames
|
||||
-- when hitting something
|
||||
-- todo: rewrite all ship hit
|
||||
-- logic so i can avoid
|
||||
-- repeating hits to the
|
||||
-- same ship instead of
|
||||
-- using a cooldown
|
||||
hitship = function(self, _)
|
||||
if self.damage > 0 and not self.awaitcancel then
|
||||
self.awaitcancel = true
|
||||
once_next_frame(function()
|
||||
new_events:push_back{
|
||||
wait = 2,
|
||||
wait = 4,
|
||||
obj = self,
|
||||
saved_dmg = self.damage,
|
||||
move = function(self)
|
||||
@ -810,10 +840,20 @@ blast = mknew(bullet_base.new{
|
||||
|
||||
blast_gun = mknew(gun_base.new{
|
||||
icon = 13,
|
||||
cooldown = 0x0.0020, -- frames between shots
|
||||
cooldown = 0x0.0078, -- 120 frames between shots
|
||||
ammo = 5,
|
||||
maxammo = 5,
|
||||
actually_shoot = spawn_one(blast),
|
||||
hdr = "bLASTER",
|
||||
body= [[plasma orb
|
||||
cuts through
|
||||
enemies.
|
||||
slow.
|
||||
|
||||
ammo: 5
|
||||
rate: 1/2sec
|
||||
dmg: 4
|
||||
]],
|
||||
})
|
||||
|
||||
protron_e = mknew(bullet_base.new{
|
||||
@ -845,7 +885,7 @@ protron_p = mknew(protron_e.new{
|
||||
|
||||
protron_gun_e = mknew(gun_base.new{
|
||||
icon = 25,
|
||||
cooldown = 0x0.000f, -- frames between shots
|
||||
cooldown = 0x0.0040, -- frames between shots
|
||||
ammo = nil,
|
||||
maxammo = nil,
|
||||
munition = protron_e
|
||||
@ -874,6 +914,17 @@ end
|
||||
|
||||
protron_gun_p = mknew(protron_gun_e.new{
|
||||
munition = protron_p,
|
||||
maxammo = 20,
|
||||
cooldown = 0x0.0018,
|
||||
hdr = "pROTRON",
|
||||
body = [[spray shots
|
||||
in a dense
|
||||
arc.
|
||||
|
||||
ammo: 20
|
||||
rate: 2/sec
|
||||
dmg: 1
|
||||
]],
|
||||
})
|
||||
|
||||
vulcan_e = mknew(bullet_base.new{
|
||||
@ -906,7 +957,7 @@ vulcan_p = mknew(vulcan_e.new{
|
||||
vulcan_gun_e = mknew(gun_base.new{
|
||||
icon = 37,
|
||||
enemy = false,
|
||||
cooldown = 0x0.0002, -- frames between shots
|
||||
cooldown = 0x0.0003, -- frames between shots
|
||||
ammo = nil,
|
||||
maxammo = nil,
|
||||
munition=vulcan_e,
|
||||
@ -925,6 +976,16 @@ vulcan_gun_e = mknew(gun_base.new{
|
||||
|
||||
vulcan_gun_p = mknew(vulcan_gun_e.new{
|
||||
munition=vulcan_p,
|
||||
maxammo = 100,
|
||||
hdr = "vULCAN",
|
||||
body = [[rapid fire
|
||||
in a v
|
||||
shape.
|
||||
|
||||
ammo: 100
|
||||
rate: 20/sec
|
||||
dmg: 0.5
|
||||
]],
|
||||
})
|
||||
|
||||
-->8
|
||||
@ -956,11 +1017,12 @@ player = mknew(ship_m.new{
|
||||
-- xp in increments of 0x0.0001
|
||||
xp = 0,
|
||||
xptarget = 0x0.0004,
|
||||
last_xp_frame = 0,
|
||||
level = 1,
|
||||
|
||||
-- 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,
|
||||
|
||||
@ -1103,6 +1165,7 @@ chasey = mknew(ship_m.new{
|
||||
end
|
||||
})
|
||||
|
||||
-- todo: use constraints
|
||||
function chasey:act()
|
||||
self.xmin = max(primary_ship.x-8, 0)
|
||||
self.xmax = min(primary_ship.x + 8, 112 - 8*self.size)
|
||||
@ -1335,32 +1398,9 @@ function spawn_blocking_spewy()
|
||||
end
|
||||
end
|
||||
|
||||
function spawn_bonus_frownie()
|
||||
local f = spawn_frownie()
|
||||
f.sprite = 7
|
||||
f.die = function(self)
|
||||
spawn_repair_at(self.x+4, self.y+4)
|
||||
frownie.die(self)
|
||||
end
|
||||
end
|
||||
|
||||
function spawn_bonus_vulcan_chasey()
|
||||
function spawn_vulcan_chasey()
|
||||
local c = spawn_chasey()
|
||||
c.main_gun=vulcan_gun_e.new{enemy=true}
|
||||
c.die = function(self)
|
||||
spawn_main_gun_at(self.x-1, self.y-1, vulcan_gun_p)
|
||||
chasey.die(self)
|
||||
end
|
||||
c.sprite=4
|
||||
return c
|
||||
end
|
||||
|
||||
function spawn_bonus_shield_chasey()
|
||||
local c = spawn_chasey()
|
||||
c.die = function(self)
|
||||
spawn_shield_upgrade_at(self.x-1, self.y-1)
|
||||
chasey.die(self)
|
||||
end
|
||||
c.sprite=4
|
||||
return c
|
||||
end
|
||||
@ -1409,7 +1449,6 @@ function spawn_rnd(typ, blocking, goodie,altspr)
|
||||
freeze -= self.ice
|
||||
self.ice=0
|
||||
typ.die(self)
|
||||
spawn_goodie(goodie, self.x, self.y, self.size)
|
||||
end,
|
||||
}
|
||||
if (altspr) s.spr = altspr
|
||||
@ -1417,14 +1456,6 @@ function spawn_rnd(typ, blocking, goodie,altspr)
|
||||
return s
|
||||
end
|
||||
|
||||
-- TODO: spawn_goodie compatible versions of gun drops
|
||||
-- TODO: goodie table
|
||||
function spawn_goodie(goodie_name, x, y, sz)
|
||||
if (not goodie_name or #goodie_name == 0) return
|
||||
local sh = sz and sz/2 or 0
|
||||
_ENV[goodie_name].new{}:spawn_at(x+sh,y+sh)
|
||||
end
|
||||
|
||||
function multi(times, interval, fnm, ...)
|
||||
local f,irm,vargs = _ENV[fnm],interval,pack(...)
|
||||
assert(type(f) == "function", fnm.." not a function")
|
||||
@ -1447,31 +1478,29 @@ end
|
||||
-- where offset,eol is a special case.
|
||||
|
||||
example_level_csv=[[1,spawn_frownie
|
||||
60,spawn_bonus_vulcan_chasey
|
||||
60,spawn_vulcan_chasey
|
||||
61,spawn_blocky
|
||||
85,spawn_spewy
|
||||
100,spawn_spewy
|
||||
115,spawn_spewy
|
||||
130,spawn_bonus_frownie
|
||||
145,spawn_spewy
|
||||
200,spawn_bonus_shield_chasey
|
||||
130,spawn_frownie
|
||||
145,spawn_frownie
|
||||
180,spawn_spewy
|
||||
230,spawn_chasey
|
||||
250,spawn_blocking_blocky
|
||||
285,spawn_spec_gun_at,35,-11,blast_gun
|
||||
310,spawn_blocking_blocky
|
||||
310,spawn_blocking_blocky
|
||||
310,spawn_blocking_blocky
|
||||
311,spawn_frownie
|
||||
350,spawn_main_gun_at,70,-11,protron_gun_p
|
||||
401,spawn_frownie
|
||||
420,spawn_blocking_frownie
|
||||
430,spawn_bonus_vulcan_chasey
|
||||
430,spawn_vulcan_chasey
|
||||
450,spawn_frownie
|
||||
465,spawn_bonus_frownie
|
||||
465,spawn_frownie
|
||||
480,spawn_chasey
|
||||
500,multi,20,12,spawn_blocking_blocky
|
||||
501,spawn_bonus_frownie
|
||||
501,spawn_frownie
|
||||
620,spawn_blocking_blocky
|
||||
630,spawn_bonus_shield_chasey
|
||||
630,spawn_vulcan_chasey
|
||||
720,spawn_blocking_boss_chasey
|
||||
721,eol]]
|
||||
|
||||
@ -1614,137 +1643,229 @@ function spawn_xp_at(x, y, off, amt)
|
||||
}:spawn_at(mid(x, 0, 124),mid(y,-4,125))
|
||||
end
|
||||
|
||||
powerup = mknew(bullet_base.new{
|
||||
-- animated sprite array: "sprites"
|
||||
-- to draw under or over anim,
|
||||
-- override draw, draw the
|
||||
-- under-part, call into
|
||||
-- powerup.draw(self), then
|
||||
-- draw the over-part
|
||||
width = 1,
|
||||
height = 1,
|
||||
-- note: make hurtboxes larger
|
||||
-- than sprite by 2px per side
|
||||
-- since ship hitbox is tiny
|
||||
-- but powerups should feel
|
||||
-- easy to pick up
|
||||
dx = 0,
|
||||
dy = 0.75,
|
||||
category = enemy_blt_cat, -- collides with player ship
|
||||
damage = 0,
|
||||
|
||||
anim_speed = 2,
|
||||
loop_pause = 30 -- affected by animspeed
|
||||
})
|
||||
-->8
|
||||
-- upgrade options
|
||||
|
||||
-- sprite indexes for "sheen" animation
|
||||
sheen8x8 = split"2,54,55,56,57,58,59,60,61"
|
||||
-- all these return
|
||||
-- a [2] of rearm_t:
|
||||
--
|
||||
-- icon: sprite id
|
||||
-- hdr: title text
|
||||
-- body: text
|
||||
-- action: callback
|
||||
-- (method)
|
||||
|
||||
function powerup:draw()
|
||||
spr(self.sprites[max(1,
|
||||
((lframe<<16)\self.anim_speed)
|
||||
%(#self.sprites+self.loop_pause)
|
||||
-self.loop_pause
|
||||
+1)],
|
||||
self.x, self.y,
|
||||
self.width, self.height)
|
||||
end
|
||||
|
||||
repair = mknew(powerup.new{
|
||||
hurt = {
|
||||
x_off = -2,
|
||||
y_off = -2,
|
||||
width = 12,
|
||||
height = 12
|
||||
},
|
||||
x_off = 4,
|
||||
y_off = 0,
|
||||
sprites = sheen8x8,
|
||||
icon = 53,
|
||||
hitship = function(self, ship)
|
||||
if (ship ~= primary_ship) return false
|
||||
primary_ship.hp = min(primary_ship.maxhp, primary_ship.hp + 1)
|
||||
return true
|
||||
end,
|
||||
draw = function(self)
|
||||
spr(self.icon, self.x, self.y, self.width, self.height)
|
||||
powerup.draw(self)
|
||||
end
|
||||
})
|
||||
|
||||
function spawn_repair_at(x, y)
|
||||
repair.new():spawn_at(x, y)
|
||||
end
|
||||
|
||||
shield_upgrade = mknew(repair.new{
|
||||
icon=52
|
||||
})
|
||||
|
||||
function shield_upgrade:hitship(ship)
|
||||
if (ship ~= primary_ship) return false
|
||||
primary_ship.maxshield += 1
|
||||
return true
|
||||
end
|
||||
|
||||
function spawn_shield_upgrade_at(x, y)
|
||||
shield_upgrade.new():spawn_at(x,y)
|
||||
end
|
||||
|
||||
gun_swap = mknew(powerup.new{
|
||||
hurt = {
|
||||
x_off = -2,
|
||||
y_off = -2,
|
||||
width = 16,
|
||||
height = 16
|
||||
},
|
||||
-- gun = gun_type.new{}
|
||||
x_off = 6,
|
||||
y_off = 0,
|
||||
width = 2,
|
||||
height = 2,
|
||||
sprites = {64, 66, 68, 70, 72, 74, 76, 78},
|
||||
hitship = function(self, ship)
|
||||
if (ship ~= primary_ship) return false
|
||||
ship.main_gun = self.gun
|
||||
return true
|
||||
end,
|
||||
draw = function(self)
|
||||
powerup.draw(self)
|
||||
spr(self.gun.icon, self.x+2, self.y+2, 1, 1)
|
||||
end
|
||||
})
|
||||
|
||||
function spawn_main_gun_at(x, y, gunt)
|
||||
if (type(gunt)=="string") gunt=_ENV[gunt]
|
||||
local gun_p = gun_swap.new{
|
||||
gun = gunt.new()
|
||||
}
|
||||
gun_p:spawn_at(x, y)
|
||||
end
|
||||
|
||||
spec_gun_pl = {
|
||||
[1] = 2,
|
||||
[14] = 6,
|
||||
[2] = 14
|
||||
spec_gunt = {
|
||||
protron_gun_p,
|
||||
vulcan_gun_p,
|
||||
blast_gun,
|
||||
}
|
||||
|
||||
function spawn_spec_gun_at(x, y, gunt)
|
||||
if (type(gunt)=="string") gunt=_ENV[gunt]
|
||||
local gun_p = gun_swap.new{
|
||||
gun = gunt.new(),
|
||||
hitship = function(self, ship)
|
||||
if (ship ~= primary_ship) return false
|
||||
ship.special_gun = self.gun
|
||||
return true
|
||||
end,
|
||||
draw = function(self)
|
||||
pal(spec_gun_pl)
|
||||
powerup.draw(self)
|
||||
pal()
|
||||
spr(self.gun.icon, self.x+2, self.y+2, 1, 1)
|
||||
-- picks n random items from
|
||||
-- tbl; permutes tbl, selected
|
||||
-- items at end
|
||||
function pick(tbl, n)
|
||||
local ret, top={}, #tbl
|
||||
for x=top,top-n,-1 do
|
||||
local idx = 1+rnd(x)\1
|
||||
add(ret, tbl[idx])
|
||||
tbl[idx]=tbl[x]
|
||||
tbl[x]=ret[#ret]
|
||||
end
|
||||
return ret
|
||||
end
|
||||
|
||||
-- add a new gun
|
||||
function spec_gun_opts()
|
||||
return pick(spec_gunt, 2)
|
||||
end
|
||||
|
||||
-- major upgrades
|
||||
function big_opts()
|
||||
return {{
|
||||
icon=1,
|
||||
hdr="placeholder",
|
||||
body="placeholder",
|
||||
action = function() end,
|
||||
},
|
||||
{
|
||||
icon=1,
|
||||
hdr="placeholder",
|
||||
body="placeholder",
|
||||
action = function() end,
|
||||
}}
|
||||
end
|
||||
|
||||
-- ordinary upgrades
|
||||
function small_opts()
|
||||
return {{
|
||||
icon=1,
|
||||
hdr="placeholder",
|
||||
body="placeholder",
|
||||
action = function() end,
|
||||
},
|
||||
{
|
||||
icon=1,
|
||||
hdr="placeholder",
|
||||
body="placeholder",
|
||||
action = function() end,
|
||||
}}
|
||||
end
|
||||
|
||||
-->8
|
||||
-- rearm screen
|
||||
|
||||
rearm_mode = mknew{
|
||||
sel=1,
|
||||
bfm=1,
|
||||
crt_frm = 1,
|
||||
pos=-1,
|
||||
init=function(this)
|
||||
poke(0x5f5c, 255) --no btnp repeat
|
||||
rearm_mode.shuffle(this)
|
||||
end,
|
||||
}
|
||||
|
||||
crt={-91,-166,-2641,-1441,-23041,23295,-20491,24570}
|
||||
|
||||
function rearm_mode:glow_box(x0, y0, x1, y1, c, cf)
|
||||
for i,v in ipairs{c[1],c[2],c[1],0} do
|
||||
i -= 1
|
||||
rect(x0+i,y0+i,x1-i,y1-i,v)
|
||||
end
|
||||
fillp(crt[self.crt_frm&0xff])
|
||||
rectfill(x0+4, y0+4, x1-4, y1-4, cf)
|
||||
fillp()
|
||||
end
|
||||
|
||||
function easeoutbounce(t)
|
||||
local n1=7.5625
|
||||
local d1=2.75
|
||||
|
||||
if (t<1/d1) then
|
||||
return n1*t*t;
|
||||
elseif(t<2/d1) then
|
||||
t-=1.5/d1
|
||||
return n1*t*t+.75;
|
||||
elseif(t<2.5/d1) then
|
||||
t-=2.25/d1
|
||||
return n1*t*t+.9375;
|
||||
else
|
||||
t-=2.625/d1
|
||||
return n1*t*t+.984375;
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function rearm_mode:frame_col(hot)
|
||||
if (not hot) return {4,10}
|
||||
if (self.bfm<=16) return {14,7}
|
||||
return {2,8}
|
||||
end
|
||||
|
||||
function rearm_mode:draw_option(id)
|
||||
local rec = self.options[id]
|
||||
self:glow_box(0,0,55,100,self:frame_col(self.sel == id),1)
|
||||
spr(rec.icon,5, 5)
|
||||
print(rec.hdr, 13, 8, 7)
|
||||
print(rec.body, 5, 15, 6)
|
||||
end
|
||||
|
||||
function rearm_mode:pos_frac()
|
||||
local pos = self.pos
|
||||
if (not pos) return
|
||||
if (pos < 0) return 1-easeoutbounce(1+pos)
|
||||
if (pos > 0) return (1-pos)*(1-pos)
|
||||
return 0
|
||||
end
|
||||
|
||||
function rearm_mode:shuffle()
|
||||
-- these will be placeholders
|
||||
-- until the upgrade deck
|
||||
-- is a thing that exists
|
||||
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()
|
||||
drawgame_top()
|
||||
local frac = self:pos_frac()
|
||||
camera(frac * 55, 0)
|
||||
self:draw_option(1)
|
||||
camera(frac * -128 + (1-frac) * -56, 0)
|
||||
self:draw_option(2)
|
||||
camera(0, -28 * frac)
|
||||
self:glow_box(0,101,111,127,self:frame_col(self.sel < 0),1)
|
||||
spr(96,15,107,4,2)
|
||||
print("full ammo\nfull shield\n+50% health",54, 106, 6)
|
||||
end
|
||||
|
||||
function rearm_mode:update_pos()
|
||||
local pos = self.pos
|
||||
if (not pos) return
|
||||
if (pos == 0) then
|
||||
if (primary_ship.xp < primary_ship.xptarget) self.pos = 1
|
||||
xpwhoosh = nil
|
||||
return
|
||||
end
|
||||
if (pos < 0) pos = min(pos + 0x0.05, 0)
|
||||
if pos > 0 then
|
||||
pos -= 0x0.1
|
||||
if (pos <= 0) pos = 999
|
||||
end
|
||||
self.pos = pos
|
||||
end
|
||||
|
||||
function rearm_mode:update()
|
||||
self:update_pos()
|
||||
if self.pos > 1 then
|
||||
mode = game_mode
|
||||
return -- do not advance frame
|
||||
end
|
||||
local sel, bfm = self.sel, self.bfm
|
||||
if (btn(3) and sel > 0 or btn(2) and sel < 0) sel=-sel
|
||||
if (btn(0)) sel = 1
|
||||
if (btn(1)) sel = 2
|
||||
if (btn()&0xF ~= 0) and bfm >= 10 or bfm >= 30 then
|
||||
bfm = 1
|
||||
else
|
||||
bfm += 1
|
||||
end
|
||||
self.bfm = bfm
|
||||
|
||||
if primary_ship.xp < primary_ship.xptarget then
|
||||
sel = 0
|
||||
elseif btnp(4) or btnp(5) and self.pos == 0 then
|
||||
if sel < 0 then
|
||||
-- todo: sound: rearm
|
||||
primary_ship.shield = primary_ship.maxshield
|
||||
-- todo: rewrite for three guns
|
||||
local specs = primary_ship.special_guns
|
||||
if specs then
|
||||
specs[1].ammo = specs[1].maxammo
|
||||
if (specs[2]) specs[2].ammo = specs[2].maxammo
|
||||
end
|
||||
primary_ship.hp = min(primary_ship.maxhp, primary_ship.hp + primary_ship.maxhp/2)
|
||||
primary_ship.xp -= primary_ship.xptarget / 2
|
||||
else
|
||||
local c = self.options[sel]
|
||||
if c then
|
||||
-- todo: sound: upgrade
|
||||
c:action()
|
||||
primary_ship.xp -= primary_ship.xptarget
|
||||
primary_ship.xptarget += primary_ship.level * 0x0.0002
|
||||
primary_ship.level += 1
|
||||
if (primary_ship.xp >= primary_ship.xptarget) self:shuffle()
|
||||
end
|
||||
end
|
||||
}
|
||||
gun_p:spawn_at(x, y)
|
||||
end
|
||||
self.sel = sel
|
||||
end
|
||||
|
||||
__gfx__
|
||||
@ -1764,14 +1885,14 @@ __gfx__
|
||||
000000005666657576667650000000000b0000b000000000000000000000000000000000000dd0009092220200000000c111111d656667650000000000000000
|
||||
0000000056565066665656500000000000bbbb0000000000000000000000000000000000000000000090020000000000c111111d650650650000000000000000
|
||||
00000000565000566500065000000000b000000b000000000000000000000000000000000000000000a00a0000000000cddddddd650000650000000000000000
|
||||
000000000c00070006000700066007600000000000a0008000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0c000700ccd07cd06cd07cd06ccd7ccd000000000090008000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0d000d000d000d006cd06cd06ccd6ccd0000000000800a0000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
00000000000000000d000d000dd00dd0000000000080090000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
000000000c000c00060006000670066000000000000a080000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0c000c00c7d0cc7067d06cd067cd6ccd000000000009080000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
07000c000d0007007cd06c707ccd6c77000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
00000000000000000d0007000dd00d70000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
060007000600070006600770766c777c0000000000a0008000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
6cd07cd06cd07cd06ccd7ccd6ccd7ccd000000000090008000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0d000d006cd07cd06ccd7ccd6ccd7ccd0000000000800a0000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
000000000d000d000dd00dd0cdd1cdd0000000000080090000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0600060006000600066006607667766c00000000000a080000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
67d06c7067d06c70677d6cc7677d6cc7000000000009080000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0d00070067d06c7067cd6cc767cd6cc7000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
000000000d0007000dd007707dd1c771000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
00000000000000000000000000000000cccccccccccccccc77000000007700000000770000000077000000000000000000000000000000000000000000000000
|
||||
00000000000000000000000000000000c116611dc11ee11d70000000077000000007700000000770000000070000000000000000000000000000000000000000
|
||||
00000000000000000000000000000000c1611c1dc11ee11d00000000770000000077000000007700000000770000000700000000000000000000000000000000
|
||||
@ -1792,6 +1913,26 @@ c1111111111d0000c1111111111d0000c1111111111d0000c111eeee111d0000c11e2222e11d0000
|
||||
c1111111111d0000c1111111111d0000c1111111111d0000c1111111111d0000c111eeee111d0000c1ee2222ee1d0000ce22111122ed0000c2111111112d0000
|
||||
c1111111111d0000c1111111111d0000c1111111111d0000c1111111111d0000c1111111111d0000c111eeee111d0000ceee2222eeed0000c2221111222d0000
|
||||
cddddddddddd0000cddddddddddd0000cddddddddddd0000cddddddddddd0000cddddddddddd0000cddddddddddd0000cddddddddddd0000cddddddddddd0000
|
||||
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
04444400044444440000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
447777700477777a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
477aaa7a0477aaaa0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
47a0047a047a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
47a0447a047a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
47a4477a047a44400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
477777a00477777a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
477770000422aaaa2222000200000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
47a77700022ee0002eeee002e00022e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
47a4777002ea2e002e002e02ee022ee0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
47a0477a22ea2e002e002e02e2e2e2e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
47a0047a2e2222e02e222e02e02e02e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
47a0047a2eeeeeea2eeee002e02e02e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
0aa000aa2e7aa2ea2e00e002e02e02e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
000000002e0002e02e002e02e02e02e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
000000000e0000e00e000e00e00e00e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
__label__
|
||||
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007777777777777777
|
||||
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007666666666666665
|
||||
|
Reference in New Issue
Block a user