From d2ff49550affa318611a1d7090f7ac4718bc3172 Mon Sep 17 00:00:00 2001 From: bvanroll Date: Mon, 28 Jul 2025 17:38:54 +0200 Subject: [PATCH] explored some with 3d, added animations with coroutines etc. --- first3d.p8 | 17 ++-- lou.p8 | 239 ++++++++++++++++++++++++++++++++++++++++++---------- untitled.p8 | 26 ++++++ 3 files changed, 232 insertions(+), 50 deletions(-) create mode 100644 untitled.p8 diff --git a/first3d.p8 b/first3d.p8 index 758c0f0..d34dd92 100644 --- a/first3d.p8 +++ b/first3d.p8 @@ -19,7 +19,7 @@ function _draw() for i=0,h-yo do w-=xo x1+=xo - tline(x1,i+y+yo,x+w,y+i+yo,0,0) + tline(x1,i+y+yo,x+w,y+i+yo,0,i/8) end xo=txo @@ -50,9 +50,12 @@ __gfx__ 00000000221122112222222200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000221122112222222200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 __map__ -0101010101010101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -0101010101010101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -0101010101010101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -0101010101010101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -0101010101010101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -0101010101010101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +0101010101010101010101010101010100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +0101010101010101010101010101010100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +0101010101010101010101010101010100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +0101010101010101010101010101010100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +0101010101010101010101010101010100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +0101010101010101010101010101010100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +0101010101010101010101010101010100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +0101010101010101010101010101010100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +0101010101010101010101010101010100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 diff --git a/lou.p8 b/lou.p8 index 9eb047f..b77d529 100644 --- a/lou.p8 +++ b/lou.p8 @@ -6,20 +6,39 @@ __lua__ function _init() printh("init") cartdata("lou") + poke(0x5f34,0x2) --enable rfill lou:init() printh("lou age: "..lou.age) menuitem(1,pauseitems[pauseindex],pauseupdate()) + menuitem(2,"wim's song", + function(b) + phraselen=64 + phrases={ + {n=16,l=phraselen}, + {n=17,l=phraselen}, + {n=18,l=phraselen}, + {n=19,l=phraselen}, + {n=20,l=phraselen}, + {n=21,l=phraselen} + } + bgm:set(phrases) + end + ) + cop=1 + end function _update() - + lou.age+=sincelast() if (btn(❎) and btn(🅾️)) cs=1 if (btn(❎) and btn(🅾️) and btn(⬆️) and btn(⬇️) and btn(⬅️) and btn(➡️)) then lou:reset() end if (lcs!=cs) then + printh(state[cs]) + printh(cs) state[cs]:init() end lcs=cs @@ -31,8 +50,12 @@ function _update() end function _draw() - cls() +-- cls() state[cs]:draw() + for r in all(routines) do + + if (costatus(r)!="dead") assert(coresume(r)) + end end -->8 --globals @@ -43,7 +66,7 @@ cs=1 --current state fc=0 --frame counter lcs=0 --last cs maxtime=.30 --maximum time before lou fully grown - +routines={} --list of sprites --order contains a 2d array j -- with the sprite index in order @@ -145,6 +168,46 @@ function pauseupdate(key) menuitem(1,pauseitems[pauseindex],pauseupdate()) return true end + +--animations +--animcounter=0 +--s = next state + +function lerp(x,y,t) + return x+(y-x)*t +end + +function async(func) +printh("euh") + add(routines,cocreate(func)) + printh(count(routines)) +end + +function fadeout() + for i=0,32 do + fillp(▒) + circfill(64,64, + lerp(128*.75,0,i/32),0|0x1800) + fillp() + circfill(64,64, + lerp(128,0,i/32),0|0x1800) + yield() + end + cs=ns +end + + +function fadein() + for i=0,32 do + fillp(▒) + circfill(64,64, + lerp(0,128*.75,i/32),0|0x1800) + fillp() + circfill(64,64, + lerp(0,128,i/32),0|0x1800) + yield() + end +end -->8 --state state={ @@ -194,10 +257,22 @@ draw=function(self) stats:draw() end, init=function(self) +end +}, +{--6 thecube +update=function(self) + cube:update() +end, +draw=function(self) + cube:draw() +end, +init=function(self) + cube:init() + end } } --->8 + --lou lou={ new=1, @@ -250,7 +325,7 @@ lou={ self:init() end } --->8 + --bgm bgm={ tracklist={ @@ -264,30 +339,32 @@ set=function(self,obj) bgm.t=1 end, loop=function(self) - if (self.t>self.tracklist[self.c].l) self.t=1 + if (self.t>self.tracklist[min(count(self.tracklist),self.c)].l) self.t=1 if self.t==1 then - self.c+=1 - + printh("playing") if self.c>count(self.tracklist) then self.c=1 end music(self.tracklist[self.c].n) - + printh(self.tracklist[self.c].n) + self.c+=1 end self.t+=1 end } -->8 +--gameplay + --menu menu={ tracks={ { - n=1, + n=0, l=127 }, { - n=0, + n=1, l=127 }, }, @@ -332,11 +409,24 @@ menu={ b=13, s=4 }, - + { + text="thecube", + x=3, + y=52, + w=28, + h=6, + c=2, + b=8, + s=6 + }, + }, speaktimer=0, selected=1, init=function(self) + async(function() + fadein() + end) bgm:set(self.tracks) end, update=function(self) @@ -344,8 +434,13 @@ menu={ self:up() elseif btnp(⬇️) then self:down() - elseif btnp(❎) then - cs=self.items[self.selected].s + elseif btnp(❎) + then + ns=self.items[self.selected].s + async(function() + printh("euh") + fadeout(ns) + end) end end, draw=function(self) @@ -400,11 +495,7 @@ menu={ } -pause={ - -} --->8 --- play +--play play={ tracks={ { @@ -414,6 +505,9 @@ play={ }, currentgame=1, init=function(self) + async(function() + fadein() + end) bgm:set(self.tracks) currentgame=1 --make this random later end, @@ -428,6 +522,8 @@ play={ end, } + +--minigames games={ {--find tx=0, @@ -499,7 +595,15 @@ games={ 16+self.py*8, sprites.sam.w, sprites.sam.h) - + poke(0x5f34,0x2) + fillp(░) + circfill(24+self.px*8, + 24+self.py*8, + 20+sin(time()/2)*3,1|0x1800) + fillp(0) + circfill(24+self.px*8, + 24+self.py*8, + 28+cos(time()/4)*5,0|0x1800) end, @@ -508,7 +612,7 @@ games={ end } } --->8 + -- stats stats={ init=function(self) @@ -524,6 +628,37 @@ draw=function(self) print("press 🅾️ to return") end } +--cube + +cube={ +tx=32, +ty=0, +x=60, +y=60, +w=8, +h=8, +init=function(self) +end, +update=function(self) + if btn(⬆️) then + self.y-=.1 + self.x-=.1 + self.w+=.2 + self.h-=.1 + end +end, +draw=function(self) + for i=0,self.h do + tline(self.x, + self.y+i, + self.x+self.w, + self.y+i, + 32, + 4+i/8 + ) + end +end +} __gfx__ 00000000000000000000c0c0eccceecce7777777eceeceee00000000000000000000000000000000000000000000000000000000000000000000000000000000 000988000000000000c09c00c777777ce77777777777777700000000000000000000000000000000000000000000000000000000000000000000000000000000 @@ -541,14 +676,14 @@ __gfx__ 009cc0000000001111000000000000007777777e7777777700000000000000000000000000000000000000000000000000000000000000000000000000000000 0099c0000000001111000000000000007777777c7777777700000000000000000000000000000000000000000000000000000000000000000000000000000000 00aa99000000000000000000000000007777777eeeeececc00000000000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +1111cccc000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +1111cccc000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +1111cccc000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +1111cccc000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +cccc1111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +cccc1111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +cccc1111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +cccc1111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000066666666600000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000666666666666000000000000000000000000000000000000000000000000000 @@ -654,14 +789,14 @@ __gfx__ 555555555555555555555657777777777777777777777777777777777777777777e77777777777777ee777777777777777777777777777777777777777777777 555555555555555555555555777777777777777777777777777777777777777777ee777eeeeee777777777777777777777777777777777777777777777777777 __map__ -3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d07070707070707070707070707070707070707070707070707070707070707070707070707070707000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d07030505050505030707070707070707070707070707070707070707070707070707070707070707000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d07040707070700140707070707070707070707070707070707070707070707070707070707070707000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -3d3d3d3d3d3d363738393a3b3d3d3d3d07040707070707140707070707070707070707070707070707070707070707070707070707070707000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -404142434445464748494a4b4c4d4e4f07040707070707140707070707070707070707070707070707070707070707070707070707070707000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -505152535455565758595a5b5c5d5e5f07040707070707140707070707070707070707070707070707070707070707070707070707070707000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -606162636465666768696a6b6c6d6e6f07040707070707140707070707070707070707070707070707070707070707070707070707070707000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -707172737475767778797a7b7c7d7e7f07031515151515030707070707070707070707070707070707070707070707070707070707070707000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d07070707070707070707070720202020202020202007070707070707070707070707070707070707000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d07030505050505030707070720202020202020202007070707070707070707070707070707070707000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d07040707070700140707070720202020202020202007070707070707070707070707070707070707000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +3d3d3d3d3d3d363738393a3b3d3d3d3d07040707070707140707070720202020202020202007070707070707070707070707070707070707000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +404142434445464748494a4b4c4d4e4f07040707070707140707070720202020202020202007070707070707070707070707070707070707000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +505152535455565758595a5b5c5d5e5f07040707070707140707070720202020202020202007070707070707070707070707070707070707000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +606162636465666768696a6b6c6d6e6f07040707070707140707070720202020202020202007070707070707070707070707070707070707000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +707172737475767778797a7b7c7d7e7f07031515151515030707070720202020202020202007070707070707070707070707070707070707000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 808182838485868788898a8b8c8d8e8f07070707070707070707070707070707070707070707070707070707070707070707070707070707070000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 909192939495969798999a9b9c9d9e9f07070707070707070707070707070707070707070707070707070707070707070707070707070707070000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 a0a1a2a3a4a5a6a7a8a9aaabacadaeaf07070707070707070707070707070707070707070707070707070707070707070707070707070707070000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 @@ -703,12 +838,12 @@ __sfx__ 002000001e150000001e152000001e152000001e152000001e150000001e152000001e152000021e152000021c152000021c152000021c152000021c152000021c152000021c152000021c152000021c15200000 014000000000015050140501305012050110501005010050000001500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 001f0000150501705000000180501d05000000000001705000000000000000000000000001705018050000001a050180500000000000150500000000000000000000015050170500000018050170500000000000 -001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -00200000000000000000000000000000000000000000000000000000000000000000000000000000000000002b0501d0502b0501a050000002b0502b0502b05000000000001a0501a0501a0501a0501a05000000 -001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +0108000015155001051715500105001050010518155001051d1550010500105001050010500105171550010500105001050010500105001050010500105001051715500105181550010500105001051a15500105 +010800001815500105001050010500105001051515500105001050010500105001050010500105001050010515155001051715500105001050010518155001051715500105001050010500105001051d15500105 +01080000001050010500105001051c1550010500105001051c155001051c1550010500105001051a1550010517155001050010500105001050010500105001050010500105001050010500105001050010500105 +010800001c155001051c1550010500105001051c155001051a1550010500105001051815500105151550010500105001050b1551d1050c1551a105001052b1051c1552b1051d155001051a1051a1051c1551a105 +010800001c1550010500105001051a15500105171550010500105001050c155001050e1550010500105001051c155001051d1550010500105001051c155001051c1550010500105001051a155001051715500105 +0108000000705007050c755007050e755007050070500705187550070517755007050070500705137550070515755007050070500705007050070513755007050070500705007050070511755007050070500705 001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 @@ -723,4 +858,22 @@ __music__ 00 0a440c0d 00 0a0c0d53 00 4e0f431d +00 10424344 +00 41424344 +00 41424344 +00 41424344 +00 41424344 +00 41424344 +00 41424344 +00 41424344 +00 41424344 +00 41424344 +00 41424344 +00 10424344 +00 11424344 +00 12424344 +00 13424344 +00 14424344 +00 15424344 +00 16424344 diff --git a/untitled.p8 b/untitled.p8 new file mode 100644 index 0000000..0ac548b --- /dev/null +++ b/untitled.p8 @@ -0,0 +1,26 @@ +pico-8 cartridge // http://www.pico-8.com +version 42 +__lua__ +function _draw() + cls() + x=64 + y=64 + h=8 + for i=0,3 do + c=rnd(3)/10+8 + o=rnd(8) + for i=0,20 do + line(x+sin(time()/8+o)*c,y,x,y+20) + end + end +end + +function _update() +end +__gfx__ +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00700700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00700700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000