ruby2d 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5a8a4ec99e4973a77f73aa07a46accf88b4d6ab4
4
- data.tar.gz: 73fbe78e3065d33795a1da5bb187b118075f9f58
3
+ metadata.gz: 2ef4f4bead6ed9ee601f91c0d16240f247fc2c49
4
+ data.tar.gz: 97f7c8fdd9c7292e9a54f5f08cca319ea8e6e6ae
5
5
  SHA512:
6
- metadata.gz: 18d3baa25a0dc7819f7b22ad49add7f1562356cc978aa52886020c68a54586063ab7ef4cecad07482c4933c8dd82955a7cfb2143b2c00cf1fc737c191ed68f00
7
- data.tar.gz: fd5aed42f38a5431f8f7821c062cf5b52ee4ecf31c36990dd4e5b477bb064e00b719478356abdd93cadbff0e4ad64b33ae8ab85c273b625fcb5ef663bbac220c
6
+ metadata.gz: 208b10d8e88d98e2f3cb208fbc1725794b334d05894b9d71c22f793f2e3dfb96ae4e168780ee98536e43f2931eb4fa2492d1da4b4143415b7bb852f51a6360b2
7
+ data.tar.gz: 1eb73fb64d4c76883a6e3a3aa6d69f5a52e9bede5124f580d4f10cf659a09e4fec1f12842b8fd61ce69699424d774cfb43ba330cd33f10d2bfaab814c9198304
@@ -1,6 +1,6 @@
1
1
  require 'mkmf'
2
2
 
3
- S2D_VERSION = '0.6.0' # Simple 2D minimum version required
3
+ S2D_VERSION = '0.7.0' # Simple 2D minimum version required
4
4
  $errors = []
5
5
 
6
6
  class String
@@ -4,19 +4,10 @@
4
4
  $R2D_WINDOW = nil
5
5
 
6
6
  # Simple 2D window
7
- `var win;`
8
-
9
-
10
- `// ruby2d.js
11
-
12
- // @type_id values for rendering
13
- const $R2D_TRIANGLE = 1;
14
- const $R2D_QUAD = 2;
15
- const $R2D_LINE = 3;
16
- const $R2D_IMAGE = 4;
17
- const $R2D_SPRITE = 5;
18
- const $R2D_TEXT = 6;
7
+ `
8
+ var win;
19
9
 
10
+ // ruby2d.js
20
11
 
21
12
  function on_key(e) {
22
13
 
@@ -104,148 +95,162 @@ function render() {
104
95
  var objects = #{$R2D_WINDOW.objects};
105
96
 
106
97
  for (var i = 0; i < objects.length; i++) {
107
-
108
98
  var el = objects[i];
99
+ el['$ext_render']();
100
+ }
101
+ }
102
+ `
109
103
 
110
- switch (el.type_id) {
111
-
112
- case $R2D_TRIANGLE:
113
-
114
- S2D.DrawTriangle(
115
- el.x1, el.y1, el.c1.r, el.c1.g, el.c1.b, el.c1.a,
116
- el.x2, el.y2, el.c2.r, el.c2.g, el.c2.b, el.c2.a,
117
- el.x3, el.y3, el.c3.r, el.c3.g, el.c3.b, el.c3.a
118
- );
119
- break;
120
-
121
- case $R2D_QUAD:
122
- S2D.DrawQuad(
123
- el.x1, el.y1, el.c1.r, el.c1.g, el.c1.b, el.c1.a,
124
- el.x2, el.y2, el.c2.r, el.c2.g, el.c2.b, el.c2.a,
125
- el.x3, el.y3, el.c3.r, el.c3.g, el.c3.b, el.c3.a,
126
- el.x4, el.y4, el.c4.r, el.c4.g, el.c4.b, el.c4.a
127
- );
128
- break;
129
-
130
- case $R2D_LINE:
131
- S2D.DrawLine(
132
- el.x1, el.y1, el.x2, el.y2, el.width,
133
- el.c1.r, el.c1.g, el.c1.b, el.c1.a,
134
- el.c2.r, el.c2.g, el.c2.b, el.c2.a,
135
- el.c3.r, el.c3.g, el.c3.b, el.c3.a,
136
- el.c4.r, el.c4.g, el.c4.b, el.c4.a
137
- );
138
- break;
139
-
140
- case $R2D_IMAGE:
141
- el.data.x = el.x;
142
- el.data.y = el.y;
143
-
144
- if (el.width != Opal.nil) el.data.width = el.width;
145
- if (el.height != Opal.nil) el.data.height = el.height;
146
-
147
- el.data.color.r = el.color.r;
148
- el.data.color.g = el.color.g;
149
- el.data.color.b = el.color.b;
150
- el.data.color.a = el.color.a;
151
-
152
- S2D.DrawImage(el.data);
153
- break;
154
-
155
- case $R2D_SPRITE:
156
- el.data.x = el.x;
157
- el.data.y = el.y;
158
-
159
- S2D.ClipSprite(
160
- el.data,
161
- el.clip_x,
162
- el.clip_y,
163
- el.clip_w,
164
- el.clip_h
165
- );
166
-
167
- S2D.DrawSprite(el.data);
168
- break;
169
-
170
- case $R2D_TEXT:
171
- el.data.x = el.x;
172
- el.data.y = el.y;
173
-
174
- el.data.color.r = el.color.r;
175
- el.data.color.g = el.color.g;
176
- el.data.color.b = el.color.b;
177
- el.data.color.a = el.color.a;
178
104
 
179
- S2D.DrawText(el.data);
180
- break;
181
- }
105
+ module Ruby2D
106
+ class Triangle
107
+ def ext_render
108
+ `S2D.DrawTriangle(
109
+ #{self}.x1, #{self}.y1, #{self}.c1.r, #{self}.c1.g, #{self}.c1.b, #{self}.c1.a,
110
+ #{self}.x2, #{self}.y2, #{self}.c2.r, #{self}.c2.g, #{self}.c2.b, #{self}.c2.a,
111
+ #{self}.x3, #{self}.y3, #{self}.c3.r, #{self}.c3.g, #{self}.c3.b, #{self}.c3.a
112
+ );`
113
+ end
114
+ end
182
115
 
183
- }
184
- }`
116
+ class Quad
117
+ def ext_render
118
+ `S2D.DrawQuad(
119
+ #{self}.x1, #{self}.y1, #{self}.c1.r, #{self}.c1.g, #{self}.c1.b, #{self}.c1.a,
120
+ #{self}.x2, #{self}.y2, #{self}.c2.r, #{self}.c2.g, #{self}.c2.b, #{self}.c2.a,
121
+ #{self}.x3, #{self}.y3, #{self}.c3.r, #{self}.c3.g, #{self}.c3.b, #{self}.c3.a,
122
+ #{self}.x4, #{self}.y4, #{self}.c4.r, #{self}.c4.g, #{self}.c4.b, #{self}.c4.a
123
+ );`
124
+ end
125
+ end
185
126
 
127
+ class Line
128
+ def ext_render
129
+ `S2D.DrawLine(
130
+ #{self}.x1, #{self}.y1, #{self}.x2, #{self}.y2, #{self}.width,
131
+ #{self}.c1.r, #{self}.c1.g, #{self}.c1.b, #{self}.c1.a,
132
+ #{self}.c2.r, #{self}.c2.g, #{self}.c2.b, #{self}.c2.a,
133
+ #{self}.c3.r, #{self}.c3.g, #{self}.c3.b, #{self}.c3.a,
134
+ #{self}.c4.r, #{self}.c4.g, #{self}.c4.b, #{self}.c4.a
135
+ );`
136
+ end
137
+ end
186
138
 
187
- module Ruby2D
188
139
  class Image
189
- def ext_image_init(path)
190
- `#{self}.data = S2D.CreateImage(path, function() {
140
+ def ext_init(path)
141
+ `
142
+ #{self}.data = S2D.CreateImage(path, function() {
191
143
  if (#{@width} == Opal.nil) {
192
144
  #{@width} = #{self}.data.width;
193
145
  }
194
146
  if (#{@height} == Opal.nil) {
195
147
  #{@height} = #{self}.data.height;
196
148
  }
197
- });`
149
+ });
150
+ `
151
+ end
152
+
153
+ def ext_render
154
+ `
155
+ #{self}.data.x = #{self}.x;
156
+ #{self}.data.y = #{self}.y;
157
+
158
+ if (#{self}.width != Opal.nil) #{self}.data.width = #{self}.width;
159
+ if (#{self}.height != Opal.nil) #{self}.data.height = #{self}.height;
160
+
161
+ #{self}.data.color.r = #{self}.color.r;
162
+ #{self}.data.color.g = #{self}.color.g;
163
+ #{self}.data.color.b = #{self}.color.b;
164
+ #{self}.data.color.a = #{self}.color.a;
165
+
166
+ S2D.DrawImage(#{self}.data);
167
+ `
198
168
  end
