ruby2d 0.9.5 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (134) hide show
  1. checksums.yaml +4 -4
  2. data/assets/include/SDL2/SDL.h +4 -1
  3. data/assets/include/SDL2/SDL_assert.h +3 -1
  4. data/assets/include/SDL2/SDL_atomic.h +1 -1
  5. data/assets/include/SDL2/SDL_audio.h +1 -1
  6. data/assets/include/SDL2/SDL_bits.h +1 -1
  7. data/assets/include/SDL2/SDL_blendmode.h +4 -1
  8. data/assets/include/SDL2/SDL_clipboard.h +1 -1
  9. data/assets/include/SDL2/SDL_config.h +1 -1
  10. data/assets/include/SDL2/SDL_config_android.h +7 -3
  11. data/assets/include/SDL2/SDL_config_iphoneos.h +16 -10
  12. data/assets/include/SDL2/SDL_config_macosx.h +40 -14
  13. data/assets/include/SDL2/SDL_config_minimal.h +1 -1
  14. data/assets/include/SDL2/SDL_config_os2.h +26 -8
  15. data/assets/include/SDL2/SDL_config_pandora.h +4 -2
  16. data/assets/include/SDL2/SDL_config_psp.h +2 -1
  17. data/assets/include/SDL2/SDL_config_windows.h +40 -9
  18. data/assets/include/SDL2/SDL_config_winrt.h +5 -2
  19. data/assets/include/SDL2/SDL_config_wiz.h +5 -2
  20. data/assets/include/SDL2/SDL_copying.h +1 -1
  21. data/assets/include/SDL2/SDL_cpuinfo.h +32 -3
  22. data/assets/include/SDL2/SDL_egl.h +4 -1
  23. data/assets/include/SDL2/SDL_endian.h +6 -3
  24. data/assets/include/SDL2/SDL_error.h +38 -2
  25. data/assets/include/SDL2/SDL_events.h +64 -28
  26. data/assets/include/SDL2/SDL_filesystem.h +1 -1
  27. data/assets/include/SDL2/SDL_gamecontroller.h +160 -9
  28. data/assets/include/SDL2/SDL_gesture.h +1 -1
  29. data/assets/include/SDL2/SDL_haptic.h +10 -1
  30. data/assets/include/SDL2/SDL_hints.h +316 -4
  31. data/assets/include/SDL2/SDL_joystick.h +115 -24
  32. data/assets/include/SDL2/SDL_keyboard.h +1 -1
  33. data/assets/include/SDL2/SDL_keycode.h +11 -9
  34. data/assets/include/SDL2/SDL_loadso.h +1 -1
  35. data/assets/include/SDL2/SDL_locale.h +101 -0
  36. data/assets/include/SDL2/SDL_log.h +3 -3
  37. data/assets/include/SDL2/SDL_main.h +1 -1
  38. data/assets/include/SDL2/SDL_messagebox.h +6 -4
  39. data/assets/include/SDL2/SDL_metal.h +117 -0
  40. data/assets/include/SDL2/SDL_misc.h +75 -0
  41. data/assets/include/SDL2/SDL_mouse.h +1 -1
  42. data/assets/include/SDL2/SDL_mutex.h +1 -1
  43. data/assets/include/SDL2/SDL_name.h +1 -1
  44. data/assets/include/SDL2/SDL_opengl.h +1 -1
  45. data/assets/include/SDL2/SDL_opengl_glext.h +3 -0
  46. data/assets/include/SDL2/SDL_opengles.h +1 -1
  47. data/assets/include/SDL2/SDL_opengles2.h +1 -1
  48. data/assets/include/SDL2/SDL_pixels.h +25 -16
  49. data/assets/include/SDL2/SDL_platform.h +1 -1
  50. data/assets/include/SDL2/SDL_power.h +1 -1
  51. data/assets/include/SDL2/SDL_quit.h +1 -1
  52. data/assets/include/SDL2/SDL_rect.h +1 -1
  53. data/assets/include/SDL2/SDL_render.h +63 -3
  54. data/assets/include/SDL2/SDL_revision.h +2 -2
  55. data/assets/include/SDL2/SDL_rwops.h +2 -10
  56. data/assets/include/SDL2/SDL_scancode.h +1 -1
  57. data/assets/include/SDL2/SDL_sensor.h +25 -9
  58. data/assets/include/SDL2/SDL_shape.h +1 -1
  59. data/assets/include/SDL2/SDL_stdinc.h +44 -4
  60. data/assets/include/SDL2/SDL_surface.h +11 -2
  61. data/assets/include/SDL2/SDL_system.h +50 -4
  62. data/assets/include/SDL2/SDL_syswm.h +29 -2
  63. data/assets/include/SDL2/SDL_test.h +1 -1
  64. data/assets/include/SDL2/SDL_test_assert.h +1 -1
  65. data/assets/include/SDL2/SDL_test_common.h +14 -1
  66. data/assets/include/SDL2/SDL_test_compare.h +1 -1
  67. data/assets/include/SDL2/SDL_test_crc32.h +1 -1
  68. data/assets/include/SDL2/SDL_test_font.h +1 -1
  69. data/assets/include/SDL2/SDL_test_fuzzer.h +1 -1
  70. data/assets/include/SDL2/SDL_test_harness.h +1 -1
  71. data/assets/include/SDL2/SDL_test_images.h +1 -1
  72. data/assets/include/SDL2/SDL_test_log.h +1 -1
  73. data/assets/include/SDL2/SDL_test_md5.h +1 -1
  74. data/assets/include/SDL2/SDL_test_memory.h +1 -1
  75. data/assets/include/SDL2/SDL_test_random.h +1 -1
  76. data/assets/include/SDL2/SDL_thread.h +34 -11
  77. data/assets/include/SDL2/SDL_timer.h +1 -1
  78. data/assets/include/SDL2/SDL_touch.h +1 -1
  79. data/assets/include/SDL2/SDL_types.h +1 -1
  80. data/assets/include/SDL2/SDL_version.h +2 -2
  81. data/assets/include/SDL2/SDL_video.h +11 -5
  82. data/assets/include/SDL2/SDL_vulkan.h +6 -8
  83. data/assets/include/SDL2/begin_code.h +5 -9
  84. data/assets/include/SDL2/close_code.h +1 -1
  85. data/assets/macos/lib/libFLAC.a +0 -0
  86. data/assets/macos/lib/libSDL2.a +0 -0
  87. data/assets/macos/lib/libSDL2_image.a +0 -0
  88. data/assets/macos/lib/libSDL2_mixer.a +0 -0
  89. data/assets/macos/lib/libSDL2_ttf.a +0 -0
  90. data/assets/macos/lib/libfreetype.a +0 -0
  91. data/assets/macos/lib/libjpeg.a +0 -0
  92. data/assets/macos/lib/libmpg123.a +0 -0
  93. data/assets/macos/lib/libogg.a +0 -0
  94. data/assets/macos/lib/libpng16.a +0 -0
  95. data/assets/macos/lib/libtiff.a +0 -0
  96. data/assets/macos/lib/libvorbis.a +0 -0
  97. data/assets/macos/lib/libvorbisfile.a +0 -0
  98. data/assets/macos/lib/libwebp.a +0 -0
  99. data/assets/mingw/bin/SDL2.dll +0 -0
  100. data/assets/mingw/lib/libSDL2.a +0 -0
  101. data/assets/mingw/lib/libSDL2.dll.a +0 -0
  102. data/assets/mingw/lib/libSDL2_test.a +0 -0
  103. data/assets/mingw/lib/libSDL2main.a +0 -0
  104. data/ext/ruby2d/extconf.rb +1 -1
  105. data/ext/ruby2d/gl.c +17 -0
  106. data/ext/ruby2d/gl2.c +15 -0
  107. data/ext/ruby2d/gl3.c +15 -0
  108. data/ext/ruby2d/gles.c +15 -0
  109. data/ext/ruby2d/music.c +13 -0
  110. data/ext/ruby2d/ruby2d.c +306 -168
  111. data/ext/ruby2d/ruby2d.h +32 -0
  112. data/ext/ruby2d/sound.c +25 -0
  113. data/ext/ruby2d/tileset.c +30 -0
  114. data/lib/ruby2d.rb +4 -1
  115. data/lib/ruby2d/circle.rb +18 -2
  116. data/lib/ruby2d/dsl.rb +16 -9
  117. data/lib/ruby2d/entity.rb +17 -0
  118. data/lib/ruby2d/font.rb +4 -3
  119. data/lib/ruby2d/image.rb +24 -1
  120. data/lib/ruby2d/line.rb +20 -0
  121. data/lib/ruby2d/music.rb +5 -0
  122. data/lib/ruby2d/pixel.rb +17 -0
  123. data/lib/ruby2d/quad.rb +18 -0
  124. data/lib/ruby2d/rectangle.rb +11 -2
  125. data/lib/ruby2d/renderable.rb +4 -8
  126. data/lib/ruby2d/sound.rb +5 -0
  127. data/lib/ruby2d/sprite.rb +35 -3
  128. data/lib/ruby2d/square.rb +9 -0
  129. data/lib/ruby2d/text.rb +22 -1
  130. data/lib/ruby2d/tileset.rb +69 -0
  131. data/lib/ruby2d/triangle.rb +16 -0
  132. data/lib/ruby2d/version.rb +1 -1
  133. data/lib/ruby2d/window.rb +249 -22
  134. metadata +10 -3
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  Simple DirectMedia Layer
3
- Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
3
+ Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
4
4
 
