2024-12-24 18:10:17 -08:00
|
|
|
pico-8 cartridge // http://www.pico-8.com
|
|
|
|
version 42
|
|
|
|
__lua__
|
|
|
|
-- vacuum gambit
|
|
|
|
-- by kistaro windrider
|
|
|
|
|
2024-12-26 12:32:31 -08:00
|
|
|
-- stdlib
|
|
|
|
|
|
|
|
-- generate standard "overlay"
|
|
|
|
-- constructor for type tt.
|
|
|
|
-- if tt.init is defined, generated
|
|
|
|
-- new calls tt.init(ret) after
|
|
|
|
-- ret is definitely not nil,
|
|
|
|
-- before calling setmetatable.
|
|
|
|
-- use to initialize mutables.
|
|
|
|
--
|
|
|
|
-- if there was a previous new,
|
|
|
|
-- it is invoked on the new
|
|
|
|
-- object *after* more, because
|
|
|
|
-- this works better with the
|
|
|
|
-- `more` impls i use.
|
|
|
|
function mknew(tt)
|
|
|
|
local mt,oldnew,more = {__index=tt},tt.new,rawget(tt, "init")
|
|
|
|
tt.new=function(ret)
|
|
|
|
if(not ret) ret = {}
|
|
|
|
if(more) more(ret)
|
|
|
|
if(oldnew) oldnew(ret)
|
|
|
|
setmetatable(ret, mt)
|
|
|
|
return ret
|
|
|
|
end
|
|
|
|
return tt
|
|
|
|
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
|
|
|
|
|
|
|
|
-->8
|
|
|
|
-- entry points
|
2024-12-24 18:10:17 -08:00
|
|
|
function _draw()
|
|
|
|
cls()
|
2024-12-24 19:23:14 -08:00
|
|
|
draw_hud_placeholder()
|
2024-12-26 16:19:52 -08:00
|
|
|
-- draw_static()
|
|
|
|
left_pane:draw()
|
|
|
|
right_pane:draw()
|
|
|
|
rearm_pane_instance:draw()
|
|
|
|
end
|
|
|
|
|
|
|
|
function draw_static()
|
2024-12-24 19:23:14 -08:00
|
|
|
draw_weap_opt(0,0,frame_col(item==1),1,"hull","\n +1\n max\nhealth")
|
|
|
|
draw_weap_opt(56,0,frame_col(item==2),2,"vulc"," rate\n\n faster\n firing\n rate")
|
|
|
|
draw_rearm(frame_col(item<0))
|
2024-12-24 19:04:07 -08:00
|
|
|
end
|
|
|
|
|
2024-12-24 19:23:14 -08:00
|
|
|
function _init()
|
|
|
|
item=1
|
|
|
|
bfm=1
|
2024-12-26 16:19:52 -08:00
|
|
|
left_pane = weapon_pane.new{
|
|
|
|
|
|
|
|
}
|
|
|
|
right_pane = weapon_pane.new{
|
|
|
|
is_left=false,
|
|
|
|
s = 2,
|
|
|
|
hdr = "vulc",
|
|
|
|
body = " rate\n\n faster\n firing\n rate",
|
|
|
|
hot = function() return item == 2 end}
|
|
|
|
rearm_pane_instance = rearm_pane.new{hot=function() return item < 0 end}
|
2024-12-24 19:23:14 -08:00
|
|
|
end
|
|
|
|
|
|
|
|
function _update()
|
|
|
|
if (btn(3) and item > 0 or btn(2) and item < 0) item = -item
|
|
|
|
if (btn(0)) item = 1
|
|
|
|
if (btn(1)) item = 2
|
|
|
|
if (btn() & 0xF ~= 0) and bfm >= 10 or bfm >= 30 then
|
|
|
|
bfm = 1
|
|
|
|
else
|
|
|
|
bfm += 1
|
|
|
|
end
|
2024-12-26 16:19:52 -08:00
|
|
|
|
|
|
|
if btnp(4) then
|
|
|
|
left_pane.pos = 1
|
|
|
|
right_pane.pos = 1
|
|
|
|
rearm_pane_instance.pos = 1
|
|
|
|
end
|
|
|
|
|
|
|
|
if btnp(5) then
|
|
|
|
left_pane.pos = -1
|
|
|
|
right_pane.pos = -1
|
|
|
|
rearm_pane_instance.pos = -1
|
|
|
|
end
|
|
|
|
|
|
|
|
left_pane:update()
|
|
|
|
right_pane:update()
|
|
|
|
rearm_pane_instance:update()
|
2024-12-24 19:23:14 -08:00
|
|
|
end
|
2024-12-24 18:10:48 -08:00
|
|
|
|
2024-12-24 19:23:14 -08:00
|
|
|
function draw_hud_placeholder()
|
2024-12-24 18:10:17 -08:00
|
|
|
rectfill(112, 0, 127, 127,0x56)
|
|
|
|
rect(112,0,127,127,7)
|
|
|
|
line(127,1,127,127,5)
|
|
|
|
line(113,127)
|
|
|
|
end
|
|
|
|
|
2024-12-26 12:32:31 -08:00
|
|
|
-->8
|
|
|
|
-- rearm pane drawing
|
|
|
|
|
2024-12-24 19:04:07 -08:00
|
|
|
function glow_box(x0, y0, x1, y1, c, cf)
|
|
|
|
rect(x0, y0, x1, y1, c[1])
|
|
|
|
rect(x0+1, y0+1, x1-1, y1-1, c[2])
|
|
|
|
rect(x0+2, y0+2, x1-2, y1-2, c[1])
|
2024-12-24 18:10:17 -08:00
|
|
|
if cf then
|
2024-12-24 19:04:07 -08:00
|
|
|
-- todo: animate "dot crawl" background
|
2024-12-24 18:10:17 -08:00
|
|
|
fillp(…)
|
|
|
|
rectfill(x0+3, y0+3, x1-3, y1-3, cf)
|
|
|
|
fillp()
|
|
|
|
end
|
|
|
|
end
|
2024-12-24 18:10:48 -08:00
|
|
|
|
2024-12-24 19:04:07 -08:00
|
|
|
function frame_col(hot)
|
|
|
|
if (not hot) return {4,10}
|
2024-12-24 19:23:14 -08:00
|
|
|
if (bfm<=16) return {14,7}
|
2024-12-24 19:04:07 -08:00
|
|
|
return {2,8}
|
|
|
|
end
|
|
|
|
|
|
|
|
function draw_weap_opt(x, y, c, s, hdr, body)
|
|
|
|
camera(-x,-y)
|
|
|
|
glow_box(0,0,55,100,c,1)
|
|
|
|
spr(s,5, 5)
|
|
|
|
print(hdr, 13, 8, 7)
|
|
|
|
print(body, 5, 15, 6)
|
|
|
|
camera()
|
|
|
|
end
|
|
|
|
|
|
|
|
function draw_rearm(c)
|
|
|
|
glow_box(0,101,111,127,c,1)
|
2024-12-24 19:23:14 -08:00
|
|
|
spr(5,15,107,4,2)
|
|
|
|
print("full ammo\nfull shield\n+50% health",54, 106, 6)
|
2024-12-24 19:04:07 -08:00
|
|
|
end
|
|
|
|
|
2024-12-26 12:32:31 -08:00
|
|
|
-->8
|
|
|
|
-- rearm pane objects
|
|
|
|
easing_pane = mknew{
|
2024-12-26 16:19:52 -08:00
|
|
|
-- to enter: pos = -1; to exit: pos = 1
|
2024-12-26 12:32:31 -08:00
|
|
|
-- runs for 16 frames
|
|
|
|
}
|
|
|
|
|
2024-12-26 16:19:52 -08:00
|
|
|
function easing_pane:frac()
|
|
|
|
local pos = self.pos
|
|
|
|
if (not pos) return
|
|
|
|
if (pos < 0) return easeoutbounce(1+pos)
|
|
|
|
if (pos > 0) return easeoutbounce(1-pos)
|
|
|
|
return 1
|
|
|
|
end
|
|
|
|
|
2024-12-26 12:32:31 -08:00
|
|
|
function easing_pane:update()
|
|
|
|
local pos = self.pos
|
|
|
|
if (not pos or pos == 0) return
|
|
|
|
-- increment is 0x0.1 -- 1/16th of pos
|
|
|
|
if (pos < 0) pos = min(pos + 0x0.1, 0)
|
|
|
|
if pos > 0 then
|
|
|
|
pos -= 0x0.1
|
|
|
|
if (pos <= 0) pos = nil
|
|
|
|
end
|
|
|
|
self.pos = pos
|
|
|
|
end
|
|
|
|
|
|
|
|
weapon_pane = mknew(easing_pane.new{
|
|
|
|
is_left = true,
|
|
|
|
s = 1,
|
|
|
|
hdr = "hull",
|
|
|
|
body = "\n +1\n max\nhealth",
|
|
|
|
hot = function() return item == 1 end,
|
|
|
|
})
|
|
|
|
|
|
|
|
function weapon_pane:draw()
|
2024-12-26 16:19:52 -08:00
|
|
|
local frac, is_left = self:frac(), self.is_left
|
|
|
|
if (not frac) return
|
2024-12-26 12:32:31 -08:00
|
|
|
camera(
|
|
|
|
frac * (is_left and 55 or 0) + (1-frac) * (is_left and 0 or -56),
|
|
|
|
frac * 55)
|
2024-12-26 16:19:52 -08:00
|
|
|
glow_box(0,0,55,100,frame_col(self:hot()),1)
|
2024-12-26 12:32:31 -08:00
|
|
|
spr(self.s,5, 5)
|
|
|
|
print(self.hdr, 13, 8, 7)
|
|
|
|
print(self.body, 5, 15, 6)
|
|
|
|
camera()
|
|
|
|
end
|
|
|
|
|
|
|
|
rearm_pane = mknew(easing_pane.new{})
|
|
|
|
|
2024-12-26 16:19:52 -08:00
|
|
|
function rearm_pane:draw()
|
|
|
|
local frac = self:frac()
|
|
|
|
if (not frac) return
|
|
|
|
camera(0, 28 * frac-1)
|
|
|
|
glow_box(0,101,111,127,frame_col(self:hot()),1)
|
|
|
|
spr(5,15,107,4,2)
|
|
|
|
print("full ammo\nfull shield\n+50% health",54, 106, 6)
|
|
|
|
camera()
|
|
|
|
end
|
2024-12-26 12:32:31 -08:00
|
|
|
|
2024-12-24 19:04:07 -08:00
|
|
|
__gfx__
|
|
|
|
000000000b00000000000a0007700770000aa0000444440004444444000000000000000000000000000000000000000000000000000000000000000000000000
|
|
|
|
00000000bba80880000008000aa00aa00a0880a0447777700477777a000000000000000000000000000000000000000000000000000000000000000000000000
|
|
|
|
007007000aaa28780a0000000990099008000080477aaa7a0477aaaa000000000000000000000000000000000000000000000000000000000000000000000000
|
|
|
|
0007000008a8887808000000099009900080080047a0047a047a0000000000000000000000000000000000000000000000000000000000000000000000000000
|
|
|
|
00007000088888820000a000088008800000000047a0447a047a0000000000000000000000000000000000000000000000000000000000000000000000000000
|
|
|
|
00700700008888200000800008800880a000000a47a4477a047a4440000000000000000000000000000000000000000000000000000000000000000000000000
|
|
|
|
000000000008820000a0000008800880080aa080477777a00477777a000000000000000000000000000000000000000000000000000000000000000000000000
|
|
|
|
0000000000002000008000000880088000088000477770000422aaaa222200020000020000000000000000000000000000000000000000000000000000000000
|
|
|
|
000000000000000000000000000000000000000047a77700022ee0002eeee002e00022e000000000000000000000000000000000000000000000000000000000
|
|
|
|
000000000000000000000000000000000000000047a4777002ea2e002e002e02ee022ee000000000000000000000000000000000000000000000000000000000
|
|
|
|
000000000000000000000000000000000000000047a0477a22ea2e002e002e02e2e2e2e000000000000000000000000000000000000000000000000000000000
|
|
|
|
000000000000000000000000000000000000000047a0047a2e2222e02e222e02e02e02e000000000000000000000000000000000000000000000000000000000
|
|
|
|
000000000000000000000000000000000000000047a0047a2eeeeeea2eeee002e02e02e000000000000000000000000000000000000000000000000000000000
|
|
|
|
00000000000000000000000000000000000000000aa000aa2e7aa2ea2e00e002e02e02e000000000000000000000000000000000000000000000000000000000
|
|
|
|
0000000000000000000000000000000000000000000000002e0002e02e002e02e02e02e000000000000000000000000000000000000000000000000000000000
|
|
|
|
0000000000000000000000000000000000000000000000000e0000e00e000e00e00e00e000000000000000000000000000000000000000000000000000000000
|