RetroBASIC
Basicprogramming(.org) => Code and examples => Topic started by: Galileo on February 16, 2018, 05:48:47 PM
-
// Classic animation program modified for fun
// Galileo, 02/2018
// Powered by Yabasic ;-)
clear screen
open window 500, 500
backcolor 0, 0, 0
clear window
color 200, 200, 0
pozx = 0
pozy = 0
do
rysuj()
wait 0.03
pozx = pozx + 2
pozy = pozy + 2
// clear window
loop
sub rysuj()
a = pozx / 99
b = pozy / 99
for x = -1 to 1
for y = -1 to 1
for z = -1 to 1
y2 = y
x2 = x * cos(a) - y2 * sin(a)
y3 = x * sin(a) + y2 * cos(a)
y2 = y3
y3 = y2 * cos(b) - z * sin(b)
z2 = y2 * sin(b) + z * cos(b)
sx = 250 + x2 * (z2 + 2) * 35
sy = 250 + y3 * (z2 + 2) * 35
size = (z2 + 2) * 5 : colorin = size * 8
color colorin, colorin, colorin
fill circle sx, sy, size
next z
next y
next x
end sub
-
Oh ha! Why not clear screen?
'Classic animation (Galileo).bas for SmallBASIC 0.12.11 B+=MGA 2018-02-16
'copied from Retro and modified
'// Classic animation program modified for fun
'// Galileo, 02/2018
'// Powered by Yabasic ;-)
' oh it's our old friend the rotating cube
color rgb(200, 200, 0), 0
pozx = 0
pozy = 0
while 1
cls
rysuj()
delay 10
pozx = pozx + 2
pozy = pozy + 2
'// clear window <<<<<<<<<<<<<<<<<<< why ?
wend
sub rysuj()
a = pozx / 99
b = pozy / 99
for x = -1 to 1
for y = -1 to 1
for z = -1 to 1
y2 = y
x2 = x * cos(a) - y2 * sin(a)
y3 = x * sin(a) + y2 * cos(a)
y2 = y3
y3 = y2 * cos(b) - z * sin(b)
z2 = y2 * sin(b) + z * cos(b)
sx = 250 + x2 * (z2 + 2) * 35
sy = 250 + y3 * (z2 + 2) * 35
size = (z2 + 2) * 5 : colorin = size * 8
color rgb(colorin, 128 + colorin/128, 128-.5*colorin)
circle sx, sy, size filled
next z
next y
next x
end sub
-
To achieve the desired effect. If you run the program you'll understand.
-
I guess you liked the living ball of worms. ;D
-
'Classic animation (Galileo).bas for SmallBASIC 0.12.11 B+=MGA 2018-02-16
'copied from Retro and modified
'// Classic animation program modified for fun
'// Galileo, 02/2018
'// BaCon port, March 2018 - PvE
' oh it's our old friend the rotating cube
INCLUDE canvas-gd
OPTION VARTYPE FLOATING
WINDOW("cube", 500, 500)
FRAMES(310)
CALLBACK(10, rysuj)
WAITKEY
SUB rysuj
INK(200, 200, 0, 255)
CLS
a = pozx / 99
b = pozy / 99
FOR x = -1 TO 1
FOR y = -1 TO 1
FOR z = -1 TO 1
y2 = y
x2 = x * COS(a) - y2 * SIN(a)
y3 = x * SIN(a) + y2 * COS(a)
y2 = y3
y3 = y2 * COS(b) - z * SIN(b)
z2 = y2 * SIN(b) + z * COS(b)
sx = 250 + x2 * (z2 + 2) * 35
sy = 250 + y3 * (z2 + 2) * 35
size = (z2 + 2) * 5 : colorin = size * 8
INK(colorin, 128 + colorin/128, 128-.5*colorin, 255)
CIRCLE(sx, sy, size, size, TRUE)
NEXT z
NEXT y
NEXT x
' Enlarged the steps a bit to get some speed
INCR pozx, 8
INCR pozy, 8
END SUB
(http://basic-converter.org/canvas/cube.gif)
-
Yeah Peter, another gif gift! :)