diff options
Diffstat (limited to 'sources/main.c')
-rw-r--r-- | sources/main.c | 59 |
1 files changed, 38 insertions, 21 deletions
diff --git a/sources/main.c b/sources/main.c index 2bed9bc..9dcaad1 100644 --- a/sources/main.c +++ b/sources/main.c @@ -1,35 +1,52 @@ #include "raylib.h" +#include <libguile.h> +#include <math.h> +#include <stdio.h> +#include <stdlib.h> +#include <pthread.h> -#define SCREEN_WIDTH (800) -#define SCREEN_HEIGHT (450) -#define WINDOW_TITLE "Window title" - -int main(void) +static SCM rl_draw_text(SCM text) { - InitWindow(SCREEN_WIDTH, SCREEN_HEIGHT, WINDOW_TITLE); - SetTargetFPS(60); + scm_t_string_failed_conversion_handler handler; + char* str = scm_to_stringn(text, NULL, NULL, handler); + DrawText(str, 200, 80, 20, RED); +} - Texture2D texture = LoadTexture(ASSETS_PATH"test.png"); // Check README.md for how this works +static void* game (void* data) +{ + scm_c_define_gsubr ("rl-draw-text", 1, 0, 0, &rl_draw_text); + + const int screen_width = 800; + const int screen_height = 600; - while (!WindowShouldClose()) - { - BeginDrawing(); + InitWindow(screen_width, screen_height, "SLGJ - 2024"); + SetTargetFPS(60); - ClearBackground(RAYWHITE); + char filename[] = SCRIPTS_PATH"main.scm"; - const int texture_x = SCREEN_WIDTH / 2 - texture.width / 2; - const int texture_y = SCREEN_HEIGHT / 2 - texture.height / 2; - DrawTexture(texture, texture_x, texture_y, WHITE); + scm_c_primitive_load(filename); - const char* text = "OMG! IT WORKS!"; - const Vector2 text_size = MeasureTextEx(GetFontDefault(), text, 20, 1); - DrawText(text, SCREEN_WIDTH / 2 - text_size.x / 2, texture_y + texture.height + text_size.y + 10, 20, BLACK); + SCM guile_update = scm_variable_ref(scm_c_lookup("update")); + SCM guile_draw = scm_variable_ref(scm_c_lookup("draw")); - EndDrawing(); + while (!WindowShouldClose()) + { + scm_call_0(guile_update); + + BeginDrawing(); + ClearBackground(RAYWHITE); + scm_call_0(guile_draw); + EndDrawing(); } + + CloseWindow(); + + return NULL; +} - CloseWindow(); - return 0; +int main(int argc, char* argv[]) { + scm_with_guile (&game, NULL); + return 0; } |