diff options
| author | realtradam <[email protected]> | 2022-02-05 02:50:11 -0500 |
|---|---|---|
| committer | realtradam <[email protected]> | 2022-02-05 02:50:11 -0500 |
| commit | dab2484365ef384a88a0f43e979c1d840318711d (patch) | |
| tree | a25fee7e03341c63e6cfc704dbd6925df06c08cb /src/core.c | |
| parent | 1efc0942ebc13c9bb7eddeb38be150a1b11ab49b (diff) | |
| download | mruby-raylib-dab2484365ef384a88a0f43e979c1d840318711d.tar.gz mruby-raylib-dab2484365ef384a88a0f43e979c1d840318711d.zip | |
doesnt work pepehands
Diffstat (limited to 'src/core.c')
| -rw-r--r-- | src/core.c | 53 |
1 files changed, 37 insertions, 16 deletions
@@ -1,27 +1,17 @@ #include "raylib/core.h" + /* - * @overload init_window(screen_width: 800, screen_height: 600, title: "Hello World from FelFlame!") - * @param [Integer] width ye - * @overload init_window(screen_width, screen_height, title) - * - * Initialize window and OpenGL context. - * - * *Parameters:* - * - * * *width* (+Integer+) - * - * * *height* (+Integer+) - * - * * *title* (+String+) - * - * @return (Nil) + * @overload init_window(width: 800, height: 600, title: "Hello World from Raylib!") + * @param width [Integer] + * @param height [Integer] + * @param title [String] */ static mrb_value mrb_init_window(mrb_state* mrb, mrb_value self) { mrb_int screenWidth = 800; mrb_int screenHeight = 600; - char* title = "Hello World from FelFlame!"; + char* title = "Hello World from Raylib!"; uint32_t kw_num = 3; const mrb_sym kw_names[] = { @@ -49,15 +39,46 @@ mrb_init_window(mrb_state* mrb, mrb_value self) { } +/* + * Check if KEY_ESCAPE pressed or Close icon pressed + * @overload should_window_close?() + */ static mrb_value mrb_window_should_close(mrb_state* mrb, mrb_value self) { return mrb_bool_value(WindowShouldClose()); } +/* + * Set background color *(framebuffer clear color)* + * @overload clear_background(color: Rl:Color.raywhite) + * @param color [Rl::Color] + * @return [Nil] + */ +static mrb_value +mrb_clear_background(mrb_state* mrb, mrb_value self) { + struct RClass *raylib = mrb_module_get(mrb, "Raylib"); + struct RClass *color = mrb_class_get_under(mrb, raylib, Color_type.struct_name); + mrb_value color_obj = mrb_funcall(mrb, mrb_obj_value(color), "raywhite", 0); + + uint32_t kw_num = 1; + const mrb_sym kw_names[] = { + mrb_intern_lit(mrb, "color"), + }; + mrb_value kw_values[kw_num]; + const mrb_kwargs kwargs = { kw_num, 0, kw_names, kw_values, NULL }; + mrb_get_args(mrb, "|o:", &color_obj, &kwargs); + + + Color *color_data = DATA_GET_PTR(mrb, color_obj, &Color_type, Color); + ClearBackground(*color_data); + return mrb_nil_value(); +} + void mrb_init_raylib_core(mrb_state* mrb) { struct RClass *raylib = mrb_define_module(mrb, "Raylib"); mrb_define_module_function(mrb, raylib, "init_window", mrb_init_window, MRB_ARGS_OPT(3)); mrb_define_module_function(mrb, raylib, "window_should_close?", mrb_window_should_close, MRB_ARGS_NONE()); + mrb_define_module_function(mrb, raylib, "clear_background", mrb_clear_background, MRB_ARGS_REQ(1)); } |