199
169
  end
200
170
 
201
171
  class Sprite
202
- def ext_sprite_init(path)
172
+ def ext_init(path)
203
173
  `#{self}.data = S2D.CreateSprite(path);`
204
174
  end
175
+
176
+ def ext_render
177
+ `
178
+ #{self}.data.x = #{self}.x;
179
+ #{self}.data.y = #{self}.y;
180
+
181
+ S2D.ClipSprite(
182
+ #{self}.data,
183
+ #{self}.clip_x,
184
+ #{self}.clip_y,
185
+ #{self}.clip_w,
186
+ #{self}.clip_h
187
+ );
188
+
189
+ S2D.DrawSprite(#{self}.data);
190
+ `
191
+ end
205
192
  end
206
193
 
207
194
  class Text
208
- def ext_text_init
209
- `#{self}.data = S2D.CreateText(#{self}.font, #{self}.text, #{self}.size);`
210
- @width = `#{self}.data.width;`
211
- @height = `#{self}.data.height;`
195
+ def ext_init
196
+ `
197
+ #{self}.data = S2D.CreateText(#{self}.font, #{self}.text, #{self}.size);
198
+ #{@width} = #{self}.data.width;
199
+ #{@height} = #{self}.data.height;
200
+ `
212
201
  end
213
202
 
214
- def ext_text_set(msg)
215
- `S2D.SetText(#{self}.data, #{msg});`
216
- @width = `#{self}.data.width;`
217
- @height = `#{self}.data.height;`
203
+ def ext_set(msg)
204
+ `
205
+ S2D.SetText(#{self}.data, #{msg});
206
+ #{@width} = #{self}.data.width;
207
+ #{@height} = #{self}.data.height;
208
+ `
209
+ end
210
+
211
+ def ext_render
212
+ `
213
+ #{self}.data.x = #{self}.x;
214
+ #{self}.data.y = #{self}.y;
215
+
216
+ #{self}.data.color.r = #{self}.color.r;
217
+ #{self}.data.color.g = #{self}.color.g;
218
+ #{self}.data.color.b = #{self}.color.b;
219
+ #{self}.data.color.a = #{self}.color.a;
220
+
221
+ S2D.DrawText(#{self}.data);
222
+ `
218
223
  end
219
224
  end
220
225
 
221
226
  class Sound
222
- def ext_sound_init(path)
227
+ def ext_init(path)
223
228
  `#{self}.data = S2D.CreateSound(path);`
224
229
  end
225
230
 
226
- def ext_sound_play
231
+ def ext_play
227
232
  `S2D.PlaySound(#{self}.data);`
228
233
  end
229
234
  end
230
235
 
231
236
  class Music
232
- def ext_music_init(path)
237
+ def ext_init(path)
233
238
  `#{self}.data = S2D.CreateMusic(path);`
234
239
  end
235
240
 
236
- def ext_music_play
241
+ def ext_play
237
242
  `S2D.PlayMusic(#{self}.data, #{self}.loop);`
238
243
  end
239
244
 
240
- def ext_music_pause
245
+ def ext_pause
241
246
  `S2D.PauseMusic();`
242
247
  end
243
248
 
244
- def ext_music_resume
249
+ def ext_resume
245
250
  `S2D.ResumeMusic();`
246
251
  end
247
252
 
248
- def ext_music_stop
253
+ def ext_stop
249
254
  `S2D.StopMusic();`
250
255
  end
251
256
 
@@ -255,7 +260,7 @@ module Ruby2D
255
260
  end
256
261
 
257
262
  class Window
258
- def ext_window_show
263
+ def ext_show
259
264
  $R2D_WINDOW = self
260
265
 
