File: rotating3dcube.kbs

package info (click to toggle)
basic256 2.0.0.11-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 15,076 kB
  • sloc: cpp: 16,791; yacc: 3,979; lex: 1,446; makefile: 25
file content (67 lines) | stat: -rwxr-xr-x 1,061 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# posted to sourceforge tracker by anonymous
# on 2010-01-30
dim credit$(6)
credit$[0] = "###"
credit$[1] = "# rotating 3d cube"
credit$[2] = "# based on and adapted from: "
credit$[3] = "# http://maettig.com/code/javascript/3d_dots.html"
credit$[4] = "*************************************************"
credit$[5] = "Move your mouse to rotate the cube"

for i=0 to 5
print credit$[i]
next i

clg
dimension = 1
a = 0
b = 0
i = 27

while 1=1
a = mousex / 99
b = mousey / 99
gosub update
end while


update:
fastgraphics
clg
for x=-dimension to dimension step dimension

for y=-dimension to dimension step dimension

for z=-dimension to dimension step dimension
u = x
v = y
w = z
u2 = u * cos(a) - v * sin(a)
v2 = u * sin(a) + v * cos(a)
w2 = w
u = u2
v = v2
w = w2
u2 = u
v2 = v * cos(b) - w * sin(b)
w2 = v * sin(b) + w * cos(b)
u = u2
v = v2
w = w2
c = floor((w + 2) * 70)
if (c < 0) then c = 0
if (c > 255) then c = 255

sx = 100+ u * (w + 2) * 35
sy = 100+ v * (w + 2) * 35

font "arial",(w + 2) * 16 ,15
text sx,sy,"+"

next z

next y

next x
refresh
return