Cool Rings

Post Reply
DrChip
Posts: 167
Joined: Wed Oct 22, 2014 3:26 pm
My devices: iPhone 4 to 6+,iPad mini to iPad air 2

Cool Rings

Post by DrChip »

Code: Select all

REM Cool Rings v2.0
REM v2 - bugs fixed
REM iPhone 6 plus / 8.3 b1 

DEF reload
NOTES LOAD "/Examples/Music & Sound/files/test8.mid"
NOTES PLAY
ENDDEF

reload

GOSUB setup

LOOP:
IF NOTES_TIME()>NOTES_LENGTH() THEN reload
REFRESH OFF
GRAPHICS CLEAR 0,0,0
'gosub background
GOSUB rotate 
GOSUB stars
GOSUB drawcircle
GOSUB msg
REFRESH ON
GOTO LOOP

rotate:
xr1=xr1+1
yr1=yr1+1
IF xr1>360 THEN
    xr1=xr1-360
END IF
IF yr1>360 THEN
    yr1=yr1-360
END IF

FOR b=1 TO 2
    IF b=1 THEN
        xr=xr1
    END IF
    IF b=2 THEN
        xr=1
    END IF
    IF b=1 THEN
        yr=1
    END IF
    IF b=2 THEN
        yr=yr1
    END IF
    
    FOR a=0 TO pts 
        x1=x(a,b)
        y1=y(a,b)
        z1=z(a,b)
        xx1=x1
        yy1=y1*cosi(xr)+z1*sine(xr)
        zz1=z1*cosi(xr)-y1*sine(xr)
        y1=yy1
        x1=xx1*cosi(yr)-zz1*sine(yr)
        z1=xx1*sine(yr)+zz1*cosi(yr)
        zz1=z1
        xx1=x1*cosi(zr)-y1*sine(zr)
        yy1=x1*sine(zr)+y1*cosi(zr)
        
        DX(a,b)=xx1
        DY(a,b)=yy1
        dz(a,b)=zz1
        xx(a,b)=DX(a,b)/((dz(a,b)/focus)+1)+sw/2
        yy(a,b)=DY(a,b)/((dz(a,b)/focus)+1)+sh/2
    NEXT a
NEXT b
RETURN

stars:
FOR a=0 TO s
    sxx(a)=sx(a)/((sz(a)/focus))+sw/2
    syy(a)=sy(a)/((sz(a)/focus))+sh/2
    col=((500-sz(a))/4)/255
    FILL COLOR col,col,col
    FILL RECT sxx(a),syy(a) TO sxx(a)+3,syy(a)+3
    sz(a)=sz(a)-15
    IF sz(a)<-500 THEN 
        sz(a)=500
    END IF
NEXT a 
RETURN

drawcircle:
FOR b=1 TO 2
'new curve
FOR a=1 TO pts-1
c=(dz(a,b)+SIZE)
IF b=1 THEN 
DRAW COLOR (8*c)/255,(4*c)/255,(1.3*c)/255
END IF
IF b=2 THEN 
DRAW COLOR (6*c)/255,(1.2*c)/255,(1.4*c)/255
END IF
DRAW LINE xx(a,b),yy(a,b) TO xx(a+1,b),yy(a+1,b) 
    NEXT a
    DRAW LINE xx(a,b),yy(a,b) TO xx(1,b),yy(1,b)
NEXT b
RETURN

msg:
mc=mc-1
IF mc<20 THEN
    mc= 200
    m = m+1
END IF 

IF m>(dp-1) THEN
    m=1
END IF 

DRAW COLOR  4*mc/255,95*mc/255,1.50*mc/255
lx=LEN(m$(m))
DRAW TEXT m$(m) AT (sw/2)-lx*5,75
RETURN

setup:
GRAPHICS
sw=SCREEN_WIDTH()
sh=SCREEN_HEIGHT()
pi=3.1415
mc=200
pts=40 ' points in circle 5-360 
focus=500
SIZE=100
s=1000 'stars at once
m=1
xr=1
yr=2
zr=3
READ dp 
DIM sx(s+1),sy(s+1),sz(s+1),sxx(s+1),syy(s+1)
DIM x(pts+2,3),y(pts+2,3),z(pts+2,3),xx(pts+2,3),yy(pts+2,3) 
DIM DX(pts+1,3),DY(pts+1,3),dz(pts+1,3),ang(pts+1,3) 
DIM sine(362),cosi(362) 
DIM m$(dp+1) 

FOR a=0 TO s 
    sx(a)=-sw/2+RND(sw) 
    sy(a)=-sh/2+RND(sh) 
    sz(a)=-500+INT(RND(1000))+.1
NEXT a 

FOR a=0 TO dp-1
    READ m$(a) 
NEXT a 

FOR a=0 TO 360
    cosi(a)=COS(a*(PI/180)) 
    sine(a)=SIN(a*(PI/180)) 
NEXT a 

FOR b=1 TO 2
    FOR a=0 TO pts 
        ang(a,b)=(360/pts)*a
        x(a,b)=(COS(ang(a,b)*(PI/180))*SIZE) 
        y(a,b)=(SIN(ang(a,b)*(PI/180))*SIZE)
    NEXT a
NEXT b
RETURN

DATA 7,"WELCOME","THIS IS"
DATA "COOL RINGS","BY DRCHIP"
DATA "DO YOU LIKE THE", "SPINNING RINGS?"
DATA "I THINK THEY ARE COOL!"
Attachments
IMG_0328.PNG
IMG_0328.PNG (344.67 KiB) Viewed 1257 times
IMG_0327.PNG
IMG_0327.PNG (342.17 KiB) Viewed 1257 times
IMG_0326.PNG
IMG_0326.PNG (343.01 KiB) Viewed 1257 times

Post Reply