summaryrefslogtreecommitdiff
path: root/sources/rl/core.h
diff options
context:
space:
mode:
authorHenrique Alves <henrique.alves@itsjungle.xyz>2024-04-29 10:23:52 +0300
committerHenrique Alves <henrique.alves@itsjungle.xyz>2024-04-29 10:23:52 +0300
commitaeddacb8d88f41ba7bdf37d39de17d8cf3b6a258 (patch)
tree2daee509556bb1e7a9b74dc610b2ef4831392fdb /sources/rl/core.h
parent94e1881676e39bd8b8e6a8ee98e541102b380549 (diff)
downloadgamejam-slgj-2024-aeddacb8d88f41ba7bdf37d39de17d8cf3b6a258.tar.gz
gamejam-slgj-2024-aeddacb8d88f41ba7bdf37d39de17d8cf3b6a258.tar.bz2
gamejam-slgj-2024-aeddacb8d88f41ba7bdf37d39de17d8cf3b6a258.zip
Creating small evaluation prompt
Diffstat (limited to 'sources/rl/core.h')
-rw-r--r--sources/rl/core.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/sources/rl/core.h b/sources/rl/core.h
new file mode 100644
index 0000000..09c5555
--- /dev/null
+++ b/sources/rl/core.h
@@ -0,0 +1,35 @@
+#include "raylib.h"
+#include "s7/s7.h"
+#include <stdio.h>
+#include <stdlib.h>
+
+static s7_pointer rl_get_mouse_position(s7_scheme *s7, s7_pointer args) {
+ Vector2 mouse_pos = GetMousePosition();
+ s7_pointer vec = s7_make_float_vector(s7, 2, 1, NULL);
+ s7_vector_set(s7, vec, 0, s7_make_real(s7, mouse_pos.x));
+ s7_vector_set(s7, vec, 1, s7_make_real(s7, mouse_pos.y));
+ return vec;
+}
+
+static s7_pointer rl_is_key_down(s7_scheme *s7, s7_pointer args) {
+ int key = s7_integer(s7_car(args));
+ bool isKey = IsKeyDown(key);
+ return(s7_make_boolean(s7, isKey));
+}
+
+static s7_pointer rl_get_char_pressed(s7_scheme *s7, s7_pointer args) {
+ int key = GetCharPressed();
+ return(s7_make_integer(s7, key));
+}
+
+static s7_pointer rl_get_key_pressed(s7_scheme *s7, s7_pointer args) {
+ int key = GetKeyPressed();
+ return(s7_make_integer(s7, key));
+}
+
+static void rl_core_define_methods(s7_scheme *s7) {
+ s7_define_function(s7, "rl-is-key-down", rl_is_key_down, 1, 0, false, "(rl-is-key-down KEY)");
+ s7_define_function(s7, "rl-get-mouse-position", rl_get_mouse_position, 0, 0, false, "(rl-get-mouse-position)");
+ s7_define_function(s7, "rl-get-char-pressed", rl_get_char_pressed, 0, 0, false, "(rl-get-char-pressed)");
+ s7_define_function(s7, "rl-get-key-pressed", rl_get_key_pressed, 0, 0, false, "(rl-get-key-pressed)");
+}