landscape.bac
REM Landscape program ported to BaCon
INCLUDE "hug.bac", INIT, WINDOW, CANVAS, ATTACH, SQUARE, LINE, OUT, TIMEOUT, KEY, RESETKEY, DISPLAY
REM Color definition
DEF FN col$(v) = "#" & HEX$(v) & HEX$(v) & HEX$(v)
REM Size of the canvas
CONST Width = 800
CONST Height = 600
REM The landscape
SUB Draw_Landscape
LOCAL colour, start, mountains, offset, x, y, factor
SQUARE("#DCC8DC", 0, 0, Width, Height, TRUE)
colour = 180
start = 100
FOR mountains = 1 TO 6
offset = 0
y = start
REPEAT
factor = (RANDOM(9)-4)/2
FOR x = offset TO offset+RANDOM(40)
y = y + factor
LINE(col$(colour), x, y, x, Height)
NEXT
offset = x
UNTIL offset >= Width
DECR colour, 23
INCR start, 20+RANDOM(80)
NEXT
OUT("Press space for a new landscape...", "#FFFFFF", col$(colour+23), 10, 500)
END SUB
REM Check for <space> or <escape>
FUNCTION Key_Press
IF KEY() = 32 THEN
Draw_Landscape
ELIF KEY() = 65307 THEN
END
ENDIF
RESETKEY
RETURN TRUE
END FUNCTION
REM Define the canvas
INIT
win = WINDOW("Landscape", Width, Height)
cvs = CANVAS(Width, Height)
ATTACH(win, cvs, 0, 0)
Draw_Landscape
TIMEOUT(10, Key_Press)
DISPLAY
Generated by GNU Enscript 1.6.5.90.