From f1034403dea928eb2381ac11ac01513dcf340575 Mon Sep 17 00:00:00 2001 From: Raimon Zamora Date: Fri, 7 Jul 2023 12:43:43 +0200 Subject: [PATCH] - [NEW] Raycast demo - ticker.lua source "petrified" - fire.lua source slightly reordered to be even "petrier" --- .gitignore | 2 ++ demos/fire.lua | 15 ++++++++------- demos/raycast.lua | 15 +++++++++++++++ demos/ticker.lua | 34 +++++++--------------------------- 4 files changed, 32 insertions(+), 34 deletions(-) create mode 100644 demos/raycast.lua diff --git a/.gitignore b/.gitignore index 195b2b4..b67bcf2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ +tools/* ascii.exe SDL2.dll +ascii \ No newline at end of file diff --git a/demos/fire.lua b/demos/fire.lua index 9232c45..e578ab0 100644 --- a/demos/fire.lua +++ b/demos/fire.lua @@ -1,7 +1,8 @@ -f={}p={0,1,5,4,6,12,14,15}for i=0,1199 -do f[i]=0 poke(i,143)end -function update()for i=0,1119 do -if i<41 then f[1160+i]=rnd(2)*256 end -f[i]=(f[i+39]+f[i+40]+f[i+41]+f[i+80])/4.1 -poke(1200+i,p[mid(0,flr(f[i]/4),7)+1]) -end end \ No newline at end of file +f={}p={0,1,5,4,6,12,14,15}for +i=0,1199 do f[i]=0 poke(i,143) +end function update()for i=0, +1119 do if i<41 then f[1160+i] +=rnd(2)*256 end f[i]=(f[i+39]+ +f[i+40]+f[i+41]+f[i+80])/4.1 +poke(1200+i,p[mid(0,flr(f[i]/4 +),7)+1]) end end \ No newline at end of file diff --git a/demos/raycast.lua b/demos/raycast.lua new file mode 100644 index 0000000..4671cb4 --- /dev/null +++ b/demos/raycast.lua @@ -0,0 +1,15 @@ +m={}for x=1,12 do m[x]={}for y=1,12 do m[x][y]=0 if x==1 +or x==12 or y==1 or y==12 then m[x][y]=1 elseif x%2==1 and +y%2==1 then m[x][y]=2 end end end pX,pY=6,6 dX,dY=1,0 lX, +lY=0,0.66 t=0 cs=cos(0.05)sn=sin(0.05)function update()s=0 +if btn(82)then s=0.1 elseif btn(81)then s=-0.1 end if s~=0 +then pX,pY=pX+dX*s,pY+dY*s end s=0 if btn(80)then s=1 elseif +btn(79)then s=-1 end if s~=0 then dX,dY=dX*cs+dY*sn*s,dY*cs- +dX*sn*s lX,lY=lX*cs+lY*sn*s,lY*cs-lX*sn*s end cls()for x=0, +39 do cX=2*x/40-1 rx,ry=dX+lX*cX,dY+lY*cX mX=flr(pX)mY=flr( +pY)eX=abs(1/rx)eY=abs(1/ry)tX=sgn(rx)sX=eX*tX*(mX-pX+((tX+1 +)>>1))tY=sgn(ry)sY=eY*tY*(mY-pY+((tY+1)>>1))while 1 do if +sX0 then break end end p=(d==0)and(sX-eX)or( +sY-eY)ink(m[mX][mY])for y=max(0,15-15/p),min(30,15+15/p)do +print(d==0 and "\143" or "\207",x,y)end end end \ No newline at end of file diff --git a/demos/ticker.lua b/demos/ticker.lua index 48561b3..7dfd1f5 100644 --- a/demos/ticker.lua +++ b/demos/ticker.lua @@ -1,27 +1,7 @@ -C=66 -a=0 -ticker=0 -function printchar(C, x,y) - if x<-8 or x>39 then return end - for j=0,7 do - line=peek(2560+C*8+j) - for i=0,7 do - X=x+7-i - ink(1+(flr(X)+j+flr(a))%15) - if X>0 and X<40 then - s=10+sin(a+(X)*0.1)*5 - if line & 1 == 1 then print(chr(233),X,y+j+s) end - end - line = line >> 1 - end - end -end - -function update() - cls() - message="HOLA JAILERS" - for n=0,#message-1 do - printchar(ascii(message,n),n*8-flr(a*4)%(#message*8),0) - end - a=a+0.1 -end \ No newline at end of file +C=66 a=0 ticker=0 function p(C,x,y)if x<-8 or x>39 +then return end for j=0,7 do l=peek(2560+C*8+j) +for i=0,7 do X=x+7-i ink(1+(flr(X)+j+flr(a))%15)if X>0 +and X<40 then s=10+sin(a+(X)*0.1)*5 if l&1==1 then +print(chr(233),X,y+j+s)end end l=l>>1 end end end +function update()cls()m="HOLA JAILERS"for n=0,#m-1 do +p(ascii(m,n),n*8-flr(a*4)%(#m*8),0)end a=a+0.1 end \ No newline at end of file