-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathraylib_cube.fy
More file actions
73 lines (61 loc) · 1.74 KB
/
Copy pathraylib_cube.fy
File metadata and controls
73 lines (61 loc) · 1.74 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
( Rotating 3D cube demo )
import "libm"
import "raylib"
( Color packing: r g b a -- color )
: rgba 24 << swap 16 << or swap 8 << or swap or ;
:: RAYWHITE 245 245 245 255 rgba ;
:: DARKGRAY 80 80 80 255 rgba ;
:: RED 230 41 55 255 rgba ;
:: DARKBLUE 0 82 172 255 rgba ;
:: GOLD 255 203 0 255 rgba ;
:: LIGHTGRAY 200 200 200 255 rgba ;
struct: Camera3D
f32 position-x f32 position-y f32 position-z
f32 target-x f32 target-y f32 target-z
f32 up-x f32 up-y f32 up-z
f32 fovy i32 projection
;
( Update camera orbit position based on time )
: update-camera ( cam -- cam )
raylib:GetTime ( cam t )
dup libm:sin 8.0 f* ( cam t cx )
over libm:cos 8.0 f* ( cam t cx cz )
>r >r drop ( cam R: cz cx )
r> swap Camera3D.position-x! ( cam R: cz )
r> swap Camera3D.position-z! ( cam )
;
800 450 "fy - Rotating Cube" raylib:InitWindow
60 raylib:SetTargetFPS
:: cam
6.0 4.0 6.0 (position)
0.0 0.0 0.0 (target)
0.0 1.0 0.0 (up)
45.0 0 (fovy, projection)
Camera3D.new
;
: color RED ;
: frame
cam update-camera drop
raylib:BeginDrawing
RAYWHITE raylib:ClearBackground
cam raylib:BeginMode3D
( Draw solid cube )
0.0 0.0 0.0
2.0 2.0 2.0
color
raylib:DrawCube
( Draw wireframe )
0.0 0.0 0.0
2.0 2.0 2.0
DARKGRAY
raylib:DrawCubeWires
( Draw ground grid )
10 1.0 raylib:DrawGrid
raylib:EndMode3D
"fy - Rotating Cube" 10 10 20 DARKGRAY raylib:DrawText
10 40 raylib:DrawFPS
raylib:EndDrawing
;
: running? raylib:WindowShouldClose 0 = ;
running? [ drop frame running? ] repeat
raylib:CloseWindow