-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathobject_methods.bas
More file actions
65 lines (45 loc) · 1.77 KB
/
object_methods.bas
File metadata and controls
65 lines (45 loc) · 1.77 KB
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
REM Object Methods - CyberBasic Example
REM This example demonstrates object methods functionality
REM Use WASD or arrow keys to interact (where applicable)
// Object Methods Demo
// Demonstrates object methods like vec.length(), vec.normalize(), etc.
PRINT "=== Object Methods Demo ==="
// Vector3 methods
LET v1 = Vector3(3, 4, 0)
LET v2 = Vector3(1, 1, 1)
PRINT "Vector 1: (" + STR(v1.x) + ", " + STR(v1.y) + ", " + STR(v1.z) + ")"
PRINT "Vector 2: (" + STR(v2.x) + ", " + STR(v2.y) + ", " + STR(v2.z) + ")"
LET len1 = v1.length()
PRINT "Length of v1: " + STR(len1)
LET len2 = v2.length()
PRINT "Length of v2: " + STR(len2)
LET norm1 = v1.normalize()
PRINT "Normalized v1: (" + STR(norm1.x) + ", " + STR(norm1.y) + ", " + STR(norm1.z) + ")"
LET dot = v1.dot(v2)
PRINT "Dot product v1·v2: " + STR(dot)
LET cross = v1.cross(v2)
PRINT "Cross product v1×v2: (" + STR(cross.x) + ", " + STR(cross.y) + ", " + STR(cross.z) + ")"
LET dist = v1.distance(v2)
PRINT "Distance between v1 and v2: " + STR(dist)
// Vector2 methods
LET v2d1 = Vector2(3, 4)
LET v2d2 = Vector2(1, 1)
PRINT ""
PRINT "2D Vector 1: (" + STR(v2d1.x) + ", " + STR(v2d1.y) + ")"
PRINT "2D Vector 2: (" + STR(v2d2.x) + ", " + STR(v2d2.y) + ")"
LET len2d1 = v2d1.length()
PRINT "Length of 2D v1: " + STR(len2d1)
LET norm2d1 = v2d1.normalize()
PRINT "Normalized 2D v1: (" + STR(norm2d1.x) + ", " + STR(norm2d1.y) + ")"
LET dot2d = v2d1.dot(v2d2)
PRINT "2D Dot product: " + STR(dot2d)
// Color methods
LET col = Color(255, 128, 64, 255)
PRINT ""
PRINT "Color: r=" + STR(col.r) + ", g=" + STR(col.g) + ", b=" + STR(col.b)
LET bright = col.brightness()
PRINT "Brightness: " + STR(bright)
LET dark = col.darken(0.3)
PRINT "Darkened (30%): r=" + STR(dark.r) + ", g=" + STR(dark.g) + ", b=" + STR(dark.b)
PRINT ""
PRINT "Demo complete!"