-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmath_utilities_test.bas
More file actions
75 lines (59 loc) · 2.72 KB
/
math_utilities_test.bas
File metadata and controls
75 lines (59 loc) · 2.72 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
65
66
67
68
69
70
71
72
73
74
75
REM Math Utilities Test - CyberBasic Example
REM This example demonstrates math utilities test functionality
REM Use WASD or arrow keys to interact (where applicable)
INITWINDOW(800, 600, "Math Utilities Test")
SETTARGETFPS(60)
LET running = TRUE
WHILE running AND NOT WINDOWSHOULDCLOSE()
BEGINDRAWING()
CLEARBACKGROUND(30, 30, 50)
REM Test math utility functions
LET test_value = -42.5
LET abs_result = ABS(test_value)
LET min_result = MIN(10, 20)
LET max_result = MAX(10, 20)
LET clamp_result = CLAMP(15, 10, 20)
LET clamp_low = CLAMP(5, 10, 20)
LET clamp_high = CLAMP(25, 10, 20)
REM Display results
DRAWTEXT("Math Utilities Test", 10, 10, 30, 255, 255, 255)
DRAWTEXT("ABS(-42.5) = " + STR(abs_result), 10, 50, 20, 255, 255, 255)
DRAWTEXT("MIN(10, 20) = " + STR(min_result), 10, 80, 20, 255, 255, 255)
DRAWTEXT("MAX(10, 20) = " + STR(max_result), 10, 110, 20, 255, 255, 255)
DRAWTEXT("CLAMP(15, 10, 20) = " + STR(clamp_result), 10, 140, 20, 255, 255, 255)
DRAWTEXT("CLAMP(5, 10, 20) = " + STR(clamp_low), 10, 170, 20, 255, 255, 255)
DRAWTEXT("CLAMP(25, 10, 20) = " + STR(clamp_high), 10, 200, 20, 255, 255, 255)
REM Test with time-based values
LET current_time = GETTIME()
LET time_abs = ABS(SIN(current_time))
LET time_min = MIN(SIN(current_time), COS(current_time))
LET time_max = MAX(SIN(current_time), COS(current_time))
LET time_clamp = CLAMP(SIN(current_time), -0.5, 0.5)
DRAWTEXT("Time-based tests:", 10, 250, 20, 255, 255, 255)
DRAWTEXT("ABS(SIN(time)) = " + STR(time_abs), 10, 280, 18, 255, 255, 255)
DRAWTEXT("MIN(SIN, COS) = " + STR(time_min), 10, 310, 18, 255, 255, 255)
DRAWTEXT("MAX(SIN, COS) = " + STR(time_max), 10, 340, 18, 255, 255, 255)
DRAWTEXT("CLAMP(SIN, -0.5, 0.5) = " + STR(time_clamp), 10, 370, 18, 255, 255, 255)
REM Draw some visual examples
LET x = 400
LET y = 300
LET size = 50 + (time_abs * 30)
DRAWCIRCLE(x, y, size, 255, 255, 0)
DRAWTEXT("Dynamic Circle", x - 40, y + size + 10, 16, 255, 255, 255)
REM Draw a line that changes length based on CLAMP
LET line_length = CLAMP(time_clamp * 200, 50, 150)
DRAWLINES(x - 100, y + 100, x - 100 + line_length, y + 100, 0, 255, 255)
DRAWTEXT("Clamped Line", x - 100, y + 120, 16, 255, 255, 255)
REM Instructions
DRAWTEXT("Press ESC to exit", 10, 550, 18, 200, 200, 200)
ENDDRAWING()
IF ISKEYPRESSED(256) THEN
running = FALSE
ENDIF
WEND
CLOSEWINDOW()
PRINT "Math utilities test completed!"
PRINT "ABS(-42.5) = " + STR(ABS(-42.5))
PRINT "MIN(10, 20) = " + STR(MIN(10, 20))
PRINT "MAX(10, 20) = " + STR(MAX(10, 20))
PRINT "CLAMP(15, 10, 20) = " + STR(CLAMP(15, 10, 20))