5
5
  This software is provided 'as-is', without any express or implied
6
6
  warranty. In no event will the authors be held liable for any damages
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -113,7 +113,7 @@ else
113
113
  add_flags(:ld, "#{ldir}/libjpeg.a #{ldir}/libpng16.a #{ldir}/libtiff.a #{ldir}/libwebp.a")
114
114
  add_flags(:ld, "#{ldir}/libmpg123.a #{ldir}/libogg.a #{ldir}/libFLAC.a #{ldir}/libvorbis.a #{ldir}/libvorbisfile.a")
115
115
  add_flags(:ld, "#{ldir}/libfreetype.a")
116
- add_flags(:ld, "-Wl,-framework,Cocoa -Wl,-framework,ForceFeedback")
116
+ add_flags(:ld, "-Wl,-framework,Cocoa -Wl,-framework,GameController -Wl,-framework,ForceFeedback")
117
117
 
118
118
  when :linux, :linux_rpi
119
119
  check_sdl_linux
data/ext/ruby2d/gl.c CHANGED
@@ -392,6 +392,23 @@ void R2D_GL_DrawSprite(R2D_Sprite *spr) {
392
392
  }
393
393
 
394
394
 
395
+ /*
396
+ * Draw a tile
397
+ */
398
+ void R2D_GL_DrawTile(R2D_Image *img, int x, int y, int tw, int th, GLfloat tx1, GLfloat ty1, GLfloat tx2,
399
+ GLfloat ty2, GLfloat tx3, GLfloat ty3, GLfloat tx4, GLfloat ty4) {
400
+ #if GLES
401
+ R2D_GLES_DrawTile(img, x, y, tw, th, tx1, ty1, tx2, ty2, tx3, ty3, tx4, ty4);
402
+ #else
403
+ if (R2D_GL2) {
404
+ R2D_GL2_DrawTile(img, x, y, tw, th, tx1, ty1, tx2, ty2, tx3, ty3, tx4, ty4);
405
+ } else {
406
+ R2D_GL3_DrawTile(img, x, y, tw, th, tx1, ty1, tx2, ty2, tx3, ty3, tx4, ty4);
407
+ }
408
+ #endif
409
+ }
410
+
411
+
395
412
  /*
396
413
  * Draw text
397
414
  */
data/ext/ruby2d/gl2.c CHANGED
@@ -130,6 +130,21 @@ void R2D_GL2_DrawSprite(R2D_Sprite *spr) {
130
130
  }
131
131
 
132
132
 
133
+ /*
134
+ * Draw a tile
135
+ */
136
+ void R2D_GL2_DrawTile(R2D_Image *img, int x, int y, int tw, int th, GLfloat tx1, GLfloat ty1, GLfloat tx2,
137
+ GLfloat ty2, GLfloat tx3, GLfloat ty3, GLfloat tx4, GLfloat ty4) {
138
+ R2D_GL2_DrawTexture(
139
+ x, y, tw, th,
140
+ img->rotate, img->rx, img->ry,
141
+ img->color.r, img->color.g, img->color.b, img->color.a,
142
+ tx1, ty1, tx2, ty2, tx3, ty3, tx4, ty4,
143
+ img->texture_id
144
+ );
145
+ }
146
+
147
+
133
148
  /*
134
149
  * Draw text
135
150
  */
data/ext/ruby2d/gl3.c CHANGED
@@ -332,6 +332,21 @@ void R2D_GL3_DrawSprite(R2D_Sprite *spr) {
332
332
  }
333
333
 
334
334
 
335
+ /*
336
+ * Draw a tile
337
+ */
338
+ void R2D_GL3_DrawTile(R2D_Image *img, int x, int y, int tw, int th, GLfloat tx1, GLfloat ty1, GLfloat tx2,
339
+ GLfloat ty2, GLfloat tx3, GLfloat ty3, GLfloat tx4, GLfloat ty4) {
340
+ R2D_GL3_DrawTexture(
341
+ x, y, tw, th,
342
+ img->rotate, img->rx, img->ry,
343
+ img->color.r, img->color.g, img->color.b, img->color.a,
344
+ tx1, ty1, tx2, ty2, tx3, ty3, tx4, ty4,
345
+ img->texture_id
346
+ );
347
+ }
348
+
349
+
335
350
  /*
336
351
  * Draw text
337
352
  */
