-
Notifications
You must be signed in to change notification settings - Fork 0
/
raylib.scm
99 lines (84 loc) · 2.06 KB
/
raylib.scm
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
(define-library (raylib)
;; TODO: check types
(import
(owl toplevel)
(owl string)
(owl core)
(raylib common)
(raylib window)
(raylib io)
(raylib draw)
(raylib util)
(raylib audio)
(raylib const)
(raylib raymath)
(raylib image)
)
(export
draw
with-window
with-mainloop
vec vec2 vec3 vec4 make-vector ;; same stuff
rec rectangle rect ;; same
(exports (raylib window))
(exports (raylib io))
(exports (raylib draw))
(exports (raylib util))
(exports (raylib audio))
(exports (raylib const))
(exports (raylib raymath))
(exports (raylib image))
)
(begin
;; this sucks
;; TODO: check if still needed
(define (ensure-rational f)
(read (number->string f)))
(define (vec2 a b)
(list (ensure-rational a)
(ensure-rational b)))
(define (vec3 a b c)
(list (ensure-rational a)
(ensure-rational b)
(ensure-rational c)))
(define (vec4 a b c d)
(list (ensure-rational a)
(ensure-rational b)
(ensure-rational c)
(ensure-rational d)))
(define rectangle vec4)
(define rect vec4)
(define rec vec4)
(define vec
(case-lambda
((a b) (vec2 a b))
((a b c) (vec3 a b c))
((a b c d) (vec4 a b c d))))
(define make-vector vec)
(define-syntax draw
(syntax-rules ()
((draw exp1 ...)
(when (window-ready?)
(begin-drawing)
exp1 ...
(end-drawing)))))
;; while !window-should-close do
(define-syntax with-mainloop
(syntax-rules ()
((with-window e ...)
(let loop ()
(if (window-should-close?)
0
(begin
e ...
(loop)))))))
;; create window. only 1 exp afterwards
(define-syntax with-window
(syntax-rules ()
((with-window width height title exp1)
(begin
(init-window width height title)
(let ((res exp1))
(close-window)
res)))))
))