Worm Hole v1

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

Worm Hole v1

Post by DrChip »

' i wrote this at Denny's as i was waiting
' with my son. i had to keep him busy.
' i'm done with it. if anyone wants to jump
' in and finish it, please feel free to!
' enjoy DrChip :)

REM
REM 3d Wormhole v1.0
REM
REM v1.0
REM cleaned code, optimized a bit, adapted for PI.

'screen area
scw = Screen_Width()
sch = Screen_Height()
csw = scw/2
csh = sch/2
pi=3.1415
graphics
graphics clear 0,0,0
'init
rings=25 '20-80 (basic is too slow)
DIM rx(rings+1)
DIM ry(rings+1)
DIM rz(rings+1)

DIM orx(1441)
DIM ory(1441)



'full rotation, 720 would work but not as nice.
DIM circx(1441)
DIM circy(1441)

offs=1
FOR a=1 TO 1440
circx(a)=2900*SIN(a*PI/720)
circy(a)=2900*COS(a*PI/720)
NEXT a

move=0.0
zsp=rings*2
gadd=0
FOR a=1 TO rings
rx(a)=920*SIN(gadd/23)
ry(a)=920*SIN(gadd/25)
rz(a)=(zsp+3)
zsp=zsp-2
gadd=gadd+5
NEXT a

' main routine
main:
graphics clear 0,0,0
refresh off
GOSUB draw_rings
refresh on

GOTO main

draw_rings:
move=move+2 ' speed 0.1 - 2.0
offs=offs+1
IF offs>160 THEN
offs=offs-160
END IF

FOR a=1 TO rings -1
tx=(rx(a)/(rz(a)-move))+csw
ty=(ry(a)/(rz(a)-move))+csh
tx2=(rx(a+1)/(rz(a+1)-move))+csw
ty2=(ry(a+1)/(rz(a+1)-move))+csh
clr=a 'shl 2

bmm=(INT(-rz(a)+53)) 'shl 1
draw COLOR .bmm ,.bmm ,.bmm

FOR z=offs TO 1280+offs STEP 160
IF a<rings THEN
ttx3=(circx(z)/(rz(a+1)-move))+tx2
tty3=(circy(z)/(rz(a+1)-move))+ty2
END IF
ttx1=(circx(z)/(rz(a)-move))+tx
tty1=(circy(z)/(rz(a)-move))+ty
IF z<=1280 THEN
ttx2=(circx(z+160)/(rz(a)-move))+tx
tty2=(circy(z+160)/(rz(a)-move))+ty
ELSE
ttx2=(circx(offs)/(rz(a)-move))+tx
tty2=(circy(offs)/(rz(a)-move))+ty
END IF

draw COLOR .ttx1,.tty1, .255

draw size 1
draw LINE ttx1,tty1 to ttx2,tty2

IF a<rings THEN
draw COLOR 1,1,1
draw size 2
draw LINE ttx1,tty1 to ttx3,tty3
END IF
NEXT z
NEXT a

IF move>2 THEN
gadd=gadd-130

FOR a=1 TO rings
rx(a)=920*SIN(gadd/23)
ry(a)=920*SIN(gadd/25)
gadd=gadd+5
NEXT a
move=move-2
END IF

RETURN
Attachments
image.jpg
image.jpg (452.32 KiB) Viewed 1756 times

Post Reply