- [NEW] Raycast demo

- ticker.lua source "petrified"
- fire.lua source slightly reordered to be even "petrier"
This commit is contained in:
2023-07-07 12:43:43 +02:00
parent 7e9b57dafe
commit f1034403de
4 changed files with 32 additions and 34 deletions

2
.gitignore vendored
View File

@@ -1,2 +1,4 @@
tools/*
ascii.exe
SDL2.dll
ascii

View File

@@ -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
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

15
demos/raycast.lua Normal file
View File

@@ -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
sX<sY then d,sX,mX=0,sX+eX,mX+tX else d,sY,mY=1,sY+eY,mY+tY
end if m[mX][mY]>0 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

View File

@@ -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
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