REM Background - Scrolling grid / 3d Box
REM iPhone 6 plus / 8.3
REM Grid - scrolls up and down automatically
REM adjust size 60,120,180,240...
REM you can make it go left and right too!
REM adjust the scroll length
REM enjoy!
setup:
graphics
sw=Screen_Width()
sh=Screen_Height()
DIM trix(4),triy(4)
pi=3.1415
DIM c(361), s(361)
DIM x(9), y(9), Z(9), x2(9), y2(9), Z2(9), x3(9), y3(9)
FOR i = 1 TO 360
c(i) = COS(i * PI/ 180)
s(i) = SIN(i * PI/ 180)
NEXT i
FOR i = 1 TO 8
READ x(i)
READ y(i)
READ Z(i)
NEXT i
phi = 1
theta = 1
xcenter = sw/2
ycenter = sh/2
zcenter = 256
speed = 10 'pos forward 10, neg backward -10
deltaspeed = 1 ' rate of inc...
stepp = 160 ' block size
ste = stepp/2
scrollmin=80
scrollmax=80
loop:
refresh off
graphics clear 0,0,0
gosub background
gosub drawbox
refresh on
goto loop
background:
speed=speed+deltaspeed
IF speed > scrollmin OR speed < -scrollmax THEN
deltaspeed = -deltaspeed
END IF
zz=zz+speed
IF zz>=0 THEN
zz=zz-speed
END IF
FOR h=zz TO sh STEP stepp
FOR w=0 TO sw STEP stepp
fill COLOR 15/255,15/255,60+(h/3)/255
fill RECT w,h to w+ste,h+ste
fill RECT w+ste,h+ste to w+stepp,h+stepp
NEXT w
NEXT h
return
drawbox:
FOR i = 1 TO 8
x2(i) = -x(i) * s(theta) + y(i) * c(theta)
y2(i) = -x(i) * c(theta) * s(phi) - y(i) * s(theta) * s(phi) - Z(i) * c(phi) + p
Z2(i) = -x(i) * c(theta) * c(phi) - y(i) * s(theta) * c(phi) + Z(i) * s(phi)
x3(i) = 256 * (x2(i) / (Z2(i) + zcenter)) + xcenter
y3(i) = 256 * (y2(i) / (Z2(i) + zcenter)) + ycenter
fill color 1,1,1
fill CIRCLE x3(i), y3(i) size 10
NEXT i
draw size 5
draw line x3(1), y3(1) to x3(3), y3(3)
draw LINE x3(1), y3(1) to x3(4), y3(4)
draw line x3(1), y3(1) to x3(5), y3(5)
draw line x3(2), y3(2) to x3(3), y3(3)
draw line x3(2), y3(2) to x3(4), y3(4)
draw line x3(2), y3(2) to x3(6), y3(6)
draw line x3(7), y3(7) to x3(6), y3(6)
draw line x3(7), y3(7) to x3(3), y3(3)
draw line x3(7), y3(7) to x3(5), y3(5)
draw line x3(8), y3(8) to x3(5), y3(5)
draw line x3(8), y3(8) to x3(4), y3(4)
draw line x3(8), y3(8) to x3(6), y3(6)
phi = phi + 1
theta = theta + 1
IF phi > 360 THEN
phi = phi - 360
END IF
IF theta > 360 THEN
theta = theta - 360
END IF
RETURN
DATA 50,50,-50
DATA -50,-50,-50
DATA -50,50,-50
DATA 50,-50,-50
DATA 50,50,50
DATA -50,-50,50
DATA -50,50,50
DATA 50,-50,50
Scrolling grid background with 3d box
-
- Posts: 167
- Joined: Wed Oct 22, 2014 3:26 pm
- My devices: iPhone 4 to 6+,iPad mini to iPad air 2
Scrolling grid background with 3d box
- Attachments
-
- image.jpg (154.51 KiB) Viewed 1961 times
-
- image.jpg (145.16 KiB) Viewed 1961 times
-
- image.jpg (153.91 KiB) Viewed 1961 times