diff options
Diffstat (limited to 'sources/rl')
-rw-r--r-- | sources/rl/core.h | 12 | ||||
-rw-r--r-- | sources/rl/shapes.h | 14 | ||||
-rw-r--r-- | sources/rl/types.h | 4 |
3 files changed, 28 insertions, 2 deletions
diff --git a/sources/rl/core.h b/sources/rl/core.h index 09c5555..14d8ba6 100644 --- a/sources/rl/core.h +++ b/sources/rl/core.h @@ -11,12 +11,22 @@ static s7_pointer rl_get_mouse_position(s7_scheme *s7, s7_pointer args) { return vec; } +static s7_pointer rl_is_mouse_button_pressed(s7_scheme *s7, s7_pointer args) { + bool isPressed = IsMouseButtonPressed(0); + return(s7_make_boolean(s7, isPressed)); +} + 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_frame_time(s7_scheme *s7, s7_pointer args) { + float dt = GetFrameTime(); + return(s7_make_real(s7, dt)); +} + static s7_pointer rl_get_char_pressed(s7_scheme *s7, s7_pointer args) { int key = GetCharPressed(); return(s7_make_integer(s7, key)); @@ -32,4 +42,6 @@ static void rl_core_define_methods(s7_scheme *s7) { 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)"); + s7_define_function(s7, "rl-get-frame-time", rl_get_frame_time, 0, 0, false, "(rl-get-frame-time)"); + s7_define_function(s7, "rl-is-mouse-button-pressed", rl_is_mouse_button_pressed, 0, 0, false, "(rl_is_mouse_button_pressed)"); } diff --git a/sources/rl/shapes.h b/sources/rl/shapes.h index 10d38eb..47e736c 100644 --- a/sources/rl/shapes.h +++ b/sources/rl/shapes.h @@ -15,6 +15,20 @@ static s7_pointer rl_draw_rectangle(s7_scheme *s7, s7_pointer args) { return(NULL); } +static s7_pointer rl_draw_line(s7_scheme *s7, s7_pointer args) { + Color *c = (Color *)s7_c_object_value(s7_car(s7_cdr(s7_cdr(s7_cdr(s7_cdr(args)))))); + + DrawLine(s7_real(s7_car(args)), + s7_real(s7_car(s7_cdr(args))), + s7_real(s7_car(s7_cdr(s7_cdr(args)))), + s7_real(s7_car(s7_cdr(s7_cdr(s7_cdr(args))))), + *c); + + return(NULL); +} + + static void rl_shapes_define_methods(s7_scheme *s7) { s7_define_function(s7, "rl-draw-rectangle", rl_draw_rectangle, 5, 0, false, "test"); + s7_define_function(s7, "rl-draw-line", rl_draw_line, 5, 0, false, "test"); } diff --git a/sources/rl/types.h b/sources/rl/types.h index 4a7244f..da426ae 100644 --- a/sources/rl/types.h +++ b/sources/rl/types.h @@ -21,7 +21,7 @@ static s7_pointer make_color(s7_scheme *sc, s7_pointer args) c->r = s7_integer(s7_car(args)); c->g = s7_integer(s7_cadr(args)); c->b = s7_integer(s7_caddr(args)); - c->a = 255; + c->a = s7_integer(s7_cadddr(args)); return(s7_make_c_object(sc, color_type_tag, (void *)c)); } @@ -92,7 +92,7 @@ static void rl_register_types(s7_scheme *s7) { s7_c_type_set_gc_free(s7, color_type_tag, free_color); s7_c_type_set_to_string(s7, color_type_tag, color_to_string); - s7_define_function(s7, "make-color", make_color, 3, 0, false, "(make-color r g b) makes a new color"); + s7_define_function(s7, "make-color", make_color, 4, 0, false, "(make-color r g b a) makes a new color"); s7_define_function(s7, "color?", is_color, 1, 0, false, "(color? anything) returns #t if its argument is a color object"); |