Author Topic: Only for fun  (Read 2013 times)

Galileo

  • Guest
Only for fun
« on: February 16, 2018, 05:48:47 PM »
Code: [Select]
// 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

B+

  • Guest
Re: Only for fun
« Reply #1 on: February 16, 2018, 09:55:59 PM »
Oh ha! Why not clear screen?

Code: [Select]
'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     


Galileo

  • Guest
Re: Only for fun
« Reply #2 on: February 17, 2018, 03:36:50 PM »
To achieve the desired effect. If you run the program you'll understand.

B+

  • Guest
Re: Only for fun
« Reply #3 on: February 17, 2018, 11:54:52 PM »
I guess you liked the living ball of worms.  ;D

Peter

  • Guest
Re: Only for fun
« Reply #4 on: March 18, 2018, 02:12:50 PM »
Code: [Select]
'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


B+

  • Guest
Re: Only for fun
« Reply #5 on: March 26, 2018, 02:51:38 PM »
Yeah Peter, another gif gift!  :)