261
266
  `
@@ -277,7 +282,8 @@ module Ruby2D
277
282
  win.on_key = on_key;
278
283
  win.on_mouse = on_mouse;
279
284
 
280
- S2D.Show(win);`
285
+ S2D.Show(win);
286
+ `
281
287
  end
282
288
  end
283
289
  end
@@ -89,14 +89,6 @@
89
89
  #define r_char_to_sym(str) ID2SYM(rb_intern(str))
90
90
  #endif
91
91
 
92
- // @type_id values for rendering
93
- #define R2D_TRIANGLE 1
94
- #define R2D_QUAD 2
95
- #define R2D_LINE 3
96
- #define R2D_IMAGE 4
97
- #define R2D_SPRITE 5
98
- #define R2D_TEXT 6
99
-
100
92
  // Create the MRuby context
101
93
  #if MRUBY
102
94
  static mrb_state *mrb;
@@ -161,18 +153,148 @@ static R_VAL file_exists(mrb_state* mrb, R_VAL self) {
161
153
 
162
154
 
163
155
  /*
164
- * Ruby2D::Image#init
156
+ * Ruby2D::Triangle#ext_render
157
+ */
158
+ #if MRUBY
159
+ static R_VAL ruby2d_triangle_ext_render(mrb_state* mrb, R_VAL self) {
160
+ #else
161
+ static R_VAL ruby2d_triangle_ext_render(R_VAL self) {
162
+ #endif
163
+ R_VAL c1 = r_iv_get(self, "@c1");
164
+ R_VAL c2 = r_iv_get(self, "@c2");
165
+ R_VAL c3 = r_iv_get(self, "@c3");
166
+
167
+ S2D_DrawTriangle(
168
+ NUM2DBL(r_iv_get(self, "@x1")),
169
+ NUM2DBL(r_iv_get(self, "@y1")),
170
+ NUM2DBL(r_iv_get(c1, "@r")),
171
+ NUM2DBL(r_iv_get(c1, "@g")),
172
+ NUM2DBL(r_iv_get(c1, "@b")),
173
+ NUM2DBL(r_iv_get(c1, "@a")),
174
+
175
+ NUM2DBL(r_iv_get(self, "@x2")),
176
+ NUM2DBL(r_iv_get(self, "@y2")),
177
+ NUM2DBL(r_iv_get(c2, "@r")),
178
+ NUM2DBL(r_iv_get(c2, "@g")),
179
+ NUM2DBL(r_iv_get(c2, "@b")),
180
+ NUM2DBL(r_iv_get(c2, "@a")),
181
+
182
+ NUM2DBL(r_iv_get(self, "@x3")),
183
+ NUM2DBL(r_iv_get(self, "@y3")),
184
+ NUM2DBL(r_iv_get(c3, "@r")),
185
+ NUM2DBL(r_iv_get(c3, "@g")),
186
+ NUM2DBL(r_iv_get(c3, "@b")),
187
+ NUM2DBL(r_iv_get(c3, "@a"))
188
+ );
189
+
190
+ return R_NIL;
191
+ }
192
+
193
+
194
+ /*
195
+ * Ruby2D::Quad#ext_render
196
+ */
197
+ #if MRUBY
198
+ static R_VAL ruby2d_quad_ext_render(mrb_state* mrb, R_VAL self) {
199
+ #else
200
+ static R_VAL ruby2d_quad_ext_render(R_VAL self) {
201
+ #endif
202
+ R_VAL c1 = r_iv_get(self, "@c1");
203
+ R_VAL c2 = r_iv_get(self, "@c2");
204
+ R_VAL c3 = r_iv_get(self, "@c3");
205
+ R_VAL c4 = r_iv_get(self, "@c4");
206
+
207
+ S2D_DrawQuad(
208
+ NUM2DBL(r_iv_get(self, "@x1")),
209
+ NUM2DBL(r_iv_get(self, "@y1")),
210
+ NUM2DBL(r_iv_get(c1, "@r")),
211
+ NUM2DBL(r_iv_get(c1, "@g")),
212
+ NUM2DBL(r_iv_get(c1, "@b")),
213
+ NUM2DBL(r_iv_get(c1, "@a")),
214
+
215
+ NUM2DBL(r_iv_get(self, "@x2")),
216
+ NUM2DBL(r_iv_get(self, "@y2")),
217
+ NUM2DBL(r_iv_get(c2, "@r")),
218
+ NUM2DBL(r_iv_get(c2, "@g")),
219
+ NUM2DBL(r_iv_get(c2, "@b")),
220
+ NUM2DBL(r_iv_get(c2, "@a")),
221
+
222
+ NUM2DBL(r_iv_get(self, "@x3")),
223
+ NUM2DBL(r_iv_get(self, "@y3")),
224
+ NUM2DBL(r_iv_get(c3, "@r")),
225
+ NUM2DBL(r_iv_get(c3, "@g")),
226
+ NUM2DBL(r_iv_get(c3, "@b")),
227
+ NUM2DBL(r_iv_get(c3, "@a")),
228
+
229
+ NUM2DBL(r_iv_get(self, "@x4")),
230
+ NUM2DBL(r_iv_get(self, "@y4")),
231
+ NUM2DBL(r_iv_get(c4, "@r")),
232
+ NUM2DBL(r_iv_get(c4, "@g")),
233
+ NUM2DBL(r_iv_get(c4, "@b")),
234
+ NUM2DBL(r_iv_get(c4, "@a"))
235
+ );
236
+
237
+ return R_NIL;
238
+ }
239
+
240
+
241
+ /*
242
+ * Ruby2D::Line#ext_render
243
+ */
244
+ #if MRUBY
245
+ static R_VAL ruby2d_line_ext_render(mrb_state* mrb, R_VAL self) {
246
+ #else
247
+ static R_VAL ruby2d_line_ext_render(R_VAL self) {
248
+ #endif
249
+ R_VAL c1 = r_iv_get(self, "@c1");
250
+ R_VAL c2 = r_iv_get(self, "@c2");
251
+ R_VAL c3 = r_iv_get(self, "@c3");
252
+ R_VAL c4 = r_iv_get(self, "@c4");
253
+
254
+ S2D_DrawLine(
255
+ NUM2DBL(r_iv_get(self, "@x1")),
256
+ NUM2DBL(r_iv_get(self, "@y1")),
257
+ NUM2DBL(r_iv_get(self, "@x2")),
258
+ NUM2DBL(r_iv_get(self, "@y2")),
259
+ NUM2DBL(r_iv_get(self, "@width")),
260
+
261
+ NUM2DBL(r_iv_get(c1, "@r")),
262
+ NUM2DBL(r_iv_get(c1, "@g")),
263
+ NUM2DBL(r_iv_get(c1, "@b")),
264
+ NUM2DBL(r_iv_get(c1, "@a")),
265
+
266
+ NUM2DBL(r_iv_get(c2, "@r")),
267
+ NUM2DBL(r_iv_get(c2, "@g")),
268
+ NUM2DBL(r_iv_get(c2, "@b")),
269
+ NUM2DBL(r_iv_get(c2, "@a")),
270
+
271
+ NUM2DBL(r_iv_get(c3, "@r")),
272
+ NUM2DBL(r_iv_get(c3, "@g")),
273
+ NUM2DBL(r_iv_get(c3, "@b")),
274
+ NUM2DBL(r_iv_get(c3, "@a")),
275
+
276
+ NUM2DBL(r_iv_get(c4, "@r")),
277
+ NUM2DBL(r_iv_get(c4, "@g")),
278
+ NUM2DBL(r_iv_get(c4, "@b")),
279
+ NUM2DBL(r_iv_get(c4, "@a"))
280
+ );
281
+
282
+ return R_NIL;
283
+ }
284
+
285
+
286
+ /*
287
+ * Ruby2D::Image#ext_init
165
288
  * Initialize image structure data
166
289
  */
167
290
  #if MRUBY
168
- static R_VAL ruby2d_image_init(mrb_state* mrb, R_VAL self) {
291
+ static R_VAL ruby2d_image_ext_init(mrb_state* mrb, R_VAL self) {
169
292
  mrb_value path;
170
293
  mrb_get_args(mrb, "o", &path);
171
294
  #else
172
- static R_VAL ruby2d_image_init(R_VAL self, R_VAL path) {
295
+ static R_VAL ruby2d_image_ext_init(R_VAL self, R_VAL path) {
173
296
  #endif
174
- sprintf(S2D_msg, "Init image: %s", RSTRING_PTR(path));
175
- S2D_Log(S2D_msg, S2D_INFO);
297
+ S2D_Log(S2D_INFO, "Init image: %s", RSTRING_PTR(path));
176
298
  S2D_Image *img = S2D_CreateImage(RSTRING_PTR(path));
177
299
 
178
300
  // Get width and height from Ruby class. If set, use it, else choose the
@@ -187,6 +309,37 @@ static R_VAL ruby2d_image_init(R_VAL self, R_VAL path) {
187
309
  }
188
310
 
189
311
 
312
+ /*
313
+ * Ruby2D::Image#ext_render
314
+ */
315
+ #if MRUBY
316
+ static R_VAL ruby2d_image_ext_render(mrb_state* mrb, R_VAL self) {
317
+ #else
318
+ static R_VAL ruby2d_image_ext_render(R_VAL self) {
319
+ #endif
320
+ S2D_Image *img;
321
+ r_data_get_struct(self, "@data", &image_data_type, S2D_Image, img);
322
+
323
+ img->x = NUM2DBL(r_iv_get(self, "@x"));
324
+ img->y = NUM2DBL(r_iv_get(self, "@y"));
325
+
326
+ R_VAL w = r_iv_get(self, "@width");
327
+ R_VAL h = r_iv_get(self, "@height");
328
+ if (r_test(w)) img->width = NUM2INT(w);
329
+ if (r_test(h)) img->height = NUM2INT(h);
330
+
331
+ R_VAL c = r_iv_get(self, "@color");
332
+ img->color.r = NUM2DBL(r_iv_get(c, "@r"));
333
+ img->color.g = NUM2DBL(r_iv_get(c, "@g"));
334
+ img->color.b = NUM2DBL(r_iv_get(c, "@b"));
335
+ img->color.a = NUM2DBL(r_iv_get(c, "@a"));
336
+
337
+ S2D_DrawImage(img);
338
+
339
+ return R_NIL;
340
+ }
341
+
342
+
190
343
  /*
191
344
  * Free image structure attached to Ruby 2D `Image` class
192
345
  */
@@ -196,31 +349,57 @@ static void free_image(mrb_state *mrb, void *p_) {
196
349
  #else
197
350
  static void free_image(S2D_Image *img) {
198
351
  #endif
199
- sprintf(S2D_msg, "Free image: %i, %i", img->x, img->y);
200
- S2D_Log(S2D_msg, S2D_INFO);
352
+ S2D_Log(S2D_INFO, "Free image: %i, %i", img->x, img->y);
201
353
  S2D_FreeImage(img);
202
354
  }
203
355
 
204
356
 
205
357
  /*
206
- * Ruby2D::Sprite#init
358
+ * Ruby2D::Sprite#ext_init
207
359
  * Initialize sprite structure data
208
360
  */
209
361
  #if MRUBY
210
- static R_VAL ruby2d_sprite_init(mrb_state* mrb, R_VAL self) {
362
+ static R_VAL ruby2d_sprite_ext_init(mrb_state* mrb, R_VAL self) {
211
363
  mrb_value path;
212
364
  mrb_get_args(mrb, "o", &path);
213
365
  #else
214
- static R_VAL ruby2d_sprite_init(R_VAL self, R_VAL path) {
366
+ static R_VAL ruby2d_sprite_ext_init(R_VAL self, R_VAL path) {
215
367
  #endif
216
- sprintf(S2D_msg, "Init sprite: %s", RSTRING_PTR(path));
217
- S2D_Log(S2D_msg, S2D_INFO);
368
+ S2D_Log(S2D_INFO, "Init sprite: %s", RSTRING_PTR(path));
218
369
  S2D_Sprite *spr = S2D_CreateSprite(RSTRING_PTR(path));
219
370
  r_iv_set(self, "@data", r_data_wrap_struct(sprite, spr));
220
371
  return R_NIL;
221
372
  }
222
373
 
223
374
 
375
+ /*
376
+ * Ruby2D::Sprite#ext_render
377
+ */
378
+ #if MRUBY
379
+ static R_VAL ruby2d_sprite_ext_render(mrb_state* mrb, R_VAL self) {
380
+ #else
381
+ static R_VAL ruby2d_sprite_ext_render(R_VAL self) {
382
+ #endif
383
+ S2D_Sprite *spr;
384
+ r_data_get_struct(self, "@data", &sprite_data_type, S2D_Sprite, spr);
385
+
386
+ spr->x = NUM2DBL(r_iv_get(self, "@x"));
387
+ spr->y = NUM2DBL(r_iv_get(self, "@y"));
388
+
389
+ S2D_ClipSprite(
390
+ spr,
391
+ NUM2INT(r_iv_get(self, "@clip_x")),
392
+ NUM2INT(r_iv_get(self, "@clip_y")),
393
+ NUM2INT(r_iv_get(self, "@clip_w")),
394
+ NUM2INT(r_iv_get(self, "@clip_h"))
395
+ );
396
+
397
+ S2D_DrawSprite(spr);
398
+
399
+ return R_NIL;
400
+ }
401
+
402
+
224
403
  /*
225
404
  * Free sprite structure attached to Ruby 2D `Sprite` class
226
405
  */
@@ -230,23 +409,21 @@ static void free_sprite(mrb_state *mrb, void *p_) {
230
409
  #else
231
410
  static void free_sprite(S2D_Sprite *spr) {
232
411
  #endif
233
- sprintf(S2D_msg, "Free sprite: %i, %i", spr->x, spr->y);
234
- S2D_Log(S2D_msg, S2D_INFO);
412
+ S2D_Log(S2D_INFO, "Free sprite: %i, %i", spr->x, spr->y);
235
413
  S2D_FreeSprite(spr);
236
414
  }
237
415
 
238
416
 
239
417
  /*
240
- * Ruby2D::Text#init
418
+ * Ruby2D::Text#ext_init
241
419
  * Initialize text structure data
242
420
  */
243
421
  #if MRUBY
244
- static R_VAL ruby2d_text_init(mrb_state* mrb, R_VAL self) {
422
+ static R_VAL ruby2d_text_ext_init(mrb_state* mrb, R_VAL self) {
245
423
  #else
246
- static R_VAL ruby2d_text_init(R_VAL self) {
424
+ static R_VAL ruby2d_text_ext_init(R_VAL self) {
247
425
  #endif
248
- sprintf(S2D_msg, "Init text: %s", RSTRING_PTR(r_iv_get(self, "@text")));
249
- S2D_Log(S2D_msg, S2D_INFO);
426
+ S2D_Log(S2D_INFO, "Init text: %s", RSTRING_PTR(r_iv_get(self, "@text")));
250
427
 
251
428
  S2D_Text *txt = S2D_CreateText(
252
429
  RSTRING_PTR(r_iv_get(self, "@font")),
@@ -263,14 +440,14 @@ static R_VAL ruby2d_text_init(R_VAL self) {
263
440
 
264
441
 
265
442
  /*
266
- * Ruby2D::Text#ext_text_set
443
+ * Ruby2D::Text#ext_set
267
444
  */
268
445
  #if MRUBY
269
- static R_VAL ruby2d_text_set(mrb_state* mrb, R_VAL self) {
446
+ static R_VAL ruby2d_text_ext_set(mrb_state* mrb, R_VAL self) {
270
447
  mrb_value text;
271
448
  mrb_get_args(mrb, "o", &text);
272
449
  #else
273
- static R_VAL ruby2d_text_set(R_VAL self, R_VAL text) {
450
+ static R_VAL ruby2d_text_ext_set(R_VAL self, R_VAL text) {
274
451
  #endif
275
452
  S2D_Text *txt;
276
453
  r_data_get_struct(self, "@data", &text_data_type, S2D_Text, txt);
@@ -284,6 +461,32 @@ static R_VAL ruby2d_text_set(R_VAL self, R_VAL text) {
284
461
  }
285
462
 
286
463
 
464
+ /*
465
+ * Ruby2D::Text#ext_render
466
+ */
467
+ #if MRUBY
468
+ static R_VAL ruby2d_text_ext_render(mrb_state* mrb, R_VAL self) {
469
+ #else
470
+ static R_VAL ruby2d_text_ext_render(R_VAL self) {
471
+ #endif
472
+ S2D_Text *txt;
473
+ r_data_get_struct(self, "@data", &text_data_type, S2D_Text, txt);
474
+
475
+ txt->x = NUM2DBL(r_iv_get(self, "@x"));
476
+ txt->y = NUM2DBL(r_iv_get(self, "@y"));
477
+
478
+ R_VAL c = r_iv_get(self, "@color");
479
+ txt->color.r = NUM2DBL(r_iv_get(c, "@r"));
480
+ txt->color.g = NUM2DBL(r_iv_get(c, "@g"));
481
+ txt->color.b = NUM2DBL(r_iv_get(c, "@b"));
482
+ txt->color.a = NUM2DBL(r_iv_get(c, "@a"));
483
+
484
+ S2D_DrawText(txt);
485
+
486
+ return R_NIL;
487
+ }
488
+
489
+
287
490
  /*
288
491
  * Free text structure attached to Ruby 2D `Text` class
289
492
  */
@@ -293,25 +496,23 @@ static void free_text(mrb_state *mrb, void *p_) {
293
496
  #else
294
497
  static void free_text(S2D_Text *txt) {
295
498
  #endif
296
- sprintf(S2D_msg, "Free text: %s", txt->msg);
297
- S2D_Log(S2D_msg, S2D_INFO);
499
+ S2D_Log(S2D_INFO, "Free text: %s", txt->msg);
298
500
  S2D_FreeText(txt);
299
501
  }
300
502
 
301
503
 
302
504
  /*
303
- * Ruby2D::Sound#init
505
+ * Ruby2D::Sound#ext_init
304
506
  * Initialize sound structure data
305
507
  */
306
508
  #if MRUBY
307
- static R_VAL ruby2d_sound_init(mrb_state* mrb, R_VAL self) {
509
+ static R_VAL ruby2d_sound_ext_init(mrb_state* mrb, R_VAL self) {
308
510
  mrb_value path;
309
511
  mrb_get_args(mrb, "o", &path);
310
512
  #else
311
- static R_VAL ruby2d_sound_init(R_VAL self, R_VAL path) {
513
+ static R_VAL ruby2d_sound_ext_init(R_VAL self, R_VAL path) {
312
514
  #endif
313
- sprintf(S2D_msg, "Init sound: %s", RSTRING_PTR(path));
314
- S2D_Log(S2D_msg, S2D_INFO);
515
+ S2D_Log(S2D_INFO, "Init sound: %s", RSTRING_PTR(path));
315
516
  S2D_Sound *snd = S2D_CreateSound(RSTRING_PTR(path));
316
517
  r_iv_set(self, "@data", r_data_wrap_struct(sound, snd));
317
518
  return R_NIL;
@@ -319,12 +520,12 @@ static R_VAL ruby2d_sound_init(R_VAL self, R_VAL path) {
319
520
 
320
521
 
321
522
  /*
322
- * Ruby2D::Sound#play
523
+ * Ruby2D::Sound#ext_play
323
524
  */
324
525
  #if MRUBY
325
- static R_VAL ruby2d_sound_play(mrb_state* mrb, R_VAL self) {
526
+ static R_VAL ruby2d_sound_ext_play(mrb_state* mrb, R_VAL self) {
326
527
  #else
327
- static R_VAL ruby2d_sound_play(R_VAL self) {
528
+ static R_VAL ruby2d_sound_ext_play(R_VAL self) {
328
529
  #endif
329
530
  S2D_Sound *snd;
330
531
  r_data_get_struct(self, "@data", &sound_data_type, S2D_Sound, snd);
@@ -342,25 +543,23 @@ static void free_sound(mrb_state *mrb, void *p_) {
342
543
  #else
343
544
  static void free_sound(S2D_Sound *snd) {
344
545
  #endif
345
- sprintf(S2D_msg, "Free sound");
346
- S2D_Log(S2D_msg, S2D_INFO);
546
+ S2D_Log(S2D_INFO, "Free sound");
347
547
  S2D_FreeSound(snd);
348
548
  }
349
549
 
350
550
 
351
551
  /*
352
- * Ruby2D::Music#init
552
+ * Ruby2D::Music#ext_init
353
553
  * Initialize music structure data
354
554
  */
355
555
  #if MRUBY
356
- static R_VAL ruby2d_music_init(mrb_state* mrb, R_VAL self) {
556
+ static R_VAL ruby2d_music_ext_init(mrb_state* mrb, R_VAL self) {
357
557
  mrb_value path;
358
558
  mrb_get_args(mrb, "o", &path);
359
559
  #else
360
- static R_VAL ruby2d_music_init(R_VAL self, R_VAL path) {
560
+ static R_VAL ruby2d_music_ext_init(R_VAL self, R_VAL path) {
361
561
  #endif
362
- sprintf(S2D_msg, "Init music: %s", RSTRING_PTR(path));
363
- S2D_Log(S2D_msg, S2D_INFO);
562
+ S2D_Log(S2D_INFO, "Init music: %s", RSTRING_PTR(path));
364
563
  S2D_Music *mus = S2D_CreateMusic(RSTRING_PTR(path));
365
564
  r_iv_set(self, "@data", r_data_wrap_struct(music, mus));
366
565
  return R_NIL;
@@ -368,12 +567,12 @@ static R_VAL ruby2d_music_init(R_VAL self, R_VAL path) {
368
567
 
369
568
 
370
569
  /*
371
- * Ruby2D::Music#play
570
+ * Ruby2D::Music#ext_play
372
571
  */
373
572
  #if MRUBY
374
- static R_VAL ruby2d_music_play(mrb_state* mrb, R_VAL self) {
573
+ static R_VAL ruby2d_music_ext_play(mrb_state* mrb, R_VAL self) {
375
574
  #else
376
- static R_VAL ruby2d_music_play(R_VAL self) {
575
+ static R_VAL ruby2d_music_ext_play(R_VAL self) {
377
576
  #endif
378
577
  S2D_Music *mus;
379
578
  r_data_get_struct(self, "@data", &music_data_type, S2D_Music, mus);
@@ -383,12 +582,12 @@ static R_VAL ruby2d_music_play(R_VAL self) {
383
582
 
384
583
 
385
584
  /*
386
- * Ruby2D::Music#pause
585
+ * Ruby2D::Music#ext_pause
387
586
  */
388
587
  #if MRUBY
389
- static R_VAL ruby2d_music_pause(mrb_state* mrb, R_VAL self) {
588
+ static R_VAL ruby2d_music_ext_pause(mrb_state* mrb, R_VAL self) {
390
589
  #else
391
- static R_VAL ruby2d_music_pause(R_VAL self) {
590
+ static R_VAL ruby2d_music_ext_pause(R_VAL self) {
392
591
  #endif
393
592
  S2D_PauseMusic();
394
593
  return R_NIL;
@@ -396,12 +595,12 @@ static R_VAL ruby2d_music_pause(R_VAL self) {
396
595
 
397
596
 
398
597
  /*
399
- * Ruby2D::Music#resume
598
+ * Ruby2D::Music#ext_resume
400
599
  */
401
600
  #if MRUBY
402
- static R_VAL ruby2d_music_resume(mrb_state* mrb, R_VAL self) {
601
+ static R_VAL ruby2d_music_ext_resume(mrb_state* mrb, R_VAL self) {
403
602
  #else
404
- static R_VAL ruby2d_music_resume(R_VAL self) {
603
+ static R_VAL ruby2d_music_ext_resume(R_VAL self) {
405
604
  #endif
406
605
  S2D_ResumeMusic();
407
606
  return R_NIL;
@@ -409,12 +608,12 @@ static R_VAL ruby2d_music_resume(R_VAL self) {
409
608
 
410
609
 
411
610
  /*
412
- * Ruby2D::Music#stop
611
+ * Ruby2D::Music#ext_stop
413
612
  */
414
613
  #if MRUBY
415
- static R_VAL ruby2d_music_stop(mrb_state* mrb, R_VAL self) {
614
+ static R_VAL ruby2d_music_ext_stop(mrb_state* mrb, R_VAL self) {
416
615
  #else
417
- static R_VAL ruby2d_music_stop(R_VAL self) {
616
+ static R_VAL ruby2d_music_ext_stop(R_VAL self) {
418
617
  #endif
419
618
  S2D_StopMusic();
420
619
  return R_NIL;
@@ -422,14 +621,14 @@ static R_VAL ruby2d_music_stop(R_VAL self) {
422
621
 
423
622
 
424
623
  /*
425
- * Ruby2D::Music#fadeout
624
+ * Ruby2D::Music#ext_fadeout
426
625
  */
427
626
  #if MRUBY
428
- static R_VAL ruby2d_music_fadeout(mrb_state* mrb, R_VAL self) {
627
+ static R_VAL ruby2d_music_ext_fadeout(mrb_state* mrb, R_VAL self) {
429
628
  mrb_value ms;
430
629
  mrb_get_args(mrb, "o", &ms);
431
630
  #else
432
- static R_VAL ruby2d_music_fadeout(R_VAL self, R_VAL ms) {
631
+ static R_VAL ruby2d_music_ext_fadeout(R_VAL self, R_VAL ms) {
433
632
  #endif
434
633
  S2D_FadeOutMusic(NUM2INT(ms));
435
634
  return R_NIL;
@@ -437,7 +636,7 @@ static R_VAL ruby2d_music_fadeout(R_VAL self, R_VAL ms) {
437
636
 
438
637
 
439
638
  /*
440
- * Free sound structure attached to Ruby 2D `Sound` class
639
+ * Free music structure attached to Ruby 2D `Music` class
441
640
  */
442
641
  #if MRUBY
443
642
  static void free_music(mrb_state *mrb, void *p_) {
@@ -445,8 +644,7 @@ static void free_music(mrb_state *mrb, void *p_) {
445
644
  #else
446
645
  static void free_music(S2D_Music *mus) {
447
646
  #endif
448
- sprintf(S2D_msg, "Free music");
449
- S2D_Log(S2D_msg, S2D_INFO);
647
+ S2D_Log(S2D_INFO, "Free music");
450
648
  S2D_FreeMusic(mus);
451
649
  }
452
650
 
@@ -596,186 +794,19 @@ static void render() {
596
794
 
597
795
  // Switch on each object type
598
796
  for (int i = 0; i < num_objects; ++i) {
599
-
600
797
  R_VAL el = r_ary_entry(objects, i);
601
- int type_id = NUM2INT(r_iv_get(el, "@type_id"));
602
-
603
- // Switch on the object's type_id
604
- switch(type_id) {
605
-
606
- case R2D_TRIANGLE: {
607
- R_VAL c1 = r_iv_get(el, "@c1");
608
- R_VAL c2 = r_iv_get(el, "@c2");
609
- R_VAL c3 = r_iv_get(el, "@c3");
610
-
611
- S2D_DrawTriangle(
612
- NUM2DBL(r_iv_get(el, "@x1")),
613
- NUM2DBL(r_iv_get(el, "@y1")),
614
- NUM2DBL(r_iv_get(c1, "@r")),
615
- NUM2DBL(r_iv_get(c1, "@g")),
616
- NUM2DBL(r_iv_get(c1, "@b")),
617
- NUM2DBL(r_iv_get(c1, "@a")),
618
-
619
- NUM2DBL(r_iv_get(el, "@x2")),
620
- NUM2DBL(r_iv_get(el, "@y2")),
621
- NUM2DBL(r_iv_get(c2, "@r")),
622
- NUM2DBL(r_iv_get(c2, "@g")),
623
- NUM2DBL(r_iv_get(c2, "@b")),
624
- NUM2DBL(r_iv_get(c2, "@a")),
625
-
626
- NUM2DBL(r_iv_get(el, "@x3")),
627
- NUM2DBL(r_iv_get(el, "@y3")),
628
- NUM2DBL(r_iv_get(c3, "@r")),
629
- NUM2DBL(r_iv_get(c3, "@g")),
630
- NUM2DBL(r_iv_get(c3, "@b")),
631
- NUM2DBL(r_iv_get(c3, "@a"))
632
- );
633
- }
634
- break;
635
-
636
- case R2D_QUAD: {
637
- R_VAL c1 = r_iv_get(el, "@c1");
638
- R_VAL c2 = r_iv_get(el, "@c2");
639
- R_VAL c3 = r_iv_get(el, "@c3");
640
- R_VAL c4 = r_iv_get(el, "@c4");
641
-
642
- S2D_DrawQuad(
643
- NUM2DBL(r_iv_get(el, "@x1")),
644
- NUM2DBL(r_iv_get(el, "@y1")),
645
- NUM2DBL(r_iv_get(c1, "@r")),
646
- NUM2DBL(r_iv_get(c1, "@g")),
647
- NUM2DBL(r_iv_get(c1, "@b")),
648
- NUM2DBL(r_iv_get(c1, "@a")),
649
-
650
- NUM2DBL(r_iv_get(el, "@x2")),
651
- NUM2DBL(r_iv_get(el, "@y2")),
652
- NUM2DBL(r_iv_get(c2, "@r")),
653
- NUM2DBL(r_iv_get(c2, "@g")),
654
- NUM2DBL(r_iv_get(c2, "@b")),
655
- NUM2DBL(r_iv_get(c2, "@a")),
656
-
657
- NUM2DBL(r_iv_get(el, "@x3")),
658
- NUM2DBL(r_iv_get(el, "@y3")),
659
- NUM2DBL(r_iv_get(c3, "@r")),
660
- NUM2DBL(r_iv_get(c3, "@g")),
661
- NUM2DBL(r_iv_get(c3, "@b")),
662
- NUM2DBL(r_iv_get(c3, "@a")),
663
-
664
- NUM2DBL(r_iv_get(el, "@x4")),
665
- NUM2DBL(r_iv_get(el, "@y4")),
666
- NUM2DBL(r_iv_get(c4, "@r")),
667
- NUM2DBL(r_iv_get(c4, "@g")),
668
- NUM2DBL(r_iv_get(c4, "@b")),
669
- NUM2DBL(r_iv_get(c4, "@a"))
670
- );
671
- }
672
- break;
673
-
674
- case R2D_LINE: {
675
- R_VAL c1 = r_iv_get(el, "@c1");
676
- R_VAL c2 = r_iv_get(el, "@c2");
677
- R_VAL c3 = r_iv_get(el, "@c3");
678
- R_VAL c4 = r_iv_get(el, "@c4");
679
-
680
- S2D_DrawLine(
681
- NUM2DBL(r_iv_get(el, "@x1")),
682
- NUM2DBL(r_iv_get(el, "@y1")),
683
- NUM2DBL(r_iv_get(el, "@x2")),
684
- NUM2DBL(r_iv_get(el, "@y2")),
685
- NUM2DBL(r_iv_get(el, "@width")),
686
-
687
- NUM2DBL(r_iv_get(c1, "@r")),
688
- NUM2DBL(r_iv_get(c1, "@g")),
689
- NUM2DBL(r_iv_get(c1, "@b")),
690
- NUM2DBL(r_iv_get(c1, "@a")),
691
-
692
- NUM2DBL(r_iv_get(c2, "@r")),
693
- NUM2DBL(r_iv_get(c2, "@g")),
694
- NUM2DBL(r_iv_get(c2, "@b")),
695
- NUM2DBL(r_iv_get(c2, "@a")),
696
-
697
- NUM2DBL(r_iv_get(c3, "@r")),
698
- NUM2DBL(r_iv_get(c3, "@g")),
699
- NUM2DBL(r_iv_get(c3, "@b")),
700
- NUM2DBL(r_iv_get(c3, "@a")),
701
-
702
- NUM2DBL(r_iv_get(c4, "@r")),
703
- NUM2DBL(r_iv_get(c4, "@g")),
704
- NUM2DBL(r_iv_get(c4, "@b")),
705
- NUM2DBL(r_iv_get(c4, "@a"))
706
- );
707
- }
708
- break;
709
-
710
- case R2D_IMAGE: {
711
- S2D_Image *img;
712
- r_data_get_struct(el, "@data", &image_data_type, S2D_Image, img);
713
-
714
- img->x = NUM2DBL(r_iv_get(el, "@x"));
715
- img->y = NUM2DBL(r_iv_get(el, "@y"));
716
-
717
- R_VAL w = r_iv_get(el, "@width");
718
- R_VAL h = r_iv_get(el, "@height");
719
- if (r_test(w)) img->width = NUM2INT(w);
720
- if (r_test(h)) img->height = NUM2INT(h);
721
-
722
- R_VAL c = r_iv_get(el, "@color");
723
- img->color.r = NUM2DBL(r_iv_get(c, "@r"));
724
- img->color.g = NUM2DBL(r_iv_get(c, "@g"));
725
- img->color.b = NUM2DBL(r_iv_get(c, "@b"));
726
- img->color.a = NUM2DBL(r_iv_get(c, "@a"));
727
-
728
- S2D_DrawImage(img);
729
- }
730
- break;
731
-
732
- case R2D_SPRITE: {
733
- S2D_Sprite *spr;
734
- r_data_get_struct(el, "@data", &sprite_data_type, S2D_Sprite, spr);
735
-
736
- spr->x = NUM2DBL(r_iv_get(el, "@x"));
737
- spr->y = NUM2DBL(r_iv_get(el, "@y"));
738
-
739
- S2D_ClipSprite(
740
- spr,
741
- NUM2INT(r_iv_get(el, "@clip_x")),
742
- NUM2INT(r_iv_get(el, "@clip_y")),
743
- NUM2INT(r_iv_get(el, "@clip_w")),
744
- NUM2INT(r_iv_get(el, "@clip_h"))
745
- );
746
-
747
- S2D_DrawSprite(spr);
748
- }
749
- break;
750
-
751
- case R2D_TEXT: {
752
- S2D_Text *txt;
753
- r_data_get_struct(el, "@data", &text_data_type, S2D_Text, txt);
754
-
755
- txt->x = NUM2DBL(r_iv_get(el, "@x"));
756
- txt->y = NUM2DBL(r_iv_get(el, "@y"));
757
-
758
- R_VAL c = r_iv_get(el, "@color");
759
- txt->color.r = NUM2DBL(r_iv_get(c, "@r"));
760
- txt->color.g = NUM2DBL(r_iv_get(c, "@g"));
761
- txt->color.b = NUM2DBL(r_iv_get(c, "@b"));
762
- txt->color.a = NUM2DBL(r_iv_get(c, "@a"));
763
-
764
- S2D_DrawText(txt);
765
- }
766
- break;
767
- }
798
+ r_funcall(el, "ext_render", 0);
768
799
  }
769
800
  }
770
801
 
771
802
 
772
803
  /*
773
- * Ruby2D::Window#show
804
+ * Ruby2D::Window#ext_show
774
805
  */
775
806
  #if MRUBY
776
- static R_VAL ruby2d_show(mrb_state* mrb, R_VAL self) {
807
+ static R_VAL ruby2d_window_ext_show(mrb_state* mrb, R_VAL self) {
777
808
  #else
778
- static R_VAL ruby2d_show(R_VAL self) {
809
+ static R_VAL ruby2d_window_ext_show(R_VAL self) {
779
810
  #endif
780
811
  ruby2d_window = self;
781
812
 
@@ -831,9 +862,9 @@ static R_VAL ruby2d_show(R_VAL self) {
831
862
 
832
863
 
833
864
  /*
834
- * Ruby2D::Window#close
865
+ * Ruby2D::Window#ext_close
835
866
  */
836
- static R_VAL ruby2d_close() {
867
+ static R_VAL ruby2d_window_ext_close() {
837
868
  S2D_Close(window);
838
869
  return R_NIL;
839
870
  }
@@ -843,7 +874,7 @@ static R_VAL ruby2d_close() {
843
874
  /*
844
875
  * MRuby entry point
845
876
  */
846
- int main(void) {
877
+ int main() {
847
878
  // Open the MRuby environment
848
879
  mrb = mrb_open();
849
880
  if (!mrb) { /* handle error */ }
@@ -865,65 +896,92 @@ void Init_ruby2d() {
865
896
  // Ruby2D
866
897
  R_CLASS ruby2d_module = r_define_module("Ruby2D");
867
898
 
899
+ // Ruby2D::Triangle
900
+ R_CLASS ruby2d_triangle_class = r_define_class(ruby2d_module, "Triangle");
901
+
902
+ // Ruby2D::Triangle#ext_render
903
+ r_define_method(ruby2d_triangle_class, "ext_render", ruby2d_triangle_ext_render, r_args_none);
904
+
905
+ // Ruby2D::Quad
906
+ R_CLASS ruby2d_quad_class = r_define_class(ruby2d_module, "Quad");
907
+
908
+ // Ruby2D::Quad#ext_render
909
+ r_define_method(ruby2d_quad_class, "ext_render", ruby2d_quad_ext_render, r_args_none);
910
+
911
+ // Ruby2D::Line
912
+ R_CLASS ruby2d_line_class = r_define_class(ruby2d_module, "Line");
913
+
914
+ // Ruby2D::Line#ext_render
915
+ r_define_method(ruby2d_line_class, "ext_render", ruby2d_line_ext_render, r_args_none);
916
+
868
917
  // Ruby2D::Image
869
918
  R_CLASS ruby2d_image_class = r_define_class(ruby2d_module, "Image");
870
919
 
871
- // Ruby2D::Image#init
872
- r_define_method(ruby2d_image_class, "ext_image_init", ruby2d_image_init, r_args_req(1));
920
+ // Ruby2D::Image#ext_init
921
+ r_define_method(ruby2d_image_class, "ext_init", ruby2d_image_ext_init, r_args_req(1));
922
+
923
+ // Ruby2D::Image#ext_render
924
+ r_define_method(ruby2d_image_class, "ext_render", ruby2d_image_ext_render, r_args_none);
873
925
 
874
926
  // Ruby2D::Sprite
875
927
  R_CLASS ruby2d_sprite_class = r_define_class(ruby2d_module, "Sprite");
876
928
 
877
- // Ruby2D::Sprite#init
878
- r_define_method(ruby2d_sprite_class, "ext_sprite_init", ruby2d_sprite_init, r_args_req(1));
929
+ // Ruby2D::Sprite#ext_init
930
+ r_define_method(ruby2d_sprite_class, "ext_init", ruby2d_sprite_ext_init, r_args_req(1));
931
+
932
+ // Ruby2D::Sprite#ext_render
933
+ r_define_method(ruby2d_sprite_class, "ext_render", ruby2d_sprite_ext_render, r_args_none);
879
934
 
880
935
  // Ruby2D::Text
881
936
  R_CLASS ruby2d_text_class = r_define_class(ruby2d_module, "Text");
882
937
 
883
- // Ruby2D::Text#init
884
- r_define_method(ruby2d_text_class, "ext_text_init", ruby2d_text_init, r_args_none);
938
+ // Ruby2D::Text#ext_init
939
+ r_define_method(ruby2d_text_class, "ext_init", ruby2d_text_ext_init, r_args_none);
940
+
941
+ // Ruby2D::Text#ext_set
942
+ r_define_method(ruby2d_text_class, "ext_set", ruby2d_text_ext_set, r_args_req(1));
885
943
 
886
- // Ruby2D::Text#ext_text_set
887
- r_define_method(ruby2d_text_class, "ext_text_set", ruby2d_text_set, r_args_req(1));
944
+ // Ruby2D::Text#ext_render
945
+ r_define_method(ruby2d_text_class, "ext_render", ruby2d_text_ext_render, r_args_none);
888
946
 
889
947
  // Ruby2D::Sound
890
948
  R_CLASS ruby2d_sound_class = r_define_class(ruby2d_module, "Sound");
891
949
 
892
- // Ruby2D::Sound#init
893
- r_define_method(ruby2d_sound_class, "ext_sound_init", ruby2d_sound_init, r_args_req(1));
950
+ // Ruby2D::Sound#ext_init
951
+ r_define_method(ruby2d_sound_class, "ext_init", ruby2d_sound_ext_init, r_args_req(1));
894
952
 
895
- // Ruby2D::Sound#play
896
- r_define_method(ruby2d_sound_class, "ext_sound_play", ruby2d_sound_play, r_args_none);
953
+ // Ruby2D::Sound#ext_play
954
+ r_define_method(ruby2d_sound_class, "ext_play", ruby2d_sound_ext_play, r_args_none);
897
955
 
898
956
  // Ruby2D::Music
899
957
  R_CLASS ruby2d_music_class = r_define_class(ruby2d_module, "Music");
900
958
 
901
- // Ruby2D::Music#init
902
- r_define_method(ruby2d_music_class, "ext_music_init", ruby2d_music_init, r_args_req(1));
959
+ // Ruby2D::Music#ext_init
960
+ r_define_method(ruby2d_music_class, "ext_init", ruby2d_music_ext_init, r_args_req(1));
903
961
 
904
- // Ruby2D::Music#play
905
- r_define_method(ruby2d_music_class, "ext_music_play", ruby2d_music_play, r_args_none);
962
+ // Ruby2D::Music#ext_play
963
+ r_define_method(ruby2d_music_class, "ext_play", ruby2d_music_ext_play, r_args_none);
906
964
 
907
- // Ruby2D::Music#pause
908
- r_define_method(ruby2d_music_class, "ext_music_pause", ruby2d_music_pause, r_args_none);
965
+ // Ruby2D::Music#ext_pause
966
+ r_define_method(ruby2d_music_class, "ext_pause", ruby2d_music_ext_pause, r_args_none);
909
967
 
910
- // Ruby2D::Music#resume
911
- r_define_method(ruby2d_music_class, "ext_music_resume", ruby2d_music_resume, r_args_none);
968
+ // Ruby2D::Music#ext_resume
969
+ r_define_method(ruby2d_music_class, "ext_resume", ruby2d_music_ext_resume, r_args_none);
912
970
 
913
- // Ruby2D::Music#stop
914
- r_define_method(ruby2d_music_class, "ext_music_stop", ruby2d_music_stop, r_args_none);
971
+ // Ruby2D::Music#ext_stop
972
+ r_define_method(ruby2d_music_class, "ext_stop", ruby2d_music_ext_stop, r_args_none);
915
973
 
916
- // Ruby2D::Music#fadeout
917
- r_define_method(ruby2d_music_class, "ext_music_fadeout", ruby2d_music_fadeout, r_args_req(1));
974
+ // Ruby2D::Music#ext_fadeout
975
+ r_define_method(ruby2d_music_class, "ext_fadeout", ruby2d_music_ext_fadeout, r_args_req(1));
918
976
 
919
977
  // Ruby2D::Window
920
978
  R_CLASS ruby2d_window_class = r_define_class(ruby2d_module, "Window");
921
979
 
922
- // Ruby2D::Window#show
923
- r_define_method(ruby2d_window_class, "ext_window_show", ruby2d_show, r_args_none);
980
+ // Ruby2D::Window#ext_show
981
+ r_define_method(ruby2d_window_class, "ext_show", ruby2d_window_ext_show, r_args_none);
924
982
 
925
- // Ruby2D::Window#close
926
- r_define_method(ruby2d_window_class, "ext_window_close", ruby2d_close, r_args_none);
983
+ // Ruby2D::Window#ext_close
984
+ r_define_method(ruby2d_window_class, "ext_close", ruby2d_window_ext_close, r_args_none);
927
985
 
928
986
  #if MRUBY
929
987
  // Load the Ruby 2D app
@@ -934,5 +992,7 @@ void Init_ruby2d() {
934
992
 
935
993
  // Close the MRuby environment
936
994
  mrb_close(mrb);
995
+
996
+ return 0;
937
997
  #endif
938
998
  }