Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
127 changes: 127 additions & 0 deletions carts/game2.p8
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
pico-8 cartridge // http://www.pico-8.com
version 18
__lua__
-- game 2
-- by matt phelps
-- == main methods ==
function _init()

end

function _update()
move_ship()
update_particles()
end

function _draw()
-- space
draw_space()
-- ship
draw_ship()
-- particles
draw_particles()

-- test
circfill(20,20,1,10)
circ(30,20,1,10)
circfill(20,30,2,10)
circ(30,30,2,10)
print(debug_str)
end


-->8
-- == global config ==
c = {
black = 0, blue = 1, maroon = 2,
green = 3, brown = 4, dark_gray = 5,
light_gray = 6, white = 7,
red = 8, orange = 9, yellow = 10,
lime = 11, light_blue = 12,
lavender = 13, pink = 14, tan = 15
}

-->8
-- == space ==
function draw_space()
cls(c['blue'])
end
-->8
-- == the ship ==
---- conf
sh = {
x = 40,
y = 40
}
---- updates
function move_ship()
local dx, dy
dx = {0,0}
dy = {0,0}
if btn(0) then sh.x+=2 dx = {dx[1]-1,dx[2]-3} dy = {dy[1]+1,dy[2]-1} end
if btn(1) then sh.x-=2 dx = {dx[1]+3,dx[2]+1} dy = {dy[1]+1,dy[2]-1} end
if btn(2) then sh.y+=2 dx = {dx[1]+1,dx[2]-1} dy = {dy[1]-1,dy[1]-3} end
if btn(3) then sh.y-=2 dx = {dx[1]+1,dx[2]-1} dy = {dy[1]+3,dy[2]+1} end
if btn(0) or btn(1) or btn(2) or btn(3) then
debug_str = dx[1] .. ' '.. dx[2] .. ',' .. dy[1] .. ' '..dy[2]
--an example passing a table for the color (flames?)
for i=1,10 do
add_new_dust(sh.x,sh.y,
dx[1]-rnd(abs(dx[1]-dx[2])),dy[1]-rnd(abs(dy[1]-dy[2])), -- dx, dy
rnd(20)+10,rnd(1)+1, -- life, rad
0, 0.8, -- grav, perc
flame_sequence)
end
end
end
---- draws
function draw_ship()
rect(sh.x-3,sh.y-3,sh.x+3,sh.y+3,c['orange'])
end

-->8
-- == particles ==
---- conf
dust = {}
flame_sequence = {7,7,7,7,7,7,6,6,6,6,6,5,5,9,9,10,10,10,10,10}
---- updates
function update_particles()
for d in all(dust) do d:update() end
end
---- draws
function draw_particles()
for d in all(dust) do d:draw() end
end

-->8
-- == ext helper func ==
local debug_str = ''
-- sign
function sign(x) return x>0 and 1 or x<0 and -1 or 0 end
-- CREDIT: DocRobs (https://www.lexaloffle.com/bbs/?pid=58211)
-- _x coordinate of dust
-- _y coordinate of dust
-- _dx x velocity
-- _dy y velocity
-- _l lifespan
-- _s starting radius
-- _g gravity
-- _p percentage shrink
-- _f col or table for fade
function add_new_dust(_x,_y,_dx,_dy,_l,_s,_g,_p,_f)
add(dust, {
fade=_f,x=_x,y=_y,dx=_dx,dy=_dy,life=_l,orig_life=_l,rad=_s,col=0,grav=_g,p=_p,draw=function(self)
pal()palt()circfill(self.x,self.y,self.rad,self.col)
end,update=function(self)
self.x+=self.dx self.y+=self.dy
self.dy+=self.grav self.rad*=self.p self.life-=1
if type(self.fade)=="table"then self.col=self.fade[flr(#self.fade*(self.life/self.orig_life))+1]else self.col=self.fade end
if self.life<0then del(dust,self)end end})
end
__gfx__
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00700700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00700700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
39 changes: 39 additions & 0 deletions carts/planet.p8
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
pico-8 cartridge // http://www.pico-8.com
version 18
__lua__
-- planet tests
-- by matt phelps
-- == main methods ==
function _init()

end

function _update()

end

function _draw()

end


-->8
-- == global config ==
c = {
black = 0, blue = 1, maroon = 2,
green = 3, brown = 4, dark_gray = 5,
light_gray = 6, white = 7,
red = 8, orange = 9, yellow = 10,
lime = 11, light_blue = 12,
lavender = 13, pink = 14, tan = 15
}



__gfx__
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00700700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00700700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
82 changes: 82 additions & 0 deletions carts/rocket.p8
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
pico-8 cartridge // http://www.pico-8.com
version 18
__lua__
-- planet tests
-- by matt phelps
-- == main methods ==
function _init()

end

function _update()
if (btn(0)) then center.angle += 0.02 end
if (btn(1)) then center.angle -= 0.02 end
if (btn(3)) then -- speed up
center.speed = min(20,center.speed+center.acc)
else -- slow down
center.speed = max(0,center.speed-center.decel)
end
center.x = (center.x + center.speed*cos(center.angle))%128
center.y = (center.y + center.speed*sin(center.angle))%128
end

function _draw()
cls(3)
draw_rocket()
print('speed: '..center.speed,1,1,c['lime'])
end


-->8
-- == global config ==
c = {
black = 0, blue = 1, maroon = 2,
green = 3, brown = 4, dark_gray = 5,
light_gray = 6, white = 7,
red = 8, orange = 9, yellow = 10,
lime = 11, light_blue = 12,
lavender = 13, pink = 14, tan = 15
}
function x(r)
if r == nil or r.r == nil or r.a == nil then return nil end
return r.r*cos(center.angle+r.a)
end
function y(r)
if r == nil or r.r == nil or r.a == nil then return nil end
return r.r*sin(center.angle+r.a)
end

center = {x=50,y=50,angle=0,speed=0,acc=2,decel=.5}
rock = {
{ r = 9, a = 0 },
{ r = 8, a = 0.35 },
{ r = 0, a = 0.5 },
{ r = 8, a = 0.65 },
{ r = 9, a = 0 },
}
-->8
-- == rocket ==
function draw_rocket()
-- center
pset(center.x,center.y,c['black'])
color(c['black'])
local r1 = rock[1]
line(center.x+x(r1),center.y+y(r1),
center.x+x(r1),center.y+y(r1))
for r in all(rock) do
line(center.x+x(r),
center.y+y(r))
end
end
-->8
-- == helper func ==
function btw(a,b,c)
return a >= b and a <= c
end
__gfx__
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00700700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00700700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
Loading