ruby2d 0.9.4 → 0.11.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (156) 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/libmodplug.a +0 -0
  93. data/assets/macos/lib/libmpg123.a +0 -0
  94. data/assets/macos/lib/libogg.a +0 -0
  95. data/assets/macos/lib/libpng16.a +0 -0
  96. data/assets/macos/lib/libtiff.a +0 -0
  97. data/assets/macos/lib/libvorbis.a +0 -0
  98. data/assets/macos/lib/libvorbisfile.a +0 -0
  99. data/assets/macos/lib/libwebp.a +0 -0
  100. data/assets/mingw/bin/SDL2.dll +0 -0
  101. data/assets/mingw/lib/libSDL2.a +0 -0
  102. data/assets/mingw/lib/libSDL2.dll.a +0 -0
  103. data/assets/mingw/lib/libSDL2_test.a +0 -0
  104. data/assets/mingw/lib/libSDL2main.a +0 -0
  105. data/bin/ruby2d +1 -0
  106. data/{assets/linux/simple2d/src/simple2d.c → ext/ruby2d/common.c} +32 -32
  107. data/{assets/linux/simple2d/src → ext/ruby2d}/controllers.c +17 -17
  108. data/ext/ruby2d/extconf.rb +37 -59
  109. data/ext/ruby2d/font.c +35 -0
  110. data/{assets/linux/simple2d/src → ext/ruby2d}/gl.c +66 -98
  111. data/ext/ruby2d/gl2.c +86 -0
  112. data/{assets/linux/simple2d/src → ext/ruby2d}/gl3.c +69 -112
  113. data/{assets/linux/simple2d/src → ext/ruby2d}/gles.c +22 -81
  114. data/ext/ruby2d/image.c +58 -0
  115. data/{assets/linux/simple2d/src → ext/ruby2d}/input.c +8 -8
  116. data/{assets/linux/simple2d/src → ext/ruby2d}/music.c +30 -17
  117. data/ext/ruby2d/ruby2d.c +449 -439
  118. data/ext/ruby2d/ruby2d.h +652 -0
  119. data/{assets/linux/simple2d/src → ext/ruby2d}/shapes.c +18 -18
  120. data/{assets/linux/simple2d/src → ext/ruby2d}/sound.c +39 -14
  121. data/ext/ruby2d/text.c +22 -0
  122. data/{assets/linux/simple2d/src → ext/ruby2d}/window.c +63 -63
  123. data/lib/ruby2d/circle.rb +21 -3
  124. data/lib/ruby2d/cli/build.rb +4 -7
  125. data/lib/ruby2d/dsl.rb +16 -9
  126. data/lib/ruby2d/entity.rb +17 -0
  127. data/lib/ruby2d/font.rb +23 -3
  128. data/lib/ruby2d/image.rb +35 -7
  129. data/lib/ruby2d/line.rb +23 -1
  130. data/lib/ruby2d/music.rb +5 -0
  131. data/lib/ruby2d/pixel.rb +17 -0
  132. data/lib/ruby2d/quad.rb +21 -1
  133. data/lib/ruby2d/rectangle.rb +12 -3
  134. data/lib/ruby2d/renderable.rb +4 -20
  135. data/lib/ruby2d/sound.rb +30 -0
  136. data/lib/ruby2d/sprite.rb +57 -75
  137. data/lib/ruby2d/square.rb +10 -1
  138. data/lib/ruby2d/text.rb +55 -12
  139. data/lib/ruby2d/texture.rb +28 -0
  140. data/lib/ruby2d/tileset.rb +87 -0
  141. data/lib/ruby2d/triangle.rb +19 -1
  142. data/lib/ruby2d/version.rb +1 -1
  143. data/lib/ruby2d/vertices.rb +84 -0
  144. data/lib/ruby2d/window.rb +259 -22
  145. data/lib/ruby2d.rb +6 -1
  146. metadata +30 -26
  147. data/assets/include/simple2d.h +0 -757
  148. data/assets/linux/simple2d/Makefile +0 -260
  149. data/assets/linux/simple2d/bin/simple2d.sh +0 -1318
  150. data/assets/linux/simple2d/include/simple2d.h +0 -757
  151. data/assets/linux/simple2d/src/gl2.c +0 -146
  152. data/assets/linux/simple2d/src/image.c +0 -138
  153. data/assets/linux/simple2d/src/sprite.c +0 -147
  154. data/assets/linux/simple2d/src/text.c +0 -129
  155. data/assets/macos/lib/libsimple2d.a +0 -0
  156. data/assets/mingw/lib/libsimple2d.a +0 -0
@@ -1,31 +1,31 @@
1
1
  // music.c
2
2
 
3
- #include "../include/simple2d.h"
3
+ #include "ruby2d.h"
4
4
 
5
5
 
6
6
  /*
7
7
  * Create the music
8
8
  */
