diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..3830f7b Binary files /dev/null and b/.DS_Store differ diff --git a/creative/balls.p8 b/creative/balls.p8 new file mode 100644 index 0000000..a702457 --- /dev/null +++ b/creative/balls.p8 @@ -0,0 +1,79 @@ +pico-8 cartridge // http://www.pico-8.com +version 34 +__lua__ +cls(rnd(8)) +v=0 +lv=0 +lh=0 +function _draw() + local t = time() + v+=t*4 + if v<10then + cls(13) + elseif v<10000 then + dither(8000-v*1, 13) + else + dither(8000, 15) + --v=0 + --lv=0 +--lh=0 +--cls(13) + end + + for i=-500, 500, 8 do + line(i+t*4,0,0,i+t*4, 15) + end + + for i=0, 30, 3.5 do + local r = sin((t+i*0.02)*0.1) --+ sin(i*0.1) + local x = 64+sin(t*0.5+0.06*i)*-29.9*r + local y = 64+sin(t+0.06*i)*-29.9*r + local z = x/18 + local c = 15--r%2 + circfill(x, y, 10-z, c) + end + + if(v>7000) then + lh+=1*5 + for i=0, 128, 2 do + line(128,i,128-lh+i,i, 13) + end + if v>8000 then + for i=0,128,2 do + line(0, 0, 0, i, 13) + end + end + end + +end +-->8 +--tools + +function dither(val, c) + for x=1,val do + pset(rnd(128),rnd(128),c) + end +end + +-- create a remap? +__gfx__ +00000000008008000080080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000008888000088880000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00700700008dd800008dd80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00077000008dd800008dd800000aa000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00077000088888800888888000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00700700088998800889988000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +000000000800e080080e008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000a00000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000030003000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000033333000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000003330000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000003330000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000003330000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000080800000606000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000888880006666600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000088800000666000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000008000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 diff --git a/creative/lines.p8 b/creative/lines.p8 new file mode 100644 index 0000000..10c0f4a --- /dev/null +++ b/creative/lines.p8 @@ -0,0 +1,53 @@ +pico-8 cartridge // http://www.pico-8.com +version 34 +__lua__ +cls(0) +v=0 +lv=0 +lh=0 +t=0 +stage = {a = 150, b = 3220} +function _draw() + t+=1 + --cls() + if(t8 +--tools + +function dither(val, c) + for x=1,val do + pset(rnd(128),rnd(128),c) + end +end + +-- create a remap? +__gfx__ +00000000008008000080080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000008888000088880000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00700700008dd800008dd80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00077000008dd800008dd800000aa000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00077000088888800888888000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00700700088998800889988000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +000000000800e080080e008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000a00000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000030003000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000033333000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000003330000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000003330000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000003330000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000080800000606000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000888880006666600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000088800000666000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000008000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 diff --git a/creative/patterns.p8 b/creative/patterns.p8 new file mode 100644 index 0000000..60920a2 --- /dev/null +++ b/creative/patterns.p8 @@ -0,0 +1,39 @@ +pico-8 cartridge // http://www.pico-8.com +version 33 +__lua__ +local box = + {x = 64, y = 64, + w = 14, h = 14, + } + +function _init() +end + +function _update() + box.x = 64 + sin(t()*0.5)*8 + box.y = 64 + cos(t()*2)*8 +end + +function _draw() + cls() + rect(box.x - 10, box.y - 10, box.x+10, box.y+10) + + fillp(0b1000011001100001) + line(0, 64, box.x, box.y, 9) + line(128,64, box.x, box.y, 10) + line(64, 0, box.x, box.y, 12) + line(64, 128, box.x, box.y, 13) + fillp() + + rectfill(box.x-box.w/2, box.y-box.h/2, box.x + box.w/2, box.y + box.h/2, 7) + +end + + +__gfx__ +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00700700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00700700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 diff --git a/creative/rotatingline.p8 b/creative/rotatingline.p8 new file mode 100644 index 0000000..1772d67 --- /dev/null +++ b/creative/rotatingline.p8 @@ -0,0 +1,23 @@ +pico-8 cartridge // http://www.pico-8.com +version 34 +__lua__ +t=0 +function _draw() + t+=1 + cls(1) + for i=0,10,3 do + local r = (sin(t*0.01)*5)+20 + local x1 = 64+sin(t*0.01)*r + local y1 = 64+cos(t*0.01)*r + local x2 = 64-sin(t*0.01)*r + local y2 = 64-cos(t*0.01)*r + line(x1,y1,x2,y2,15) + end +end +__gfx__ +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00700700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00700700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 diff --git a/flock.p8 b/flock.p8 new file mode 100644 index 0000000..91765e9 --- /dev/null +++ b/flock.p8 @@ -0,0 +1,50 @@ +pico-8 cartridge // http://www.pico-8.com +version 33 +__lua__ + +function _init() + flock = {} + for i=0,20,1 do + add_new_boid() + end +end + +function _draw() + cls() + for f in all(flock) do + f:draw() + end +end + +function _update() + for f in all(flock) do + f:update() + end +end +-->8 + +function add_new_boid() + add(flock, + { + pos = {x = 63, y = 63}, + vel = {x = rnd(0.2), y = -0.0001}, + acc = {x = 0, y = 0}, + draw = function(self) + circfill(self.pos.x, self.pos.y, 1, 2) + end, + update = function(self) + self.pos.x += self.vel.x + self.pos.y += self.vel.y + self.vel.x += self.acc.x + self.vel.y += self.vel.y + end + } + ) +end +__gfx__ +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00700700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00700700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 diff --git a/learn/interactivity.p8 b/learn/interactivity.p8 new file mode 100644 index 0000000..f3ece0d --- /dev/null +++ b/learn/interactivity.p8 @@ -0,0 +1,39 @@ +pico-8 cartridge // http://www.pico-8.com +version 33 +__lua__ +cls(7) + + +for i=0,25,1 do + pset(rnd(128),rnd(128),rnd(16)) +end + +function _update() + if btn(❎) then + for i=0,10,1 do + circfill(rnd(128),rnd(128), rnd(5),7) + end + end +end + +function _draw() + for g=0,200,1 do + local x=rnd(128) + local y=rnd(128) + local c=pget(x,y) + + if c!=7 then + circfill(x,y, 2, c) + end + + end + + +end +__gfx__ +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00700700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00700700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 diff --git a/learn/learn1_basics.p8 b/learn/learn1_basics.p8 new file mode 100644 index 0000000..eed3e65 --- /dev/null +++ b/learn/learn1_basics.p8 @@ -0,0 +1,37 @@ +pico-8 cartridge // http://www.pico-8.com +version 33 +__lua__ +local x,y + +function _init() + x,y = 60, 60 +end + +function _update() + if btn(➡️) then + x+=1 + end + if btn(⬅️) then + x-=1 + end + if btn(⬆️) then + y-=1 + end + if btn(⬇️) then + y+=1 + end +end + +function _draw() + cls() + rect(0,0,127,127,1) + pset(x,y,3) +end + +__gfx__ +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00700700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00700700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 diff --git a/learn/loops.p8 b/learn/loops.p8 new file mode 100644 index 0000000..b8b9172 --- /dev/null +++ b/learn/loops.p8 @@ -0,0 +1,30 @@ +pico-8 cartridge // http://www.pico-8.com +version 33 +__lua__ +cls(7) + + +for i=0,25,1 do + pset(rnd(128),rnd(128),rnd(15) + 1) +end + + +function _draw() + for g=0,200,1 do + local x=rnd(128) + local y=rnd(128) + local c=pget(x,y) + + if c!=7 then + circfill(x,y, 2, c) + end + + end +end +__gfx__ +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00700700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00700700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 diff --git a/learn/sincos.p8 b/learn/sincos.p8 new file mode 100644 index 0000000..b7141a3 --- /dev/null +++ b/learn/sincos.p8 @@ -0,0 +1,51 @@ +pico-8 cartridge // http://www.pico-8.com +version 33 +__lua__ + cls(7) + + +for i=0,25,1 do + pset(rnd(128),rnd(128),rnd(16)) +end + +function _update() + if btn(❎) then + for i=0,10,1 do + circfill(rnd(128),rnd(128), rnd(5),7) + end + end +end + +function _draw() + for g=0,60,1 do + local x=rnd(128) + local y=rnd(128) + local c=pget(x,y) + + if c!=7 then + local n_col + local n_count = 0 + for arc=0,.875,.125 do + n_col = pget(sin(arc)+x+.5, cos(arc)+y+.5) + if n_col == c then + n_count+=1 + end + end + if n_count>7 then + print("░", x - 3, y+rnd(4), c) + else + circfill(x,y, 1 + n_count/3, c) + end + end + + end + + +end +__gfx__ +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00700700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00700700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 diff --git a/media/balls_2.gif b/media/balls_2.gif new file mode 100644 index 0000000..7bbf9b0 Binary files /dev/null and b/media/balls_2.gif differ diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..21cc680 --- /dev/null +++ b/readme.md @@ -0,0 +1,3 @@ +# Brin's Pico8 Stash +![balls spinning around weee](media/balls_2.gif) +My carts. Feel free to fork, but god help you trying to untangle this code. diff --git a/rogue.p8 b/rogue.p8 new file mode 100644 index 0000000..b9a6ea4 --- /dev/null +++ b/rogue.p8 @@ -0,0 +1,237 @@ +pico-8 cartridge // http://www.pico-8.com +version 34 +__lua__ +function _init() + t=0 + p_a={224,225,226,227} + _upd=update_game + _drw=draw_game + startgame() +end + +function _update() + t+=1 + _upd() +end + +function _draw() + _drw() +end + + +function startgame() + p_x=1 p_y=4 + p_ox=0 p_oy=0 +end + + +-->8 +-- updates + +function update_game() + if btnp(⬅️) then + p_x-=1 + p_ox=8 + _upd=update_pturn + end + if btnp(➡️) then + p_x+=1 + p_ox=-8 + _upd=update_pturn + end + if btnp(⬆️) then + p_y-=1 + p_oy=8 + _upd=update_pturn + end + if btnp(⬇️) then + p_y+=1 + p_oy=-8 + _upd=update_pturn + end +end + +function update_pturn() + p_moving=true + p_ox=tow(p_ox,0,2) + p_oy=tow(p_oy,0,2) + + if p_ox==0 and p_oy==0 then + _upd=update_game + end +end + +function update_gameover() +end +-->8 +-- draws +function draw_game() + cls(0) + map() + drawspr(anim(p_a),p_x*8+p_ox,p_y*8+p_oy,9) + +end + +function draw_gameover() +end +-->8 +--tools +--returns the current frame from +--a set of animation array +function anim(a) + local spd=4 + return a[flr((t/spd)%#a+1)] +end + +function drawspr(_spr,_x,_y,_c) + palt(0, false) + pal(6,_c) + spr(_spr,_x,_y) + pal() +end + +--moves a towards b at rate +function tow(a,b,r) + if a+rb then return a-r end + return b +end + +__gfx__ +00000000000000006666606066666060000000000000000000000000000000000000000000000000000000000000000000000000000000009000000055555550 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000099000000000000 +00700700000000006066066060660660000000000000000000000000000000000000000000000000000000000000000000000000000000009099099005500000 +00077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009000099005505000 +00077000000000006606666066066660000000000000000000000000000000000000000000000000000000000000000000000000000000009099099005505500 +00700700000500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009099000005505000 +00000000000000006066606060666060000000000000000000000000000000000000000000000000000000000000000000000000000000009099099005505500 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +06666600000000000000000000666600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +60000060066666000000000006000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +60660060600000600666666006066060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +60606060606600606000000606060660000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +60666600606060606066000606066600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +60000000606666006066666006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +06666660066666600666666600666660000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000060600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +06060000006060000666600000606000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +66660000066660000060666006666000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +06066600006066600066666000606660000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +06666600006666600600000006666660000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +60000000060000006606600066066000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +60660000666660006606600066066000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +60060000660060000066000000606000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +__map__ +0202020202020202020202020200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +0202020101010101010202020200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +0202010101010101010102020200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +0202010101020101010202020200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +020f01010102010101020e020200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +0202020202020202010101020200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +0202020202020202020202020200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +0202020202020202020202020200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 diff --git a/spaceshooter.p8 b/spaceshooter.p8 new file mode 100644 index 0000000..005df61 --- /dev/null +++ b/spaceshooter.p8 @@ -0,0 +1,269 @@ +pico-8 cartridge // http://www.pico-8.com +version 34 +__lua__ +function _init() + t=0 + + ship = { + h=4, + sp=1, + x = 63, + y = 100, + p = 0, + imm = false, + t = 0, + box = {x1=0, y1=0, + x2=7, x2=7} + } + + bullets = {} + enemies = {} + expl = {} + stars = {} + + for i=1,128 do + add(stars, { + x=rnd(128), + y=rnd(128), + s=rnd(2)+1 + }) + end + + + start() +end + +function start() + _update = update_game + _draw = draw_game +end + +function game_over() + _update = update_over + _draw = draw_over +end + +function update_over() +end +function draw_over() + cls() + print("game_over!", 40, 50,4) +end + + +function explode(_x,_y) + add(expl, {x=_x,y=_y,t=0}) +end + +function fire() + local b = { + sp=3, + x=ship.x, + y=ship.y, + dx=0, + dy=-3, + box = {x1=2, y1=2, + x2=5, x2=5} + } + add(bullets,b) +end + +function draw_game() + cls() + + for st in all(stars) do + pset(st.x, st.y, 6) + end + --bullets + for b in all(bullets) do + spr(b.sp, b.x, b.y) + --draw_coll(b) + end + + for ex in all(expl) do + circ(ex.x,ex.y,ex.t/3,8+ex.t%3) + end + + --enemies + for e in all(enemies) do + spr(e.sp, e.x, e.y) + --draw_coll(e) + end + --ship + if not ship.imm or t%8<4 then + spr(ship.sp,ship.x,ship.y) + end + --draw_coll(ship) + + -- ui drawing + for i=1,4 do + if i<=ship.h then + spr(33,80+6*i,3) + else + spr(34,80+6*i,3) + end + end + +end + +function update_game() + t=t+1 + if ship.imm then + ship.t += 1 + if ship.t>30 then + ship.imm=false + ship.t=0 + end + end + + for st in all(stars) do + st.y += st.s + if st.y >= 128 then + st.y = 0 + st.x = rnd(128) + end + end + + for ex in all(expl) do + ex.t+=1 + if ex.t == 13 then + del(expl, ex) + end + end + + --enemy logic + if #enemies <= 0 then + respawn() + end + for e in all(enemies) do + e.m_y +=1.2 + e.x = e.r*sin(e.d*t/50) + e.m_x + e.y = e.r*cos(t/50) + e.m_y + if coll(ship,e) and not + ship.imm then + ship.imm = true + ship.h -= 1 + ship.y += 4 + if ship.h <= 0 then + game_over() + end + + end + + if e.y > 150 then + del(enemies,e) + end + + end + + for b in all(bullets) do + b.x+=b.dx + b.y+=b.dy + if b.x < 0 or b.x > 128 or + b.y < 0 or b.y > 128 then + del(bullets, b) + end + for e in all(enemies) do + if coll(b,e) then + del(enemies,e) + ship.p+=1 + explode(e.x,e.y) + end + end + + end + + if(t%8<4) then + ship.sp=1 + else + ship.sp=2 + end + + local shooting = false + if btn(❎) then + fire() + shooting = true + ship.y+=0.5 + end + + if not shooting then + if btn(0) then ship.x-=1 end + if btn(1) then ship.x+=1 end + if btn(2) then ship.y-=1 end + if btn(3) then ship.y+=1 end + end + +end +-->8 +function coll(a,b) + --todo + local box_a = abs_box(a) + local box_b = abs_box(b) + + if box_a.x1 > box_b.x2 or + box_a.y1 > box_b.y2 or + box_b.x1 > box_a.x2 or + box_b.y1 > box_b.y2 then + return false + else + return true + end +end + +function draw_coll(o) + local o_box = abs_box(o) + rect(o_box.x1, o_box.y1, + o_box.x2, o_box.y2, + 11) +end + +function abs_box(s) + -- returns the position of the + -- collision box + local box = {} + box.x1 = s.box.x1 + s.x + box.y1 = s.box.y1 + s.y + box.x2 = s.box.x2 + s.x + box.y2 = s.box.x2 + s.y + return box +end +-->8 +function respawn() + local n = flr(rnd(9))+2 + for i=1,4 do + local d = -1 + if rnd(1)<0.5 then d=1 end + add(enemies, { + sp=17, + m_x=10+i*16, + m_y=i*4-10, + d=d, + x=-32, + y=-32, + r=10, + box = {x1=0, y1=0, + x2=7, x2=7} + }) + end +end +__gfx__ +00000000008008000080080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000008888000088880000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00700700008dd800008dd80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00077000008dd800008dd800000aa000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00077000088888800888888000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00700700088998800889988000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +000000000800e080080e008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000a00000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000030003000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000033333000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000003330000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000003330000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000003330000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000080800000606000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000888880006666600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000088800000666000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000008000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000