03-10-2025, 09:51 AM
How about "Pipes 2D" ?
Code:
' Set up the screen
#win32
set window "Pipes 2D", 640, 480,false
'randomize
randomize time()
'color definition
black = [0,0,0]
white = [255,255,255]
red = [255,0,0]
green = [0,255,0]
blue = [0,0,255]
yellow = [255,255,0]
cyan = [0,255,255]
magenta = [255,0,255]
' Define colors for the pipes
colors=[]
colors[0] = red
colors[1] = green
colors[2] = blue
colors[3] = yellow
colors[4] = cyan
colors[5] = magenta
'initial color
col = red
' Pipe settings
pipe_width = 10
speed = pipe_width
' Directions: 0 = right, 1 = down, 2 = left, 3 = up
direction = int(rnd() * 4)
' Starting position
x = width()/2
y = height()/2
' Main loop
while not keydown(KEY_ESCAPE)
' Randomly choose a color for the new pipe segment
set color col
' Draw the pipe segment based on direction
if direction = 0 then
' Right
draw rect x, y, pipe_width, pipe_width,true
x = x + speed
elseif direction = 1 then
' Down
draw rect x, y, pipe_width, pipe_width,true
y = y + speed
elseif direction = 2 then
' Left
draw rect x, y, pipe_width, pipe_width,true
x = x - speed
elseif direction = 3 then
' Up
draw rect x, y, pipe_width, pipe_width,true
y = y - speed
endif
' Change direction randomly or when hitting the screen edge
if x <= (0+pipe_width) or x >= (640 - pipe_width) or
y <= (0+pipe_width) or y >= (480 - pipe_width) or
int(rnd() * 20) < 10 then
direction = int(rnd() * 4)
endif
' Clear the screen occasionally to prevent clutter
if int(rnd() * 1800) < 5 or keydown(KEY_SPACE,true) then
set color black
cls
x = width()/2
y = height()/2
endif
'change colors
if int(rnd() * 400) < 5 then
col = colors[int(rnd() * 5)]
x = x + pipe_width*2
y = y + pipe_width*2
endif
' Pause for a short time
fwait 60
wend