Some sort of "screensaver" for your console/terminal. Based on Yu-Jie Lin's "pipes.sh", but cooler, since it's written in FreeBasic. Maybe someone rembembers the old Windows 98 OpenGL-screensaver with those pipes?
Code: Select all
const num_pipes=3
dim shared as integer xscale, yscale
xscale=loword(width)
yscale=hiword(width)
dim shared as ushort feld(xscale,yscale),feld_clr(xscale,yscale)
type t_pipe
as ubyte clr
as byte direction,olddirection,x,y,timers
declare sub update()
declare constructor
end type
randomize
constructor t_pipe
x=rnd()*xscale
y=rnd()*yscale
clr=rnd()*14+1
end constructor
sub t_pipe.update()
timers+=1
if timers>3 then
direction=rnd()*3
if direction=0 and olddirection=2 then exit sub
if direction=2 and olddirection=0 then exit sub
if direction=1 and olddirection=3 then exit sub
if direction=3 and olddirection=1 then exit sub
timers=0
else
olddirection=direction
end if
if x>xscale-1 then x=0
if y>yscale-1 then y=0
if x<0 then x=xscale-1
if y<0 then y=yscale-1
feld_clr(x,y)=clr
if direction=0 then 'Runter
select case as const olddirection
case 0
if feld(x,y)=&h2501 then
feld(x,y)=&h254B
else
feld(x,y)=&h2503
end if
case 1:feld(x,y)=&h2513
case 3:feld(x,y)=&h250F
end select
y+=1
elseif direction=2 then 'Hoch
select case as const olddirection
case 2
if feld(x,y)=&h2501 then
feld(x,y)=&h254B
else
feld(x,y)=&h2503
end if
case 1:feld(x,y)=&h251B
case 3:feld(x,y)=&h2517
end select
y-=1
elseif direction=1 then 'Rechts
select case as const olddirection
case 0:feld(x,y)=&h2517
case 2:feld(x,y)=&h250F
case 1
if feld(x,y)=&h2503 then
feld(x,y)=&h254B
else
feld(x,y)=&h2501
end if
end select
x+=1
elseif direction=3 then 'Links
select case as const olddirection
case 0:feld(x,y)=&h251B
case 2:feld(x,y)=&h2513
case 3
if feld(x,y)=&h2503 then
feld(x,y)=&h254B
else
feld(x,y)=&h2501
end if
end select
x-=1
end if
end sub
sub render()
locate 0,0
for y as integer=0 to yscale-1
for x as integer=0 to xscale-1
if feld(x,y)=0 then print " ";
color feld_clr(x,y)
print wchr(feld(x,y));
next
print
next
end sub
dim as t_pipe pipes(num_pipes-1)
do
for i as integer=0 to num_pipes-1
pipes(i).update()
sleep 5,1
next
render()
loop until inkey=chr(27)