From 258b139f38598e8cd4bef504da2708e48d979451 Mon Sep 17 00:00:00 2001 From: Brin-o <49071768+Brin-o@users.noreply.github.com> Date: Wed, 22 Dec 2021 12:11:57 +0100 Subject: [PATCH] creative changes, rogue tutorial goes on --- creative/balls.p8 | 2 +- creative/boxes.p8 | 39 +++++++++++++++++ creative/lines.p8 | 15 ++++--- creative/rotatingline.p8 | 21 ++++++---- rogue.p8 | 91 +++++++++++++++++++++++++--------------- 5 files changed, 120 insertions(+), 48 deletions(-) create mode 100644 creative/boxes.p8 diff --git a/creative/balls.p8 b/creative/balls.p8 index a702457..9e17d2a 100644 --- a/creative/balls.p8 +++ b/creative/balls.p8 @@ -47,7 +47,7 @@ function _draw() end -->8 ---tools +--creative tools function dither(val, c) for x=1,val do diff --git a/creative/boxes.p8 b/creative/boxes.p8 new file mode 100644 index 0000000..5d00ad5 --- /dev/null +++ b/creative/boxes.p8 @@ -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 diff --git a/creative/lines.p8 b/creative/lines.p8 index 10c0f4a..192a353 100644 --- a/creative/lines.p8 +++ b/creative/lines.p8 @@ -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(t8 --tools diff --git a/creative/rotatingline.p8 b/creative/rotatingline.p8 index 1772d67..f5ff528 100644 --- a/creative/rotatingline.p8 +++ b/creative/rotatingline.p8 @@ -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__ diff --git a/rogue.p8 b/rogue.p8 index b9a6ea4..78eb2ce 100644 --- a/rogue.p8 +++ b/rogue.p8 @@ -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 @@ -20,8 +24,11 @@ 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 @@ -29,34 +36,32 @@ end -- 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 @@ -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 @@ -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 @@ -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 @@ -226,6 +246,9 @@ __gfx__ 60000000060000006606600066066000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 60660000666660006606600066066000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 60060000660060000066000000606000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +__gff__ +0000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 __map__ 0202020202020202020202020200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0202020101010101010202020200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000