Post by joe2874 on Apr 6, 2022 7:24:03 GMT -6
Bacon is a basic to c converter developped in bash. the syntax is modern and the generated programs are autonomous and very fast. there is an editor but I prefer to configure it under geany. allows to realize programs in command line or with graphical interface. easy to use. available only for linux unix macos.
example of code found in the official site :
example of code found in the official site :
'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