data/ext/ruby2d/gles.c CHANGED
@@ -292,6 +292,21 @@ void R2D_GLES_DrawSprite(R2D_Sprite *spr) {
292
292
  }
293
293
 
294
294
 
295
+ /*
296
+ * Draw a tile
297
+ */
298
+ void R2D_GLES_DrawTile(R2D_Image *img, int x, int y, int tw, int th, GLfloat tx1, GLfloat ty1, GLfloat tx2,
299
+ GLfloat ty2, GLfloat tx3, GLfloat ty3, GLfloat tx4, GLfloat ty4) {
300
+ R2D_GLES_DrawTexture(
301
+ x, y, tw, th,
302
+ img->rotate, img->rx, img->ry,
303
+ img->color.r, img->color.g, img->color.b, img->color.a,
304
+ tx1, ty1, tx2, ty2, tx3, ty3, tx4, ty4,
305
+ img->texture_id
306
+ );
307
+ }
308
+
309
+
295
310
  /*
296
311
  * Draw text
297
312
  */
data/ext/ruby2d/music.c CHANGED
@@ -33,6 +33,11 @@ R2D_Music *R2D_CreateMusic(const char *path) {
33
33
  // Initialize values
34
34
  mus->path = path;
35
35
 
36
+ // Calculate the length of music by creating a temporary R2D_Sound object
37
+ R2D_Sound *snd = R2D_CreateSound(path);
38
+ mus->length = R2D_GetSoundLength(snd);
39
+ R2D_FreeSound(snd);
40
+
36
41
  return mus;
37
42
  }
38
43
 
@@ -104,6 +109,14 @@ void R2D_FadeOutMusic(int ms) {
104
109
  }
105
110
 
106
111
 
112
+ /*
113
+ * Get the length of the music in seconds
114
+ */
115
+ int R2D_GetMusicLength(R2D_Music *mus) {
116
+ return mus->length;
117
+ }
118
+
119
+
107
120
  /*
108
121
  * Free the music
109
122
  */