9
- S2D_Music *S2D_CreateMusic(const char *path) {
10
- S2D_Init();
9
+ R2D_Music *R2D_CreateMusic(const char *path) {
10
+ R2D_Init();
11
11
 
12
12
  // Check if music file exists
13
- if (!S2D_FileExists(path)) {
14
- S2D_Error("S2D_CreateMusic", "Music file `%s` not found", path);
13
+ if (!R2D_FileExists(path)) {
14
+ R2D_Error("R2D_CreateMusic", "Music file `%s` not found", path);
15
15
  return NULL;
16
16
  }
17
17
 
18
18
  // Allocate the music structure
19
- S2D_Music *mus = (S2D_Music *) malloc(sizeof(S2D_Music));
19
+ R2D_Music *mus = (R2D_Music *) malloc(sizeof(R2D_Music));
20
20
  if (!mus) {
21
- S2D_Error("S2D_CreateMusic", "Out of memory!");
21
+ R2D_Error("R2D_CreateMusic", "Out of memory!");
22
22
  return NULL;
23
23
  }
24
24
 
25
25
  // Load the music data from file
26
26
  mus->data = Mix_LoadMUS(path);
27
27
  if (!mus->data) {
28
- S2D_Error("Mix_LoadMUS", Mix_GetError());
28
+ R2D_Error("Mix_LoadMUS", Mix_GetError());
29
29
  free(mus);
30
30
  return NULL;
31
31
  }
@@ -33,6 +33,11 @@ S2D_Music *S2D_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
 
@@ -40,7 +45,7 @@ S2D_Music *S2D_CreateMusic(const char *path) {
40
45
  /*
41
46
  * Play the music
42
47
  */
43
- void S2D_PlayMusic(S2D_Music *mus, bool loop) {
48
+ void R2D_PlayMusic(R2D_Music *mus, bool loop) {
44
49
  if (!mus) return;
45
50
 
46
51
  // If looping, set to -1 times; else 0
@@ -49,7 +54,7 @@ void S2D_PlayMusic(S2D_Music *mus, bool loop) {
49
54
  // times: 0 == once, -1 == forever
50
55
  if (Mix_PlayMusic(mus->data, times) == -1) {
51
56
  // No music for you
52
- S2D_Error("S2D_PlayMusic", Mix_GetError());
57
+ R2D_Error("R2D_PlayMusic", Mix_GetError());
53
58
  }
54
59
  }
55
60
 
@@ -57,7 +62,7 @@ void S2D_PlayMusic(S2D_Music *mus, bool loop) {
57
62
  /*
58
63
  * Pause the playing music
59
64
  */
60
- void S2D_PauseMusic() {
65
+ void R2D_PauseMusic() {
61
66
  Mix_PauseMusic();
62
67
  }
63
68
 
@@ -65,7 +70,7 @@ void S2D_PauseMusic() {
65
70
  /*
66
71
  * Resume the current music
67
72
  */
68
- void S2D_ResumeMusic() {
73
+ void R2D_ResumeMusic() {
69
74
  Mix_ResumeMusic();
70
75
  }
71
76
 
@@ -73,7 +78,7 @@ void S2D_ResumeMusic() {
73
78
  /*
74
79
  * Stop the playing music; interrupts fader effects
75
80
  */
76
- void S2D_StopMusic() {
81
+ void R2D_StopMusic() {
77
82
  Mix_HaltMusic();
78
83
  }
79
84
 
@@ -81,7 +86,7 @@ void S2D_StopMusic() {
81
86
  /*
82
87
  * Get the music volume
83
88
  */
84
- int S2D_GetMusicVolume() {
89
+ int R2D_GetMusicVolume() {
85
90
  // Get music volume as percentage of maximum mix volume
86
91
  return ceil(Mix_VolumeMusic(-1) * (100.0 / MIX_MAX_VOLUME));
87
92
  }
@@ -90,7 +95,7 @@ int S2D_GetMusicVolume() {
90
95
  /*
91
96
  * Set the music volume a given percentage
92
97
  */
93
- void S2D_SetMusicVolume(int volume) {
98
+ void R2D_SetMusicVolume(int volume) {
94
99
  // Set volume to be a percentage of the maximum mix volume
95
100
  Mix_VolumeMusic((volume / 100.0) * MIX_MAX_VOLUME);
96
101
  }
@@ -99,15 +104,23 @@ void S2D_SetMusicVolume(int volume) {
99
104
  /*
100
105
  * Fade out the playing music
101
106
  */
102
- void S2D_FadeOutMusic(int ms) {
107
+ void R2D_FadeOutMusic(int ms) {
103
108
  Mix_FadeOutMusic(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
  */
110
- void S2D_FreeMusic(S2D_Music *mus) {
123
+ void R2D_FreeMusic(R2D_Music *mus) {
111
124
  if (!mus) return;
112
125
  Mix_FreeMusic(mus->data);
113
126
  free(mus);