summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core.c18
-rw-r--r--src/raylib.c49
-rw-r--r--src/types.c52
3 files changed, 62 insertions, 57 deletions
diff --git a/src/core.c b/src/core.c
index e6b290f..96df1ae 100644
--- a/src/core.c
+++ b/src/core.c
@@ -1,13 +1,6 @@
-#include "raylib/core.h"
-
-const struct mrb_data_type Color_type = {
- "Color", mrb_free
-};
-
-const struct mrb_data_type Rectangle_type = {
- "Rectangle", mrb_free
-};
-
+#include "mruby-raylib/core.h"
+#include "mruby-raylib/types.h"
+#include <raylib.h>
/*
* @overload init_window(width: 800, height: 600, title: "Hello World from Raylib!")
* @param width [Integer]
@@ -138,6 +131,11 @@ mrb_begin_scissor_mode(mrb_state* mrb, mrb_value self) {
kw_values[1] = mrb_fixnum_value(y);
kw_values[2] = mrb_fixnum_value(width);
kw_values[3] = mrb_fixnum_value(height);
+ } else {
+ kw_values[0] = mrb_ensure_int_type(mrb, kw_values[0]);
+ kw_values[1] = mrb_ensure_int_type(mrb, kw_values[1]);
+ kw_values[2] = mrb_ensure_int_type(mrb, kw_values[2]);
+ kw_values[3] = mrb_ensure_int_type(mrb, kw_values[3]);
}
BeginScissorMode(mrb_fixnum(kw_values[0]), mrb_fixnum(kw_values[1]), mrb_fixnum(kw_values[2]), mrb_fixnum(kw_values[3]));
return mrb_nil_value();
diff --git a/src/raylib.c b/src/raylib.c
index dd69f96..56bdf96 100644
--- a/src/raylib.c
+++ b/src/raylib.c
@@ -1,12 +1,11 @@
+#include "mruby-raylib/types.h"
+#include "mruby-raylib/core.h"
#include <raylib.h>
-#include <mruby.h>
#include <mruby/array.h>
-#include <mruby/data.h>
#include <mruby/class.h>
#include <mruby/numeric.h>
#include <mruby/string.h>
#include <stdlib.h>
-#include "raylib/core.h"
#if defined(PLATFORM_WEB)
#include <emscripten/emscripten.h>
#endif
@@ -14,54 +13,10 @@
#if defined(PLATFORM_WEB)
void execute_emscripten_block(void*);
#endif
-void helper_texture_free(mrb_state*, void*);
-void helper_sound_free(mrb_state*, void*);
-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 Texture_type = {
- "Texture", helper_texture_free
-};
-
-void
-helper_texture_free(mrb_state* mrb, void*ptr) {
- Texture *texture = (Texture*)ptr;
- UnloadTexture(*texture);
- mrb_free(mrb, ptr);
-}
-
-static const struct mrb_data_type Sound_type = {
- "Sound", helper_sound_free
-};
-
-void
-helper_sound_free(mrb_state* mrb, void*ptr) {
- Sound *sound = (Sound*)ptr;
- UnloadSound(*sound);
- mrb_free(mrb, ptr);
-}
-
-static const struct mrb_data_type Vector2_type = {
- "Vector2", mrb_free
-};
-
-
-static const struct mrb_data_type NPatchInfo_type = {
- "NPatchInfo", mrb_free
-};
-
-static const struct mrb_data_type Music_type = {
- "Music", helper_music_free
-};
-
-void
-helper_music_free(mrb_state* mrb, void*ptr) {
- Music *music = (Music*)ptr;
- UnloadMusicStream(*music);
- mrb_free(mrb, ptr);
-}
static mrb_value
diff --git a/src/types.c b/src/types.c
new file mode 100644
index 0000000..c1b3e34
--- /dev/null
+++ b/src/types.c
@@ -0,0 +1,52 @@
+#include "mruby-raylib/types.h"
+#include <raylib.h>
+
+const struct mrb_data_type Color_type = {
+ "Color", mrb_free
+};
+
+const struct mrb_data_type Rectangle_type = {
+ "Rectangle", mrb_free
+};
+
+const struct mrb_data_type Texture_type = {
+ "Texture", helper_texture_free
+};
+
+void
+helper_texture_free(mrb_state* mrb, void*ptr) {
+ Texture *texture = (Texture*)ptr;
+ UnloadTexture(*texture);
+ mrb_free(mrb, ptr);
+}
+
+const struct mrb_data_type Sound_type = {
+ "Sound", helper_sound_free
+};
+
+void
+helper_sound_free(mrb_state* mrb, void*ptr) {
+ Sound *sound = (Sound*)ptr;
+ UnloadSound(*sound);
+ mrb_free(mrb, ptr);
+}
+
+const struct mrb_data_type Music_type = {
+ "Music", helper_music_free
+};
+
+void
+helper_music_free(mrb_state* mrb, void*ptr) {
+ Music *music = (Music*)ptr;
+ UnloadMusicStream(*music);
+ mrb_free(mrb, ptr);
+}
+
+const struct mrb_data_type Vector2_type = {
+ "Vector2", mrb_free
+};
+
+const struct mrb_data_type NPatchInfo_type = {
+ "NPatchInfo", mrb_free
+};
+