summaryrefslogtreecommitdiff
path: root/sources
diff options
context:
space:
mode:
Diffstat (limited to 'sources')
-rw-r--r--sources/core.h14
-rw-r--r--sources/main.c7
-rw-r--r--sources/text.h30
-rw-r--r--sources/texture.h29
4 files changed, 50 insertions, 30 deletions
diff --git a/sources/core.h b/sources/core.h
new file mode 100644
index 0000000..7e387de
--- /dev/null
+++ b/sources/core.h
@@ -0,0 +1,14 @@
+#include "raylib.h"
+#include "s7.h"
+#include <stdio.h>
+#include <stdlib.h>
+
+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 void rl_core_define_methods(s7_scheme *s7) {
+ s7_define_function(s7, "rl-is-key-down", rl_is_key_down, 1, 0, false, "test");
+}
diff --git a/sources/main.c b/sources/main.c
index 3601fe3..5086080 100644
--- a/sources/main.c
+++ b/sources/main.c
@@ -4,8 +4,10 @@
#endif
#include "raylib.h"
-#include "text.h"
#include "s7.h"
+#include "text.h"
+#include "texture.h"
+#include "core.h"
#include <math.h>
#include <stdio.h>
@@ -41,6 +43,8 @@ int main(int argc, char* argv[]) {
s7 = s7_init();
rl_text_define_methods(s7);
+ rl_texture_define_methods(s7);
+ rl_core_define_methods(s7);
const int screen_width = 800;
const int screen_height = 600;
@@ -48,7 +52,6 @@ int main(int argc, char* argv[]) {
InitWindow(screen_width, screen_height, "SLGJ - 2024");
SetTargetFPS(60);
- printf("foi");
char filename[] = SCRIPTS_PATH"main.scm";
s7_load(s7, filename);
diff --git a/sources/text.h b/sources/text.h
index fed7181..a0e3497 100644
--- a/sources/text.h
+++ b/sources/text.h
@@ -3,38 +3,12 @@
#include <stdio.h>
#include <stdlib.h>
-int texture_2d_tag;
-
-static s7_pointer free_texture_2d(s7_scheme *s7, s7_pointer obj) {
- Texture2D *texture = (Texture2D *) s7_c_object_value(obj);
- UnloadTexture(*texture);
- free(texture);
- return(NULL);
-}
-
static s7_pointer rl_draw_text(s7_scheme *s7, s7_pointer args) {
+ printf("%s\n", s7_string(s7_car(args)));
DrawText(s7_string(s7_car(args)), 200, 80, 20, RED);
return(NULL);
}
-static s7_pointer rl_draw_texture(s7_scheme *s7, s7_pointer args) {
- Texture2D *texture = (Texture2D *) s7_c_object_value(s7_car(args));
- DrawTexture(*texture, 100, 100, WHITE);
- return(NULL);
-}
-
-static s7_pointer rl_load_texture(s7_scheme *s7, s7_pointer args) {
- Texture2D texture = LoadTexture("./assets/test.png");
- Texture2D *texture_ptr = (Texture2D *) malloc(sizeof(Texture2D));
- *texture_ptr = texture;
- return (s7_make_c_object(s7, texture_2d_tag, (void *) texture_ptr));
-}
-
static void rl_text_define_methods(s7_scheme *s7) {
- s7_define_safe_function(s7, "rl-draw-text", rl_draw_text, 1, 0, false, "test");
- s7_define_safe_function(s7, "rl-load-texture", rl_load_texture, 0, 0, false, "test");
- s7_define_safe_function(s7, "rl-draw-texture", rl_draw_texture, 1, 0, false, "test");
-
- texture_2d_tag = s7_make_c_type(s7, "texture-2d");
- s7_c_type_set_gc_free(s7, texture_2d_tag, free_texture_2d);
+ s7_define_function(s7, "rl-draw-text", rl_draw_text, 1, 0, false, "test");
}
diff --git a/sources/texture.h b/sources/texture.h
new file mode 100644
index 0000000..8dfb996
--- /dev/null
+++ b/sources/texture.h
@@ -0,0 +1,29 @@
+int texture_2d_tag;
+
+static s7_pointer free_texture_2d(s7_scheme *s7, s7_pointer obj) {
+ Texture2D *texture = (Texture2D *) s7_c_object_value(obj);
+ UnloadTexture(*texture);
+ free(texture);
+ return(NULL);
+}
+
+static s7_pointer rl_draw_texture(s7_scheme *s7, s7_pointer args) {
+ Texture2D *texture = (Texture2D *) s7_c_object_value(s7_car(args));
+ DrawTexture(*texture, 100, 100, WHITE);
+ return(NULL);
+}
+
+static s7_pointer rl_load_texture(s7_scheme *s7, s7_pointer args) {
+ Texture2D texture = LoadTexture("./assets/test.png");
+ Texture2D *texture_ptr = (Texture2D *) malloc(sizeof(Texture2D));
+ *texture_ptr = texture;
+ return (s7_make_c_object(s7, texture_2d_tag, (void *) texture_ptr));
+}
+
+static void rl_texture_define_methods(s7_scheme *s7) {
+ s7_define_function(s7, "rl-load-texture", rl_load_texture, 0, 0, false, "test");
+ s7_define_function(s7, "rl-draw-texture", rl_draw_texture, 1, 0, false, "test");
+
+ texture_2d_tag = s7_make_c_type(s7, "texture-2d");
+ s7_c_type_set_gc_free(s7, texture_2d_tag, free_texture_2d);
+}