data/ext/ruby2d/ruby2d.c CHANGED
@@ -166,38 +166,84 @@ static R_VAL ruby2d_ext_base_path(R_VAL self) {
166
166
 
167
167
 
168
168
  /*
169
- * Ruby2D::Triangle#ext_render
169
+ * Ruby2D::Pixel#self.ext_draw
170
170
  */
171
171
  #if MRUBY
172
- static R_VAL ruby2d_triangle_ext_render(mrb_state* mrb, R_VAL self) {
172
+ static R_VAL ruby2d_pixel_ext_draw(mrb_state* mrb, R_VAL self) {
173
+ mrb_value a;
174
+ mrb_get_args(mrb, "o", &a);
173
175
  #else
174
- static R_VAL ruby2d_triangle_ext_render(R_VAL self) {
176
+ static R_VAL ruby2d_pixel_ext_draw(R_VAL self, R_VAL a) {
175
177
  #endif
176
- R_VAL c1 = r_iv_get(self, "@c1");
177
- R_VAL c2 = r_iv_get(self, "@c2");
178
- R_VAL c3 = r_iv_get(self, "@c3");
178
+ // `a` is the array representing the pixel
179
+
180
+ R2D_DrawQuad(
181
+ NUM2DBL(r_ary_entry(a, 0)), // x1
182
+ NUM2DBL(r_ary_entry(a, 1)), // y1
183
+ NUM2DBL(r_ary_entry(a, 8)), // color
184
+ NUM2DBL(r_ary_entry(a, 9)), // color
185
+ NUM2DBL(r_ary_entry(a, 10)), // color
186
+ NUM2DBL(r_ary_entry(a, 11)), // color
187
+
188
+ NUM2DBL(r_ary_entry(a, 2)), // x2
189
+ NUM2DBL(r_ary_entry(a, 3)), // y2
190
+ NUM2DBL(r_ary_entry(a, 8)), // color
191
+ NUM2DBL(r_ary_entry(a, 9)), // color
192
+ NUM2DBL(r_ary_entry(a, 10)), // color
193
+ NUM2DBL(r_ary_entry(a, 11)), // color
194
+
195
+ NUM2DBL(r_ary_entry(a, 4)), // x3
196
+ NUM2DBL(r_ary_entry(a, 5)), // y3
197
+ NUM2DBL(r_ary_entry(a, 8)), // color
198
+ NUM2DBL(r_ary_entry(a, 9)), // color
199
+ NUM2DBL(r_ary_entry(a, 10)), // color
200
+ NUM2DBL(r_ary_entry(a, 11)), // color
201
+
202
+ NUM2DBL(r_ary_entry(a, 6)), // x4
203
+ NUM2DBL(r_ary_entry(a, 7)), // y4
204
+ NUM2DBL(r_ary_entry(a, 8)), // color
205
+ NUM2DBL(r_ary_entry(a, 9)), // color
206
+ NUM2DBL(r_ary_entry(a, 10)), // color
207
+ NUM2DBL(r_ary_entry(a, 11)) // color
208
+ );
209
+
210
+ return R_NIL;
211
+ }
212
+
213
+
214
+ /*
215
+ * Ruby2D::Triangle#self.ext_draw
216
+ */
217
+ #if MRUBY
218
+ static R_VAL ruby2d_triangle_ext_draw(mrb_state* mrb, R_VAL self) {
219
+ mrb_value a;
220
+ mrb_get_args(mrb, "o", &a);
221
+ #else
222
+ static R_VAL ruby2d_triangle_ext_draw(R_VAL self, R_VAL a) {
223
+ #endif
224
+ // `a` is the array representing the triangle
179
225
 
180
226
  R2D_DrawTriangle(
181
- NUM2DBL(r_iv_get(self, "@x1")),
182
- NUM2DBL(r_iv_get(self, "@y1")),
183
- NUM2DBL(r_iv_get(c1, "@r")),
184
- NUM2DBL(r_iv_get(c1, "@g")),
185
- NUM2DBL(r_iv_get(c1, "@b")),
186
- NUM2DBL(r_iv_get(c1, "@a")),
187
-
188
- NUM2DBL(r_iv_get(self, "@x2")),
189
- NUM2DBL(r_iv_get(self, "@y2")),
190
- NUM2DBL(r_iv_get(c2, "@r")),
191
- NUM2DBL(r_iv_get(c2, "@g")),
192
- NUM2DBL(r_iv_get(c2, "@b")),
193
- NUM2DBL(r_iv_get(c2, "@a")),
194
-
195
- NUM2DBL(r_iv_get(self, "@x3")),
196
- NUM2DBL(r_iv_get(self, "@y3")),
197
- NUM2DBL(r_iv_get(c3, "@r")),
198
- NUM2DBL(r_iv_get(c3, "@g")),
199
- NUM2DBL(r_iv_get(c3, "@b")),
200
- NUM2DBL(r_iv_get(c3, "@a"))
227
+ NUM2DBL(r_ary_entry(a, 0)), // x1
228
+ NUM2DBL(r_ary_entry(a, 1)), // y1
229
+ NUM2DBL(r_ary_entry(a, 2)), // c1 red
230
+ NUM2DBL(r_ary_entry(a, 3)), // c1 green
231
+ NUM2DBL(r_ary_entry(a, 4)), // c1 blue
232
+ NUM2DBL(r_ary_entry(a, 5)), // c1 alpha
233
+
234
+ NUM2DBL(r_ary_entry(a, 6)), // x2
235
+ NUM2DBL(r_ary_entry(a, 7)), // y2
236
+ NUM2DBL(r_ary_entry(a, 8)), // c2 red
237
+ NUM2DBL(r_ary_entry(a, 9)), // c2 green
238
+ NUM2DBL(r_ary_entry(a, 10)), // c2 blue
239
+ NUM2DBL(r_ary_entry(a, 11)), // c2 alpha
240
+
241
+ NUM2DBL(r_ary_entry(a, 12)), // x3
242
+ NUM2DBL(r_ary_entry(a, 13)), // y3
243
+ NUM2DBL(r_ary_entry(a, 14)), // c3 red
244
+ NUM2DBL(r_ary_entry(a, 15)), // c3 green
245
+ NUM2DBL(r_ary_entry(a, 16)), // c3 blue
246
+ NUM2DBL(r_ary_entry(a, 17)) // c3 alpha
201
247
  );
202
248
 
203
249
  return R_NIL;
@@ -205,46 +251,45 @@ static R_VAL ruby2d_triangle_ext_render(R_VAL self) {
205
251
 
206
252
 
207
253
  /*
208
- * Ruby2D::Quad#ext_render
254
+ * Ruby2D::Quad#self.ext_draw
209
255
  */
210
256
  #if MRUBY
211
- static R_VAL ruby2d_quad_ext_render(mrb_state* mrb, R_VAL self) {
257
+ static R_VAL ruby2d_quad_ext_draw(mrb_state* mrb, R_VAL self) {
258
+ mrb_value a;
259
+ mrb_get_args(mrb, "o", &a);
212
260
  #else
213
- static R_VAL ruby2d_quad_ext_render(R_VAL self) {
261
+ static R_VAL ruby2d_quad_ext_draw(R_VAL self, R_VAL a) {
214
262
  #endif
215
- R_VAL c1 = r_iv_get(self, "@c1");
216
- R_VAL c2 = r_iv_get(self, "@c2");
217
- R_VAL c3 = r_iv_get(self, "@c3");
218
- R_VAL c4 = r_iv_get(self, "@c4");
263
+ // `a` is the array representing the quad
219
264
 
220
265
  R2D_DrawQuad(
221
- NUM2DBL(r_iv_get(self, "@x1")),
222
- NUM2DBL(r_iv_get(self, "@y1")),
223
- NUM2DBL(r_iv_get(c1, "@r")),
224
- NUM2DBL(r_iv_get(c1, "@g")),
225
- NUM2DBL(r_iv_get(c1, "@b")),
226
- NUM2DBL(r_iv_get(c1, "@a")),
227
-
228
- NUM2DBL(r_iv_get(self, "@x2")),
229
- NUM2DBL(r_iv_get(self, "@y2")),
230
- NUM2DBL(r_iv_get(c2, "@r")),
231
- NUM2DBL(r_iv_get(c2, "@g")),
232
- NUM2DBL(r_iv_get(c2, "@b")),
233
- NUM2DBL(r_iv_get(c2, "@a")),
234
-
235
- NUM2DBL(r_iv_get(self, "@x3")),
236
- NUM2DBL(r_iv_get(self, "@y3")),
237
- NUM2DBL(r_iv_get(c3, "@r")),
238
- NUM2DBL(r_iv_get(c3, "@g")),
239
- NUM2DBL(r_iv_get(c3, "@b")),
240
- NUM2DBL(r_iv_get(c3, "@a")),
241
-
242
- NUM2DBL(r_iv_get(self, "@x4")),
243
- NUM2DBL(r_iv_get(self, "@y4")),
244
- NUM2DBL(r_iv_get(c4, "@r")),
245
- NUM2DBL(r_iv_get(c4, "@g")),
246
- NUM2DBL(r_iv_get(c4, "@b")),
247
- NUM2DBL(r_iv_get(c4, "@a"))
266
+ NUM2DBL(r_ary_entry(a, 0)), // x1
267
+ NUM2DBL(r_ary_entry(a, 1)), // y1
268
+ NUM2DBL(r_ary_entry(a, 2)), // c1 red
269
+ NUM2DBL(r_ary_entry(a, 3)), // c1 green
270
+ NUM2DBL(r_ary_entry(a, 4)), // c1 blue
271
+ NUM2DBL(r_ary_entry(a, 5)), // c1 alpha
272
+
273
+ NUM2DBL(r_ary_entry(a, 6)), // x2
274
+ NUM2DBL(r_ary_entry(a, 7)), // y2
275
+ NUM2DBL(r_ary_entry(a, 8)), // c2 red
276
+ NUM2DBL(r_ary_entry(a, 9)), // c2 green
277
+ NUM2DBL(r_ary_entry(a, 10)), // c2 blue
278
+ NUM2DBL(r_ary_entry(a, 11)), // c2 alpha
279
+
280
+ NUM2DBL(r_ary_entry(a, 12)), // x3
281
+ NUM2DBL(r_ary_entry(a, 13)), // y3
282
+ NUM2DBL(r_ary_entry(a, 14)), // c3 red
283
+ NUM2DBL(r_ary_entry(a, 15)), // c3 green
284
+ NUM2DBL(r_ary_entry(a, 16)), // c3 blue
285
+ NUM2DBL(r_ary_entry(a, 17)), // c3 alpha
286
+
287
+ NUM2DBL(r_ary_entry(a, 18)), // x4
288
+ NUM2DBL(r_ary_entry(a, 19)), // y4
289
+ NUM2DBL(r_ary_entry(a, 20)), // c4 red
290
+ NUM2DBL(r_ary_entry(a, 21)), // c4 green
291
+ NUM2DBL(r_ary_entry(a, 22)), // c4 blue
292
+ NUM2DBL(r_ary_entry(a, 23)) // c4 alpha
248
293
  );
249
294
 
250
295
  return R_NIL;
@@ -252,44 +297,43 @@ static R_VAL ruby2d_quad_ext_render(R_VAL self) {
252
297
 
253
298
 
254
299
  /*
255
- * Ruby2D::Line#ext_render
300
+ * Ruby2D::Line#self.ext_draw
256
301
  */
257
302
  #if MRUBY
258
- static R_VAL ruby2d_line_ext_render(mrb_state* mrb, R_VAL self) {
303
+ static R_VAL ruby2d_line_ext_draw(mrb_state* mrb, R_VAL self) {
304
+ mrb_value a;
305
+ mrb_get_args(mrb, "o", &a);
259
306
  #else
260
- static R_VAL ruby2d_line_ext_render(R_VAL self) {
307
+ static R_VAL ruby2d_line_ext_draw(R_VAL self, R_VAL a) {
261
308
  #endif
262
- R_VAL c1 = r_iv_get(self, "@c1");
263
- R_VAL c2 = r_iv_get(self, "@c2");
264
- R_VAL c3 = r_iv_get(self, "@c3");
265
- R_VAL c4 = r_iv_get(self, "@c4");
309
+ // `a` is the array representing the line
266
310
 
267
311
  R2D_DrawLine(
268
- NUM2DBL(r_iv_get(self, "@x1")),
269
- NUM2DBL(r_iv_get(self, "@y1")),
270
- NUM2DBL(r_iv_get(self, "@x2")),
271
- NUM2DBL(r_iv_get(self, "@y2")),
272
- NUM2DBL(r_iv_get(self, "@width")),
273
-
274
- NUM2DBL(r_iv_get(c1, "@r")),
275
- NUM2DBL(r_iv_get(c1, "@g")),
276
- NUM2DBL(r_iv_get(c1, "@b")),
277
- NUM2DBL(r_iv_get(c1, "@a")),
278
-
279
- NUM2DBL(r_iv_get(c2, "@r")),
280
- NUM2DBL(r_iv_get(c2, "@g")),
281
- NUM2DBL(r_iv_get(c2, "@b")),
282
- NUM2DBL(r_iv_get(c2, "@a")),
283
-
284
- NUM2DBL(r_iv_get(c3, "@r")),
285
- NUM2DBL(r_iv_get(c3, "@g")),
286
- NUM2DBL(r_iv_get(c3, "@b")),
287
- NUM2DBL(r_iv_get(c3, "@a")),
288
-
289
- NUM2DBL(r_iv_get(c4, "@r")),
290
- NUM2DBL(r_iv_get(c4, "@g")),
291
- NUM2DBL(r_iv_get(c4, "@b")),
292
- NUM2DBL(r_iv_get(c4, "@a"))
312
+ NUM2DBL(r_ary_entry(a, 0)), // x1
313
+ NUM2DBL(r_ary_entry(a, 1)), // y1
314
+ NUM2DBL(r_ary_entry(a, 2)), // x2
315
+ NUM2DBL(r_ary_entry(a, 3)), // y2
316
+ NUM2DBL(r_ary_entry(a, 4)), // width
317
+
318
+ NUM2DBL(r_ary_entry(a, 5)), // c1 red
319
+ NUM2DBL(r_ary_entry(a, 6)), // c1 green
320
+ NUM2DBL(r_ary_entry(a, 7)), // c1 blue
321
+ NUM2DBL(r_ary_entry(a, 8)), // c1 alpha
322
+
323
+ NUM2DBL(r_ary_entry(a, 9)), // c2 red
324
+ NUM2DBL(r_ary_entry(a, 10)), // c2 green
325
+ NUM2DBL(r_ary_entry(a, 11)), // c2 blue
326
+ NUM2DBL(r_ary_entry(a, 12)), // c2 alpha
327
+
328
+ NUM2DBL(r_ary_entry(a, 13)), // c3 red
329
+ NUM2DBL(r_ary_entry(a, 14)), // c3 green
330
+ NUM2DBL(r_ary_entry(a, 15)), // c3 blue
331
+ NUM2DBL(r_ary_entry(a, 16)), // c3 alpha
332
+
333
+ NUM2DBL(r_ary_entry(a, 17)), // c4 red
334
+ NUM2DBL(r_ary_entry(a, 18)), // c4 green
335
+ NUM2DBL(r_ary_entry(a, 19)), // c4 blue
336
+ NUM2DBL(r_ary_entry(a, 20)) // c4 alpha
293
337
  );
294
338
 
295
339
  return R_NIL;
@@ -297,24 +341,26 @@ static R_VAL ruby2d_line_ext_render(R_VAL self) {
297
341
 
298
342
 
299
343
  /*
300
- * Ruby2D::Circle#ext_render
344
+ * Ruby2D::Circle#self.ext_draw
301
345
  */
302
346
  #if MRUBY
303
- static R_VAL ruby2d_circle_ext_render(mrb_state* mrb, R_VAL self) {
347
+ static R_VAL ruby2d_circle_ext_draw(mrb_state* mrb, R_VAL self) {
348
+ mrb_value a;
349
+ mrb_get_args(mrb, "o", &a);
304
350
  #else
305
- static R_VAL ruby2d_circle_ext_render(R_VAL self) {
351
+ static R_VAL ruby2d_circle_ext_draw(R_VAL self, R_VAL a) {
306
352
  #endif
307
- R_VAL c = r_iv_get(self, "@color");
353
+ // `a` is the array representing the circle
308
354
 
309
355
  R2D_DrawCircle(
310
- NUM2DBL(r_iv_get(self, "@x")),
311
- NUM2DBL(r_iv_get(self, "@y")),
312
- NUM2DBL(r_iv_get(self, "@radius")),
313
- NUM2DBL(r_iv_get(self, "@sectors")),
314
- NUM2DBL(r_iv_get(c, "@r")),
315
- NUM2DBL(r_iv_get(c, "@g")),
316
- NUM2DBL(r_iv_get(c, "@b")),
317
- NUM2DBL(r_iv_get(c, "@a"))
356
+ NUM2DBL(r_ary_entry(a, 0)), // x
357
+ NUM2DBL(r_ary_entry(a, 1)), // y
358
+ NUM2DBL(r_ary_entry(a, 2)), // radius
359
+ NUM2DBL(r_ary_entry(a, 3)), // sectors
360
+ NUM2DBL(r_ary_entry(a, 4)), // red
361
+ NUM2DBL(r_ary_entry(a, 5)), // green
362
+ NUM2DBL(r_ary_entry(a, 6)), // blue
363
+ NUM2DBL(r_ary_entry(a, 7)) // alpha
318
364
  );
319
365
 
320
366
  return R_NIL;
@@ -348,34 +394,36 @@ static R_VAL ruby2d_image_ext_init(R_VAL self, R_VAL path) {
348
394
 
349
395
 
350
396
  /*
351
- * Ruby2D::Image#ext_render
397
+ * Ruby2D::Image#self.ext_draw
352
398
  */
353
399
  #if MRUBY
354
- static R_VAL ruby2d_image_ext_render(mrb_state* mrb, R_VAL self) {
400
+ static R_VAL ruby2d_image_ext_draw(mrb_state* mrb, R_VAL self) {
401
+ mrb_value a;
402
+ mrb_get_args(mrb, "o", &a);
355
403
  #else
356
- static R_VAL ruby2d_image_ext_render(R_VAL self) {
404
+ static R_VAL ruby2d_image_ext_draw(R_VAL self, R_VAL a) {
357
405
  #endif
406
+ // `a` is the array representing the image
407
+
358
408
  R2D_Image *img;
359
- r_data_get_struct(self, "@data", &image_data_type, R2D_Image, img);
409
+ r_data_get_struct(r_ary_entry(a, 0), "@data", &image_data_type, R2D_Image, img);
360
410
 
361
- img->x = NUM2DBL(r_iv_get(self, "@x"));
362
- img->y = NUM2DBL(r_iv_get(self, "@y"));
411
+ img->x = NUM2DBL(r_ary_entry(a, 1));
412
+ img->y = NUM2DBL(r_ary_entry(a, 2));
363
413
 
364
- R_VAL w = r_iv_get(self, "@width");
365
- R_VAL h = r_iv_get(self, "@height");
414
+ R_VAL w = r_ary_entry(a, 3);
415
+ R_VAL h = r_ary_entry(a, 4);
366
416
  if (r_test(w)) img->width = NUM2INT(w);
367
417
  if (r_test(h)) img->height = NUM2INT(h);
368
418
 
369
- R2D_RotateImage(img, NUM2DBL(r_iv_get(self, "@rotate")), R2D_CENTER);
419
+ R2D_RotateImage(img, NUM2DBL(r_ary_entry(a, 5)), R2D_CENTER);
370
420
 
371
- R_VAL c = r_iv_get(self, "@color");
372
- img->color.r = NUM2DBL(r_iv_get(c, "@r"));
373
- img->color.g = NUM2DBL(r_iv_get(c, "@g"));
374
- img->color.b = NUM2DBL(r_iv_get(c, "@b"));
375
- img->color.a = NUM2DBL(r_iv_get(c, "@a"));
421
+ img->color.r = NUM2DBL(r_ary_entry(a, 6));
422
+ img->color.g = NUM2DBL(r_ary_entry(a, 7));
423
+ img->color.b = NUM2DBL(r_ary_entry(a, 8));
424
+ img->color.a = NUM2DBL(r_ary_entry(a, 9));
376
425
 
377
426
  R2D_DrawImage(img);
378
-
379
427
  return R_NIL;
380
428
  }
381
429
 
@@ -416,45 +464,45 @@ static R_VAL ruby2d_sprite_ext_init(R_VAL self, R_VAL path) {
416
464
 
417
465
 
418
466
  /*
419
- * Ruby2D::Sprite#ext_render
467
+ * Ruby2D::Sprite#ext_draw
420
468
  */
421
469
  #if MRUBY
422
- static R_VAL ruby2d_sprite_ext_render(mrb_state* mrb, R_VAL self) {
470
+ static R_VAL ruby2d_sprite_ext_draw(mrb_state* mrb, R_VAL self) {
471
+ mrb_value a;
472
+ mrb_get_args(mrb, "o", &a);
423
473
  #else
424
- static R_VAL ruby2d_sprite_ext_render(R_VAL self) {
474
+ static R_VAL ruby2d_sprite_ext_draw(R_VAL self, R_VAL a) {
425
475
  #endif
426
- r_funcall(self, "update", 0);
476
+ // `a` is the array representing the sprite
427
477
 
428
478
  R2D_Sprite *spr;
429
- r_data_get_struct(self, "@data", &sprite_data_type, R2D_Sprite, spr);
479
+ r_data_get_struct(r_ary_entry(a, 0), "@data", &sprite_data_type, R2D_Sprite, spr);
430
480
 
431
- spr->x = NUM2DBL(r_iv_get(self, "@flip_x"));
432
- spr->y = NUM2DBL(r_iv_get(self, "@flip_y"));
481
+ spr->x = NUM2DBL(r_ary_entry(a, 1));
482
+ spr->y = NUM2DBL(r_ary_entry(a, 2));
433
483
 
434
- R_VAL w = r_iv_get(self, "@flip_width");
484
+ R_VAL w = r_ary_entry(a, 3);
435
485
  if (r_test(w)) spr->width = NUM2DBL(w);
436
486
 
437
- R_VAL h = r_iv_get(self, "@flip_height");
487
+ R_VAL h = r_ary_entry(a, 4);
438
488
  if (r_test(h)) spr->height = NUM2DBL(h);
439
489
 
440
- R2D_RotateSprite(spr, NUM2DBL(r_iv_get(self, "@rotate")), R2D_CENTER);
441
-
442
- R_VAL c = r_iv_get(self, "@color");
443
- spr->color.r = NUM2DBL(r_iv_get(c, "@r"));
444
- spr->color.g = NUM2DBL(r_iv_get(c, "@g"));
445
- spr->color.b = NUM2DBL(r_iv_get(c, "@b"));
446
- spr->color.a = NUM2DBL(r_iv_get(c, "@a"));
490
+ R2D_RotateSprite(spr, NUM2DBL(r_ary_entry(a, 5)), R2D_CENTER);
447
491
 
448
492
  R2D_ClipSprite(
449
493
  spr,
450
- NUM2INT(r_iv_get(self, "@clip_x")),
451
- NUM2INT(r_iv_get(self, "@clip_y")),
452
- NUM2INT(r_iv_get(self, "@clip_width")),
453
- NUM2INT(r_iv_get(self, "@clip_height"))
494
+ NUM2INT(r_ary_entry(a, 6)),
495
+ NUM2INT(r_ary_entry(a, 7)),
496
+ NUM2INT(r_ary_entry(a, 8)),
497
+ NUM2INT(r_ary_entry(a, 9))
454
498
  );
455
499
 
456
- R2D_DrawSprite(spr);
500
+ spr->color.r = NUM2DBL(r_ary_entry(a, 10));
501
+ spr->color.g = NUM2DBL(r_ary_entry(a, 11));
502
+ spr->color.b = NUM2DBL(r_ary_entry(a, 12));
503
+ spr->color.a = NUM2DBL(r_ary_entry(a, 13));
457
504
 
505
+ R2D_DrawSprite(spr);
458
506
  return R_NIL;
459
507
  }
460
508
 
@@ -472,6 +520,50 @@ static void free_sprite(R2D_Sprite *spr) {
472
520
  }
473
521
 
474
522
 
523
+ /*
524
+ * Ruby2D::Tileset#ext_init
525
+ * Initialize tileset data
526
+ */
527
+ static R_VAL ruby2d_tileset_ext_init(R_VAL self, R_VAL path) {
528
+ R2D_Image *img = R2D_CreateImage(RSTRING_PTR(path));
529
+ if (!img) return R_FALSE;
530
+
531
+ // Get width and height from Ruby class. If set, use it, else choose the
532
+ // native dimensions of the image.
533
+ R_VAL w = r_iv_get(self, "@width");
534
+ R_VAL h = r_iv_get(self, "@height");
535
+ r_iv_set(self, "@width" , r_test(w) ? w : INT2NUM(img->width));
536
+ r_iv_set(self, "@height", r_test(h) ? h : INT2NUM(img->height));
537
+ r_iv_set(self, "@data", r_data_wrap_struct(image, img));
538
+
539
+ return R_TRUE;
540
+ }
541
+
542
+
543
+ /*
544
+ * Ruby2D::Tileset#ext_draw
545
+ * Draws a single tile, will be called once per individual tile to draw
546
+ */
547
+ static R_VAL ruby2d_tileset_ext_draw(R_VAL self, R_VAL a) {
548
+ // `a` is the array representing the tileset
549
+
550
+ R2D_Image *img;
551
+ r_data_get_struct(r_ary_entry(a, 0), "@data", &image_data_type, R2D_Image, img);
552
+
553
+ int tw = NUM2INT(r_ary_entry(a, 1));
554
+ int th = NUM2INT(r_ary_entry(a, 2));
555
+ int padding = NUM2INT(r_ary_entry(a, 3));
556
+ int spacing = NUM2INT(r_ary_entry(a, 4));
557
+ int tx = NUM2INT(r_ary_entry(a, 5));
558
+ int ty = NUM2INT(r_ary_entry(a, 6));
559
+ int x = NUM2INT(r_ary_entry(a, 7));
560
+ int y = NUM2INT(r_ary_entry(a, 8));
561
+
562
+ R2D_DrawTile(img, tw, th, padding, spacing, tx, ty, x, y);
563
+ return R_NIL;
564
+ }
565
+
566
+
475
567
  /*
476
568
  * Ruby2D::Text#ext_init
477
569
  * Initialize text structure data
@@ -525,29 +617,31 @@ static R_VAL ruby2d_text_ext_set(R_VAL self, R_VAL text) {
525
617
 
526
618
 
527
619
  /*
528
- * Ruby2D::Text#ext_render
620
+ * Ruby2D::Text#self.ext_draw
529
621
  */
530
622
  #if MRUBY
531
- static R_VAL ruby2d_text_ext_render(mrb_state* mrb, R_VAL self) {
623
+ static R_VAL ruby2d_text_ext_draw(mrb_state* mrb, R_VAL self) {
624
+ mrb_value a;
625
+ mrb_get_args(mrb, "o", &a);
532
626
  #else
533
- static R_VAL ruby2d_text_ext_render(R_VAL self) {
627
+ static R_VAL ruby2d_text_ext_draw(R_VAL self, R_VAL a) {
534
628
  #endif
629
+ // `a` is the array representing the text
630
+
535
631
  R2D_Text *txt;
536
- r_data_get_struct(self, "@data", &text_data_type, R2D_Text, txt);
632
+ r_data_get_struct(r_ary_entry(a, 0), "@data", &text_data_type, R2D_Text, txt);
537
633
 
538
- txt->x = NUM2DBL(r_iv_get(self, "@x"));
539
- txt->y = NUM2DBL(r_iv_get(self, "@y"));
634
+ txt->x = NUM2DBL(r_ary_entry(a, 1));
635
+ txt->y = NUM2DBL(r_ary_entry(a, 2));
540
636
 
541
- R2D_RotateText(txt, NUM2DBL(r_iv_get(self, "@rotate")), R2D_CENTER);
637
+ R2D_RotateText(txt, NUM2DBL(r_ary_entry(a, 3)), R2D_CENTER);
542
638
 
543
- R_VAL c = r_iv_get(self, "@color");
544
- txt->color.r = NUM2DBL(r_iv_get(c, "@r"));
545
- txt->color.g = NUM2DBL(r_iv_get(c, "@g"));
546
- txt->color.b = NUM2DBL(r_iv_get(c, "@b"));
547
- txt->color.a = NUM2DBL(r_iv_get(c, "@a"));
639
+ txt->color.r = NUM2DBL(r_ary_entry(a, 4));
640
+ txt->color.g = NUM2DBL(r_ary_entry(a, 5));
641
+ txt->color.b = NUM2DBL(r_ary_entry(a, 6));
642
+ txt->color.a = NUM2DBL(r_ary_entry(a, 7));
548
643
 
549
644
  R2D_DrawText(txt);
550
-
551
645
  return R_NIL;
552
646
  }
553
647
 
@@ -598,6 +692,16 @@ static R_VAL ruby2d_sound_ext_play(R_VAL self) {
598
692
  }
599
693
 
600
694
 
695
+ /*
696
+ * Ruby2D::Sound#ext_length
697
+ */
698
+ static R_VAL ruby2d_sound_ext_length(R_VAL self) {
699
+ R2D_Sound *snd;
700
+ r_data_get_struct(self, "@data", &sound_data_type, R2D_Sound, snd);
701
+ return INT2NUM(R2D_GetSoundLength(snd));
702
+ }
703
+
704
+
601
705
  /*
602
706
  * Free sound structure attached to Ruby 2D `Sound` class
603
707
  */
@@ -725,6 +829,16 @@ static R_VAL ruby2d_music_ext_fadeout(R_VAL self, R_VAL ms) {
725
829
  }
726
830
 
727
831
 
832
+ /*
833
+ * Ruby2D::Music#ext_length
834
+ */
835
+ static R_VAL ruby2d_music_ext_length(R_VAL self) {
836
+ R2D_Music *ms;
837
+ r_data_get_struct(self, "@data", &music_data_type, R2D_Music, ms);
838
+ return INT2NUM(R2D_GetMusicLength(ms));
839
+ }
840
+
841
+
728
842
  /*
729
843
  * Free music structure attached to Ruby 2D `Music` class
730
844
  */
@@ -951,8 +1065,11 @@ static void render() {
951
1065
  // Switch on each object type
952
1066
  for (int i = 0; i < num_objects; ++i) {
953
1067
  R_VAL el = r_ary_entry(objects, i);
954
- r_funcall(el, "ext_render", 0);
1068
+ r_funcall(el, "render", 0); // call the object's `render` function
955
1069
  }
1070
+
1071
+ // Call render proc, `window.render`
1072
+ r_funcall(ruby2d_window, "render_callback", 0);
956
1073
  }
957
1074
 
958
1075
 
@@ -1125,29 +1242,35 @@ void Init_ruby2d() {
1125
1242
  // Ruby2D#self.ext_base_path
1126
1243
  r_define_class_method(ruby2d_module, "ext_base_path", ruby2d_ext_base_path, r_args_none);
1127
1244
 
1245
+ // Ruby2D::Pixel
1246
+ R_CLASS ruby2d_pixel_class = r_define_class(ruby2d_module, "Pixel");
1247
+
1248
+ // Ruby2D::Pixel#self.ext_draw
1249
+ r_define_class_method(ruby2d_pixel_class, "ext_draw", ruby2d_pixel_ext_draw, r_args_req(1));
1250
+
1128
1251
  // Ruby2D::Triangle
1129
1252
  R_CLASS ruby2d_triangle_class = r_define_class(ruby2d_module, "Triangle");
1130
1253
 
1131
- // Ruby2D::Triangle#ext_render
1132
- r_define_method(ruby2d_triangle_class, "ext_render", ruby2d_triangle_ext_render, r_args_none);
1254
+ // Ruby2D::Triangle#self.ext_draw
1255
+ r_define_class_method(ruby2d_triangle_class, "ext_draw", ruby2d_triangle_ext_draw, r_args_req(1));
1133
1256
 
1134
1257
  // Ruby2D::Quad
1135
1258
  R_CLASS ruby2d_quad_class = r_define_class(ruby2d_module, "Quad");
1136
1259
 
1137
- // Ruby2D::Quad#ext_render
1138
- r_define_method(ruby2d_quad_class, "ext_render", ruby2d_quad_ext_render, r_args_none);
1260
+ // Ruby2D::Quad#self.ext_draw
1261
+ r_define_class_method(ruby2d_quad_class, "ext_draw", ruby2d_quad_ext_draw, r_args_req(1));
1139
1262
 
1140
1263
  // Ruby2D::Line
1141
1264
  R_CLASS ruby2d_line_class = r_define_class(ruby2d_module, "Line");
1142
1265
 
1143
- // Ruby2D::Line#ext_render
1144
- r_define_method(ruby2d_line_class, "ext_render", ruby2d_line_ext_render, r_args_none);
1266
+ // Ruby2D::Line#self.ext_draw
1267
+ r_define_class_method(ruby2d_line_class, "ext_draw", ruby2d_line_ext_draw, r_args_req(1));
1145
1268
 
1146
1269
  // Ruby2D::Circle
1147
1270
  R_CLASS ruby2d_circle_class = r_define_class(ruby2d_module, "Circle");
1148
1271
 
1149
- // Ruby2D::Circle#ext_render
1150
- r_define_method(ruby2d_circle_class, "ext_render", ruby2d_circle_ext_render, r_args_none);
1272
+ // Ruby2D::Circle#self.ext_draw
1273
+ r_define_class_method(ruby2d_circle_class, "ext_draw", ruby2d_circle_ext_draw, r_args_req(1));
1151
1274
 
1152
1275
  // Ruby2D::Image
1153
1276
  R_CLASS ruby2d_image_class = r_define_class(ruby2d_module, "Image");
@@ -1155,8 +1278,8 @@ void Init_ruby2d() {
1155
1278
  // Ruby2D::Image#ext_init
1156
1279
  r_define_method(ruby2d_image_class, "ext_init", ruby2d_image_ext_init, r_args_req(1));
1157
1280
 
1158
- // Ruby2D::Image#ext_render
1159
- r_define_method(ruby2d_image_class, "ext_render", ruby2d_image_ext_render, r_args_none);
1281
+ // Ruby2D::Image#self.ext_draw
1282
+ r_define_class_method(ruby2d_image_class, "ext_draw", ruby2d_image_ext_draw, r_args_req(1));
1160
1283
 
1161
1284
  // Ruby2D::Sprite
1162
1285
  R_CLASS ruby2d_sprite_class = r_define_class(ruby2d_module, "Sprite");
@@ -1164,8 +1287,17 @@ void Init_ruby2d() {
1164
1287
  // Ruby2D::Sprite#ext_init
1165
1288
  r_define_method(ruby2d_sprite_class, "ext_init", ruby2d_sprite_ext_init, r_args_req(1));
1166
1289
 
1167
- // Ruby2D::Sprite#ext_render
1168
- r_define_method(ruby2d_sprite_class, "ext_render", ruby2d_sprite_ext_render, r_args_none);
1290
+ // Ruby2D::Sprite#self.ext_draw
1291
+ r_define_class_method(ruby2d_sprite_class, "ext_draw", ruby2d_sprite_ext_draw, r_args_req(1));
1292
+
1293
+ // Ruby2D::Tileset
1294
+ R_CLASS ruby2d_tileset_class = r_define_class(ruby2d_module, "Tileset");
1295
+
1296
+ // Ruby2D::Tileset#ext_init
1297
+ r_define_method(ruby2d_tileset_class, "ext_init", ruby2d_tileset_ext_init, r_args_req(1));
1298
+
1299
+ // Ruby2D::Tileset#self.ext_draw
1300
+ r_define_class_method(ruby2d_tileset_class, "ext_draw", ruby2d_tileset_ext_draw, r_args_req(1));
1169
1301
 
1170
1302
  // Ruby2D::Text
1171
1303
  R_CLASS ruby2d_text_class = r_define_class(ruby2d_module, "Text");
@@ -1176,8 +1308,8 @@ void Init_ruby2d() {
1176
1308
  // Ruby2D::Text#ext_set
1177
1309
  r_define_method(ruby2d_text_class, "ext_set", ruby2d_text_ext_set, r_args_req(1));
1178
1310
 
1179
- // Ruby2D::Text#ext_render
1180
- r_define_method(ruby2d_text_class, "ext_render", ruby2d_text_ext_render, r_args_none);
1311
+ // Ruby2D::Text#self.ext_draw
1312
+ r_define_class_method(ruby2d_text_class, "ext_draw", ruby2d_text_ext_draw, r_args_req(1));
1181
1313
 
1182
1314
  // Ruby2D::Sound
1183
1315
  R_CLASS ruby2d_sound_class = r_define_class(ruby2d_module, "Sound");
@@ -1188,6 +1320,9 @@ void Init_ruby2d() {
1188
1320
  // Ruby2D::Sound#ext_play
1189
1321
  r_define_method(ruby2d_sound_class, "ext_play", ruby2d_sound_ext_play, r_args_none);
1190
1322
 
1323
+ // Ruby2D::Sound#ext_length
1324
+ r_define_method(ruby2d_sound_class, "ext_length", ruby2d_sound_ext_length, r_args_none);
1325
+
1191
1326
  // Ruby2D::Music
1192
1327
  R_CLASS ruby2d_music_class = r_define_class(ruby2d_module, "Music");
1193
1328
 
@@ -1215,6 +1350,9 @@ void Init_ruby2d() {
1215
1350
  // Ruby2D::Music#ext_fadeout
1216
1351
  r_define_method(ruby2d_music_class, "ext_fadeout", ruby2d_music_ext_fadeout, r_args_req(1));
1217
1352
 
1353
+ // Ruby2D::Music#ext_length
1354
+ r_define_method(ruby2d_music_class, "ext_length", ruby2d_music_ext_length, r_args_none);
1355
+
1218
1356
  // Ruby2D::Window
1219
1357
  R_CLASS ruby2d_window_class = r_define_class(ruby2d_module, "Window");
1220
1358