Skip to content

Commit

Permalink
creative changes, rogue tutorial goes on
Browse files Browse the repository at this point in the history
  • Loading branch information
Brin-o committed Dec 22, 2021
1 parent 3a6cc77 commit 258b139
Show file tree
Hide file tree
Showing 5 changed files with 120 additions and 48 deletions.
2 changes: 1 addition & 1 deletion creative/balls.p8
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function _draw()

end
-->8
--tools
--creative tools

function dither(val, c)
for x=1,val do
Expand Down
39 changes: 39 additions & 0 deletions creative/boxes.p8
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
pico-8 cartridge // http://www.pico-8.com
version 34
__lua__
function _init()
t=0
c=0
end

function _update60()
t+=1
end

function _draw()
cls()
c += sin(time()*0.001)*10
c = min(c, 30)
h=sin(t*0.01)*9.9
for i=0,128,8 do
local w=sin((t+i*0.7)*0.01)*4.9
for p=0,64,12 do
rect_c(i+p,i-p,c+w,c+w,i)
rect_c(i-p,i+p,c+w,c+w,i)
end
end
end
-->8
--tools

--draw a cnetered rect
function rect_c(x,y,w,h,c)
rect(x-w/2,y-h/2,x+w/2,y+h/2,c)
end
__gfx__
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00700700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00700700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
15 changes: 10 additions & 5 deletions creative/lines.p8
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,24 @@ v=0
lv=0
lh=0
t=0
stage = {a = 150, b = 3220}
stage = {a = 150, b = 300}
r=0
function _draw()
dither(5000, 0)
t+=1
--cls()
if(t<stage.a)then
for i=0,128,3 do
line(i,0 , i, t+sin(time()+i*0.2)*10, 15)
line(i,0,i,t+sin(time()+i*0.2)*10, 15)
end
elseif(t<stage.b) then
--if(t==stage.a) then t=0 end
circfill(64,64,sin(t)*100,3)
for i=0,128,3 do
line(0, i, t-155+sin(time()+i*0.2)*10,i,14)
end
else
t=0
end
print(t, 0,0,2)
print(t,0,0,11)
end
-->8
--tools
Expand Down
21 changes: 13 additions & 8 deletions creative/rotatingline.p8
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,19 @@ __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)
cls()
--pogruntaj kaj s tem??
for i=0,48,4 do
local ti= t+i
local s = min(t, 20)
local v = min(t/3,100)
local r = s+sin(ti*0.01)*v
local x1 = 64+sin(ti*0.01)*r
local y1 = 64+cos(ti*0.01)*r
local x2 = 64-sin(ti*0.01)*r
local y2 = 64-cos(ti*0.01)*r
line(x1,y1+30,x2,y2+30,15)
line(x1,y1-30,x2,y2-30,14)
end
end
__gfx__
Expand Down
91 changes: 57 additions & 34 deletions rogue.p8
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@ __lua__
function _init()
t=0
p_a={224,225,226,227}

dirx={-1,1,0,0}
diry={0,0,-1,1}
startgame()

_upd=update_game
_drw=draw_game
startgame()
end

function _update()
function _update60()
t+=1
_upd()
end
Expand All @@ -20,43 +24,44 @@ end


function startgame()
p_x=1 p_y=4
p_ox=0 p_oy=0
p_x,p_y=1,4 --position
p_ox,p_oy=0,0 --anim offset
p_sox,p_soy=0,0 --starting offset
p_t=0
p_flip=false
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
for i=0,3 do
if btnp(i) then
local dx,dy=dirx[i+1],diry[i+1]
p_x+=dx
p_y+=dy
--flipping
--if dx<0 then p_flip=true
--elseif dx>0 then p_flip=false
--end

p_sox,p_soy=-dx*8,-dy*8
p_ox,p_oy=p_sox,p_soy
_upd=update_pturn
return
end
end
end

function update_pturn()
p_moving=true
p_ox=tow(p_ox,0,2)
p_oy=tow(p_oy,0,2)
p_t=min(p_t+0.15, 1) --gets p_t+0.1 or 1
p_ox=p_sox*(1-p_t)
p_oy=p_soy*(1-p_t)


if p_ox==0 and p_oy==0 then
p_t=0
_upd=update_game
end
end
Expand All @@ -68,7 +73,7 @@ end
function draw_game()
cls(0)
map()
drawspr(anim(p_a),p_x*8+p_ox,p_y*8+p_oy,9)
drawspr(anim(p_a),p_x*8+p_ox,p_y*8+p_oy,9,p_flip)

end

Expand All @@ -79,14 +84,14 @@ end
--returns the current frame from
--a set of animation array
function anim(a)
local spd=4
local spd=6
return a[flr((t/spd)%#a+1)]
end

function drawspr(_spr,_x,_y,_c)
function drawspr(_spr,_x,_y,_c,_flip)
palt(0, false)
pal(6,_c)
spr(_spr,_x,_y)
spr(_spr,_x,_y,1,1,_flip)
pal()
end

Expand All @@ -97,14 +102,29 @@ function tow(a,b,r)
return b
end

-->8
--gameplay
function moveplayer(dx, dy)
local dx,dy=dirx[i+1],diry[i+1]
p_x+=dx
p_y+=dy
--flipping
--if dx<0 then p_flip=true
--elseif dx>0 then p_flip=false
--end

p_sox,p_soy=-dx*8,-dy*8
p_ox,p_oy=p_sox,p_soy
_upd=update_pturn
end
__gfx__
00000000000000006666606066666060000000000000000000000000000000000000000000000000000000000000000000000000000000009000000055555550
00000000000000006666606000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009000000055555550
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000099000000000000
00700700000000006066066060660660000000000000000000000000000000000000000000000000000000000000000000000000000000009099099005500000
00700700000000006066066000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009099099005500000
00077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009000099005505000
00077000000000006606666066066660000000000000000000000000000000000000000000000000000000000000000000000000000000009099099005505500
00077000000000006606666000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009099099005505500
00700700000500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009099000005505000
00000000000000006066606060666060000000000000000000000000000000000000000000000000000000000000000000000000000000009099099005505500
00000000000000006066606000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009099099005505500
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
Expand Down Expand Up @@ -226,6 +246,9 @@ __gfx__
60000000060000006606600066066000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
60660000666660006606600066066000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
60060000660060000066000000606000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
__gff__
0000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
__map__
0202020202020202020202020200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0202020101010101010202020200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
Expand Down

0 comments on commit 258b139

Please sign in to comment.