summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorrealtradam <[email protected]>2022-02-05 02:50:11 -0500
committerrealtradam <[email protected]>2022-02-05 02:50:11 -0500
commitdab2484365ef384a88a0f43e979c1d840318711d (patch)
treea25fee7e03341c63e6cfc704dbd6925df06c08cb
parent1efc0942ebc13c9bb7eddeb38be150a1b11ab49b (diff)
downloadmruby-raylib-dab2484365ef384a88a0f43e979c1d840318711d.tar.gz
mruby-raylib-dab2484365ef384a88a0f43e979c1d840318711d.zip
doesnt work pepehands
-rw-r--r--.yardoc/checksums4
-rw-r--r--.yardoc/object_typesbin4911 -> 4911 bytes
-rw-r--r--.yardoc/objects/root.datbin72120 -> 72914 bytes
-rw-r--r--Rakefile19
-rw-r--r--include/raylib/core.h5
-rw-r--r--mrblib/raylib.rb8
-rw-r--r--src/core.c53
-rw-r--r--src/raylib.c12
8 files changed, 56 insertions, 45 deletions
diff --git a/.yardoc/checksums b/.yardoc/checksums
index c23bbfe..f8ac59d 100644
--- a/.yardoc/checksums
+++ b/.yardoc/checksums
@@ -1,3 +1,3 @@
mrblib/raylib.rb ce42382655c9ad1b0aa789cfb6d45d08be4eaf94
-src/core.c 0500b1e45bbbecf8c2fa2828781070044bd676c7
-src/raylib.c eb2e710a0df02ee30563454790c715cede73189a
+src/core.c b6db3cd16136b72a42912955e51a0745dfc5429b
+src/raylib.c 4c1742dd879b28455ab020b4a51b7bda9916ee60
diff --git a/.yardoc/object_types b/.yardoc/object_types
index ff3ed41..63384f0 100644
--- a/.yardoc/object_types
+++ b/.yardoc/object_types
Binary files differ
diff --git a/.yardoc/objects/root.dat b/.yardoc/objects/root.dat
index 5cb5a82..42e3414 100644
--- a/.yardoc/objects/root.dat
+++ b/.yardoc/objects/root.dat
Binary files differ
diff --git a/Rakefile b/Rakefile
index fb6c606..22cef3f 100644
--- a/Rakefile
+++ b/Rakefile
@@ -1,22 +1,11 @@
-require 'yard'
+require 'bundler'
-task default: [:api]
-#task default: [:yard]
+Bundler.setup(:default, :yard)
-#YARD::Rake::YardocTask.new do |t|
-# t.files = ['./mrblib/*', 'src/*']
-# t.options = ['--output-dir', './docs', 'yardoc --markup=markdown|textile|rdoc(default)', '--plugin mruby']
-# t.stats_options = ['--list-undoc']
-#end
-#
-YARD::Rake::YardocTask.new do |t|
- t.files = ['mrblib/raylib.rb', 'mrbdoc/core.rb'] # ['system_manager.rb', 'component_manager.rb', 'entity_manager.rb', 'scene_manager.rb', 'stage_manager.rb', 'felecs.rb']
- t.options = ['--output-dir', './docs', 'yardoc --markup=markdown|textile|rdoc(default)']
- t.stats_options = ['--list-undoc']
-end
+task default: [:yard]
desc 'generate yard docs'
-task :api do
+task :yard do
begin
sh "mrbdoc"
rescue
diff --git a/include/raylib/core.h b/include/raylib/core.h
index 4d27650..8ba03ca 100644
--- a/include/raylib/core.h
+++ b/include/raylib/core.h
@@ -9,6 +9,11 @@
#include <emscripten/emscripten.h>
#endif
+
+static const struct mrb_data_type Color_type = {
+ "Color", mrb_free
+};
+
void mrb_init_raylib_core(mrb_state*);
#endif /* end of include guard MRUBY_RAYLIB_CORE_H */
diff --git a/mrblib/raylib.rb b/mrblib/raylib.rb
index ed98340..e0061a2 100644
--- a/mrblib/raylib.rb
+++ b/mrblib/raylib.rb
@@ -38,6 +38,14 @@ module Raylib
end
end
+ class Color
+ class << self
+ def raywhite
+ @raywhite ||= Color.new(245, 245, 245, 255)
+ end
+ end
+ end
+
class << self
attr_accessor :defined_loop
attr_accessor :data_keys_pressed
diff --git a/src/core.c b/src/core.c
index 6fdedb8..4f6a80b 100644
--- a/src/core.c
+++ b/src/core.c
@@ -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));
}
diff --git a/src/raylib.c b/src/raylib.c
index 36b4550..120802c 100644
--- a/src/raylib.c
+++ b/src/raylib.c
@@ -20,9 +20,6 @@ void helper_music_free(mrb_state*, void*);
bool check_collision_circle_rec(mrb_state* mrb, mrb_value circle_obj, mrb_value rec_obj);
-static const struct mrb_data_type Color_type = {
- "Color", mrb_free
-};
static const struct mrb_data_type Texture_type = {
"Texture", helper_texture_free
@@ -850,14 +847,6 @@ mrb_end_drawing(mrb_state* mrb, mrb_value self) {
return mrb_nil_value();
}
-static mrb_value
-mrb_clear_background(mrb_state* mrb, mrb_value self) {
- mrb_value color_obj;
- mrb_get_args(mrb, "o", &color_obj);
- Color *color_data = DATA_GET_PTR(mrb, color_obj, &Color_type, Color);
- ClearBackground(*color_data);
- return mrb_nil_value();
-}
static mrb_value
mrb_call_main_loop(mrb_state* mrb, mrb_value self) {
@@ -1014,7 +1003,6 @@ mrb_mruby_raylib_gem_init(mrb_state* mrb) {
mrb_define_module_function(mrb, raylib, "_draw_text", mrb_draw_text, MRB_ARGS_OPT(5));
mrb_define_module_function(mrb, raylib, "begin_drawing", mrb_begin_drawing, MRB_ARGS_NONE());
mrb_define_module_function(mrb, raylib, "end_drawing", mrb_end_drawing, MRB_ARGS_NONE());
- mrb_define_module_function(mrb, raylib, "clear_background", mrb_clear_background, MRB_ARGS_REQ(1));
mrb_define_module_function(mrb, raylib, "call_main_loop", mrb_call_main_loop, MRB_ARGS_NONE());
mrb_define_module_function(mrb, raylib, "target_fps=", mrb_target_fps, MRB_ARGS_REQ(1));
mrb_define_module_function(mrb, raylib, "fps", mrb_fps, MRB_ARGS_NONE());