gosu 0.15.2 → 1.0.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (234) hide show
  1. checksums.yaml +4 -4
  2. data/dependencies/SDL/include/SDL.h +138 -0
  3. data/dependencies/SDL/include/SDL_assert.h +293 -0
  4. data/dependencies/SDL/include/SDL_atomic.h +295 -0
  5. data/dependencies/SDL/include/SDL_audio.h +859 -0
  6. data/dependencies/SDL/include/SDL_bits.h +121 -0
  7. data/dependencies/SDL/include/SDL_blendmode.h +123 -0
  8. data/dependencies/SDL/include/SDL_clipboard.h +71 -0
  9. data/dependencies/SDL/include/SDL_config.h +55 -0
  10. data/dependencies/SDL/include/SDL_config_android.h +182 -0
  11. data/dependencies/SDL/include/SDL_config_iphoneos.h +207 -0
  12. data/dependencies/SDL/include/SDL_config_macosx.h +266 -0
  13. data/dependencies/SDL/include/SDL_config_minimal.h +85 -0
  14. data/dependencies/SDL/include/SDL_config_os2.h +188 -0
  15. data/dependencies/SDL/include/SDL_config_pandora.h +135 -0
  16. data/dependencies/SDL/include/SDL_config_psp.h +165 -0
  17. data/dependencies/SDL/include/SDL_config_windows.h +288 -0
  18. data/dependencies/SDL/include/SDL_config_winrt.h +243 -0
  19. data/dependencies/SDL/include/SDL_config_wiz.h +149 -0
  20. data/dependencies/SDL/include/SDL_copying.h +20 -0
  21. data/dependencies/SDL/include/SDL_cpuinfo.h +299 -0
  22. data/dependencies/SDL/include/SDL_egl.h +1676 -0
  23. data/dependencies/SDL/include/SDL_endian.h +263 -0
  24. data/dependencies/SDL/include/SDL_error.h +112 -0
  25. data/dependencies/SDL/include/SDL_events.h +827 -0
  26. data/dependencies/SDL/include/SDL_filesystem.h +136 -0
  27. data/dependencies/SDL/include/SDL_gamecontroller.h +541 -0
  28. data/dependencies/SDL/include/SDL_gesture.h +87 -0
  29. data/dependencies/SDL/include/SDL_haptic.h +1247 -0
  30. data/dependencies/SDL/include/SDL_hints.h +1578 -0
  31. data/dependencies/SDL/include/SDL_joystick.h +499 -0
  32. data/dependencies/SDL/include/SDL_keyboard.h +217 -0
  33. data/dependencies/SDL/include/SDL_keycode.h +351 -0
  34. data/dependencies/SDL/include/SDL_loadso.h +81 -0
  35. data/dependencies/SDL/include/SDL_locale.h +101 -0
  36. data/dependencies/SDL/include/SDL_log.h +211 -0
  37. data/dependencies/SDL/include/SDL_main.h +180 -0
  38. data/dependencies/SDL/include/SDL_messagebox.h +146 -0
  39. data/dependencies/SDL/include/SDL_metal.h +117 -0
  40. data/dependencies/SDL/include/SDL_misc.h +75 -0
  41. data/dependencies/SDL/include/SDL_mouse.h +302 -0
  42. data/dependencies/SDL/include/SDL_mutex.h +251 -0
  43. data/dependencies/SDL/include/SDL_name.h +33 -0
  44. data/dependencies/SDL/include/SDL_opengl.h +2183 -0
  45. data/dependencies/SDL/include/SDL_opengl_glext.h +11180 -0
  46. data/dependencies/SDL/include/SDL_opengles.h +39 -0
  47. data/dependencies/SDL/include/SDL_opengles2.h +52 -0
  48. data/dependencies/SDL/include/SDL_opengles2_gl2.h +621 -0
  49. data/dependencies/SDL/include/SDL_opengles2_gl2ext.h +2050 -0
  50. data/dependencies/SDL/include/SDL_opengles2_gl2platform.h +30 -0
  51. data/dependencies/SDL/include/SDL_opengles2_khrplatform.h +282 -0
  52. data/dependencies/SDL/include/SDL_pixels.h +479 -0
  53. data/dependencies/SDL/include/SDL_platform.h +198 -0
  54. data/dependencies/SDL/include/SDL_power.h +75 -0
  55. data/dependencies/SDL/include/SDL_quit.h +58 -0
  56. data/dependencies/SDL/include/SDL_rect.h +174 -0
  57. data/dependencies/SDL/include/SDL_render.h +1158 -0
  58. data/dependencies/SDL/include/SDL_revision.h +2 -0
  59. data/dependencies/SDL/include/SDL_rwops.h +283 -0
  60. data/dependencies/SDL/include/SDL_scancode.h +413 -0
  61. data/dependencies/SDL/include/SDL_sensor.h +267 -0
  62. data/dependencies/SDL/include/SDL_shape.h +144 -0
  63. data/dependencies/SDL/include/SDL_stdinc.h +647 -0
  64. data/dependencies/SDL/include/SDL_surface.h +563 -0
  65. data/dependencies/SDL/include/SDL_system.h +325 -0
  66. data/dependencies/SDL/include/SDL_syswm.h +354 -0
  67. data/dependencies/SDL/include/SDL_test.h +69 -0
  68. data/dependencies/SDL/include/SDL_test_assert.h +105 -0
  69. data/dependencies/SDL/include/SDL_test_common.h +218 -0
  70. data/dependencies/SDL/include/SDL_test_compare.h +69 -0
  71. data/dependencies/SDL/include/SDL_test_crc32.h +124 -0
  72. data/dependencies/SDL/include/SDL_test_font.h +81 -0
  73. data/dependencies/SDL/include/SDL_test_fuzzer.h +384 -0
  74. data/dependencies/SDL/include/SDL_test_harness.h +134 -0
  75. data/dependencies/SDL/include/SDL_test_images.h +78 -0
  76. data/dependencies/SDL/include/SDL_test_log.h +67 -0
  77. data/dependencies/SDL/include/SDL_test_md5.h +129 -0
  78. data/dependencies/SDL/include/SDL_test_memory.h +63 -0
  79. data/dependencies/SDL/include/SDL_test_random.h +115 -0
  80. data/dependencies/SDL/include/SDL_thread.h +366 -0
  81. data/dependencies/SDL/include/SDL_timer.h +115 -0
  82. data/dependencies/SDL/include/SDL_touch.h +102 -0
  83. data/dependencies/SDL/include/SDL_types.h +29 -0
  84. data/dependencies/SDL/include/SDL_version.h +162 -0
  85. data/dependencies/SDL/include/SDL_video.h +1282 -0
  86. data/dependencies/SDL/include/SDL_vulkan.h +276 -0
  87. data/dependencies/SDL/include/begin_code.h +166 -0
  88. data/dependencies/SDL/include/close_code.h +40 -0
  89. data/dependencies/SDL/lib/x64/libSDL2.dll.a +0 -0
  90. data/dependencies/SDL/lib/x86/libSDL2.dll.a +0 -0
  91. data/dependencies/SDL_sound/SDL_sound.c +795 -0
  92. data/dependencies/SDL_sound/SDL_sound.h +725 -0
  93. data/dependencies/SDL_sound/SDL_sound_aiff.c +537 -0
  94. data/dependencies/SDL_sound/SDL_sound_au.c +352 -0
  95. data/dependencies/SDL_sound/SDL_sound_coreaudio.c +747 -0
  96. data/dependencies/SDL_sound/SDL_sound_flac.c +182 -0
  97. data/dependencies/SDL_sound/SDL_sound_internal.h +304 -0
  98. data/dependencies/SDL_sound/SDL_sound_modplug.c +228 -0
  99. data/dependencies/SDL_sound/SDL_sound_mp3.c +184 -0
  100. data/dependencies/SDL_sound/SDL_sound_raw.c +164 -0
  101. data/dependencies/SDL_sound/SDL_sound_shn.c +1309 -0
  102. data/dependencies/SDL_sound/SDL_sound_voc.c +550 -0
  103. data/dependencies/SDL_sound/SDL_sound_vorbis.c +223 -0
  104. data/dependencies/SDL_sound/SDL_sound_wav.c +783 -0
  105. data/dependencies/SDL_sound/dr_flac.h +5906 -0
  106. data/dependencies/SDL_sound/dr_mp3.h +2832 -0
  107. data/dependencies/SDL_sound/libmodplug/fastmix.c +1748 -0
  108. data/dependencies/SDL_sound/libmodplug/libmodplug.h +1001 -0
  109. data/dependencies/SDL_sound/libmodplug/load_669.c +188 -0
  110. data/dependencies/SDL_sound/libmodplug/load_abc.c +4725 -0
  111. data/dependencies/SDL_sound/libmodplug/load_amf.c +403 -0
  112. data/dependencies/SDL_sound/libmodplug/load_ams.c +587 -0
  113. data/dependencies/SDL_sound/libmodplug/load_dbm.c +357 -0
  114. data/dependencies/SDL_sound/libmodplug/load_dmf.c +531 -0
  115. data/dependencies/SDL_sound/libmodplug/load_dsm.c +232 -0
  116. data/dependencies/SDL_sound/libmodplug/load_far.c +253 -0
  117. data/dependencies/SDL_sound/libmodplug/load_it.c +796 -0
  118. data/dependencies/SDL_sound/libmodplug/load_mdl.c +488 -0
  119. data/dependencies/SDL_sound/libmodplug/load_med.c +757 -0
  120. data/dependencies/SDL_sound/libmodplug/load_mid.c +1405 -0
  121. data/dependencies/SDL_sound/libmodplug/load_mod.c +269 -0
  122. data/dependencies/SDL_sound/libmodplug/load_mt2.c +546 -0
  123. data/dependencies/SDL_sound/libmodplug/load_mtm.c +142 -0
  124. data/dependencies/SDL_sound/libmodplug/load_okt.c +192 -0
  125. data/dependencies/SDL_sound/libmodplug/load_pat.c +1143 -0
  126. data/dependencies/SDL_sound/libmodplug/load_pat.h +25 -0
  127. data/dependencies/SDL_sound/libmodplug/load_psm.c +350 -0
  128. data/dependencies/SDL_sound/libmodplug/load_ptm.c +204 -0
  129. data/dependencies/SDL_sound/libmodplug/load_s3m.c +325 -0
  130. data/dependencies/SDL_sound/libmodplug/load_stm.c +180 -0
  131. data/dependencies/SDL_sound/libmodplug/load_ult.c +206 -0
  132. data/dependencies/SDL_sound/libmodplug/load_umx.c +51 -0
  133. data/dependencies/SDL_sound/libmodplug/load_xm.c +554 -0
  134. data/dependencies/SDL_sound/libmodplug/mmcmp.c +382 -0
  135. data/dependencies/SDL_sound/libmodplug/modplug.c +170 -0
  136. data/dependencies/SDL_sound/libmodplug/modplug.h +90 -0
  137. data/dependencies/SDL_sound/libmodplug/snd_dsp.c +301 -0
  138. data/dependencies/SDL_sound/libmodplug/snd_flt.c +63 -0
  139. data/dependencies/SDL_sound/libmodplug/snd_fx.c +2350 -0
  140. data/dependencies/SDL_sound/libmodplug/sndfile.c +1169 -0
  141. data/dependencies/SDL_sound/libmodplug/sndmix.c +1034 -0
  142. data/dependencies/SDL_sound/libmodplug/tables.h +371 -0
  143. data/{src/stb_vorbis.c → dependencies/SDL_sound/stb_vorbis.h} +143 -78
  144. data/dependencies/al_soft/AL/al.h +655 -0
  145. data/dependencies/al_soft/AL/alc.h +270 -0
  146. data/dependencies/al_soft/AL/alext.h +585 -0
  147. data/dependencies/al_soft/AL/efx-creative.h +3 -0
  148. data/dependencies/al_soft/AL/efx-presets.h +402 -0
  149. data/dependencies/al_soft/AL/efx.h +762 -0
  150. data/dependencies/al_soft/x64/libOpenAL32.dll.a +0 -0
  151. data/dependencies/al_soft/x86/libOpenAL32.dll.a +0 -0
  152. data/{src → dependencies/stb}/stb_image.h +330 -127
  153. data/{src → dependencies/stb}/stb_image_write.h +156 -85
  154. data/{src → dependencies/stb}/stb_truetype.h +192 -69
  155. data/{src → dependencies/utf8proc}/utf8proc.c +0 -0
  156. data/{src → dependencies/utf8proc}/utf8proc.h +0 -0
  157. data/{src → dependencies/utf8proc}/utf8proc_data.h +0 -0
  158. data/ext/gosu/extconf.rb +56 -22
  159. data/{Gosu → include/Gosu}/Audio.hpp +6 -8
  160. data/{Gosu → include/Gosu}/AutoLink.hpp +0 -0
  161. data/include/Gosu/Bitmap.hpp +100 -0
  162. data/{Gosu → include/Gosu}/Buttons.hpp +94 -35
  163. data/{Gosu → include/Gosu}/Channel.h +0 -0
  164. data/{Gosu → include/Gosu}/Color.h +0 -0
  165. data/{Gosu → include/Gosu}/Color.hpp +0 -0
  166. data/{Gosu → include/Gosu}/Directories.hpp +0 -0
  167. data/{Gosu → include/Gosu}/Font.h +0 -0
  168. data/{Gosu → include/Gosu}/Font.hpp +0 -0
  169. data/{Gosu → include/Gosu}/Fwd.hpp +0 -0
  170. data/{Gosu → include/Gosu}/Gosu.h +3 -0
  171. data/{Gosu → include/Gosu}/Gosu.hpp +0 -0
  172. data/{Gosu → include/Gosu}/Graphics.hpp +0 -0
  173. data/{Gosu → include/Gosu}/GraphicsBase.hpp +0 -0
  174. data/{Gosu → include/Gosu}/IO.hpp +0 -0
  175. data/{Gosu → include/Gosu}/Image.h +0 -0
  176. data/{Gosu → include/Gosu}/Image.hpp +7 -6
  177. data/{Gosu → include/Gosu}/ImageData.hpp +0 -0
  178. data/{Gosu → include/Gosu}/Input.hpp +30 -15
  179. data/{Gosu → include/Gosu}/Inspection.hpp +0 -0
  180. data/{Gosu → include/Gosu}/Math.hpp +0 -0
  181. data/{Gosu → include/Gosu}/Platform.hpp +0 -0
  182. data/{Gosu → include/Gosu}/Sample.h +0 -0
  183. data/{Gosu → include/Gosu}/Song.h +0 -0
  184. data/{Gosu → include/Gosu}/Text.hpp +0 -0
  185. data/{Gosu → include/Gosu}/TextInput.h +0 -0
  186. data/{Gosu → include/Gosu}/TextInput.hpp +0 -0
  187. data/{Gosu → include/Gosu}/Timing.hpp +0 -0
  188. data/{Gosu → include/Gosu}/Utility.hpp +1 -1
  189. data/{Gosu → include/Gosu}/Version.hpp +0 -0
  190. data/{Gosu → include/Gosu}/Window.h +2 -0
  191. data/{Gosu → include/Gosu}/Window.hpp +21 -13
  192. data/lib/OpenAL32.dll +0 -0
  193. data/lib/SDL2.dll +0 -0
  194. data/lib/gosu.rb +0 -3
  195. data/lib/gosu/patches.rb +0 -9
  196. data/lib/gosu/swig_patches.rb +3 -2
  197. data/lib/libmpg123.dll +0 -0
  198. data/lib/libsndfile.dll +0 -0
  199. data/lib64/OpenAL32.dll +0 -0
  200. data/lib64/SDL2.dll +0 -0
  201. data/lib64/libmpg123.dll +0 -0
  202. data/lib64/libsndfile.dll +0 -0
  203. data/rdoc/gosu.rb +95 -20
  204. data/src/Audio.cpp +50 -224
  205. data/src/AudioFile.hpp +17 -37
  206. data/src/AudioFileAudioToolbox.cpp +237 -0
  207. data/src/AudioFileSDLSound.cpp +147 -0
  208. data/src/AudioImpl.cpp +3 -12
  209. data/src/AudioImpl.hpp +3 -1
  210. data/src/Bitmap.cpp +85 -83
  211. data/src/BitmapIO.cpp +52 -58
  212. data/src/Constants.cpp +80 -33
  213. data/src/Font.cpp +3 -1
  214. data/src/GosuWrapper.cpp +19 -0
  215. data/src/Graphics.cpp +7 -4
  216. data/src/Image.cpp +13 -16
  217. data/src/Input.cpp +408 -159
  218. data/src/LargeImageData.cpp +1 -1
  219. data/src/MarkupParser.cpp +2 -1
  220. data/src/RubyGosu.cxx +349 -83
  221. data/src/RubyGosu.h +4 -2
  222. data/src/TexChunk.cpp +1 -1
  223. data/src/TextBuilder.cpp +3 -1
  224. data/src/Texture.cpp +1 -1
  225. data/src/TrueTypeFont.cpp +1 -1
  226. data/src/Utility.cpp +11 -7
  227. data/src/Window.cpp +30 -39
  228. data/src/WindowWrapper.cpp +28 -0
  229. metadata +207 -52
  230. data/Gosu/Bitmap.hpp +0 -113
  231. data/src/AudioToolboxFile.hpp +0 -210
  232. data/src/OggFile.hpp +0 -92
  233. data/src/SndFile.hpp +0 -174
  234. data/src/WinMain.cpp +0 -64
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -67,6 +67,9 @@ unsigned Gosu_screen_height(Gosu_Window* window);
67
67
  int Gosu_button_down(int id);
68
68
  const char* Gosu_button_id_to_char(int id);
69
69
  unsigned Gosu_button_char_to_id(const char* character);
70
+ const char *Gosu_button_name(int id);
71
+ const char *Gosu_gamepad_name(int id);
72
+ double Gosu_axis(int id);
70
73
 
71
74
  // Misc
72
75
  int Gosu_fps();
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -7,6 +7,7 @@
7
7
  #include <Gosu/Color.hpp>
8
8
  #include <Gosu/GraphicsBase.hpp>
9
9
  #include <memory>
10
+ #include <string>
10
11
  #include <vector>
11
12
 
12
13
  namespace Gosu
@@ -30,15 +31,15 @@ namespace Gosu
30
31
  //!
31
32
  //! A color key of #ff00ff is automatically applied to BMP image files.
32
33
  //! For more flexibility, use the corresponding constructor that uses a Bitmap object.
33
- Image(const std::string& filename, unsigned src_x, unsigned src_y,
34
- unsigned src_width, unsigned src_height, unsigned image_flags = IF_SMOOTH);
34
+ Image(const std::string& filename, int src_x, int src_y,
35
+ int src_width, int src_height, unsigned image_flags = IF_SMOOTH);
35
36
 
36
37
  //! Converts the given bitmap into an image.
37
38
  explicit Image(const Bitmap& source, unsigned image_flags = IF_SMOOTH);
38
39
 
39
40
  //! Converts a portion of the given bitmap into an image.
40
- Image(const Bitmap& source, unsigned src_x, unsigned src_y, unsigned src_width,
41
- unsigned src_height, unsigned image_flags = IF_SMOOTH);
41
+ Image(const Bitmap& source, int src_x, int src_y, int src_width,
42
+ int src_height, unsigned image_flags = IF_SMOOTH);
42
43
 
43
44
  //! Creates an Image from a user-supplied instance of the ImageData interface.
44
45
  explicit Image(std::unique_ptr<ImageData>&& data);
@@ -47,7 +48,7 @@ namespace Gosu
47
48
  unsigned height() const;
48
49
 
49
50
  //! Draws the image so its upper left corner is at (x; y).
50
- void draw(double x, double y, ZPos z, double scale_x = 1, double scale_y = 1,
51
+ void draw(double x, double y, ZPos z = 0, double scale_x = 1, double scale_y = 1,
51
52
  Color c = Color::WHITE, AlphaMode mode = AM_DEFAULT) const;
52
53
  //! Like draw(), but with modulation colors for all four corners.
53
54
  void draw_mod(double x, double y, ZPos z, double scale_x, double scale_y,
@@ -62,7 +63,7 @@ namespace Gosu
62
63
  //! on the image. 0 is the left border, 1 is the right border, 0.5 is
63
64
  //! the center (and default).
64
65
  //! \param center_y See center_x.
65
- void draw_rot(double x, double y, ZPos z, double angle,
66
+ void draw_rot(double x, double y, ZPos z = 0, double angle = 0,
66
67
  double center_x = 0.5, double center_y = 0.5, double scale_x = 1, double scale_y = 1,
67
68
  Color c = Color::WHITE, AlphaMode mode = AM_DEFAULT) const;
68
69
 
File without changes
@@ -8,6 +8,7 @@
8
8
  #include <Gosu/Platform.hpp>
9
9
  #include <functional>
10
10
  #include <memory>
11
+ #include <string>
11
12
  #include <vector>
12
13
 
13
14
  namespace Gosu
@@ -16,7 +17,7 @@ namespace Gosu
16
17
  class Button
17
18
  {
18
19
  unsigned id_;
19
-
20
+
20
21
  public:
21
22
  //! For internal use.
22
23
  explicit Button(unsigned id) : id_(id) {}
@@ -29,12 +30,12 @@ namespace Gosu
29
30
  //! Conversion from ButtonName constants.
30
31
  Button(ButtonName name) : id_(name) {}
31
32
  };
32
-
33
+
33
34
  //! Tests whether two Buttons identify the same physical button.
34
35
  inline bool operator==(Button lhs, Button rhs) { return lhs.id() == rhs.id(); }
35
36
  inline bool operator!=(Button lhs, Button rhs) { return !(lhs == rhs); }
36
37
  inline bool operator<(Button lhs, Button rhs) { return lhs.id() < rhs.id(); }
37
-
38
+
38
39
  //! Struct that saves information about a touch on the surface of a multi-
39
40
  //! touch device.
40
41
  //! Available even on non-iPhone platforms to make it easier to compile the
@@ -47,7 +48,7 @@ namespace Gosu
47
48
  float x, y;
48
49
  };
49
50
  typedef std::vector<Touch> Touches;
50
-
51
+
51
52
  //! Manages initialization and shutdown of the input system. Only one Input
52
53
  //! instance can exist per application.
53
54
  class Input
@@ -64,26 +65,38 @@ namespace Gosu
64
65
  Input(void* window);
65
66
  bool feed_sdl_event(void* event);
66
67
  #endif
67
-
68
+
68
69
  ~Input();
69
-
70
+
70
71
  //! Returns the character (as a UTF-8 encoded string) that a button usually produces.
71
72
  //! Returns the empty string if nothing can be found.
72
73
  static std::string id_to_char(Button btn);
73
74
  //! Returns the button that has to be pressed to produce the given character (as a UTF-8
74
75
  //! encoded string), or NO_BUTTON.
75
76
  static Button char_to_id(std::string ch);
76
-
77
+
78
+ //! Returns the name for the given button, provided it is a Gosu::KB_{constant}
79
+ //! Returns the empty string if nothing can be found.
80
+ static std::string button_name(Button btn);
81
+
82
+ //! Returns the name for the given gamepad.
83
+ //! Returns an empty string if there is no gamepad in the slot index.
84
+ static std::string gamepad_name(int index);
85
+
77
86
  //! Returns true if a button is currently pressed.
78
87
  //! Updated every tick.
79
88
  static bool down(Button btn);
80
-
89
+
90
+ //! Returns the value of a Gamepad joystick in the range -1.0 thru +1.0 and trigger in the range 0.0 thru +1.0.
91
+ //! Updated every tick.
92
+ static double axis(Button btn);
93
+
81
94
  //! Returns the horizontal position of the mouse relative to the top
82
95
  //! left corner of the window given to Input's constructor.
83
96
  double mouse_x() const;
84
97
  //! See mouse_x.
85
98
  double mouse_y() const;
86
-
99
+
87
100
  //! Immediately moves the mouse as far towards the desired position
88
101
  //! as possible. x and y are relative to the window, just as in mouse_x()
89
102
  //! and mouse_y(), so (0, 0) is the top left corner of the window..
@@ -92,29 +105,31 @@ namespace Gosu
92
105
  // Undocumented for the moment. Also applies to current_touches().
93
106
  void set_mouse_factors(double factor_x, double factor_y,
94
107
  double offset_x = 0, double offset_y = 0);
95
-
108
+
96
109
  //! Currently known touches.
97
110
  const Touches& current_touches() const;
98
-
111
+
99
112
  //! Accelerometer positions in all three dimensions (smoothened).
100
113
  //! Note: Not really deprecated, but temporarily defunct.
101
114
  GOSU_DEPRECATED double accelerometer_x() const;
102
115
  GOSU_DEPRECATED double accelerometer_y() const;
103
116
  GOSU_DEPRECATED double accelerometer_z() const;
104
-
117
+
105
118
  //! Collects new information about which buttons are pressed, where the
106
119
  //! mouse is and calls on_button_up/on_button_down, if assigned.
107
120
  void update();
108
-
121
+
109
122
  //! Assignable events that are called by update. You can bind these to your own functions.
110
123
  //! If you use the Window class, it will assign these to its own methods.
111
124
  std::function<void (Button)> on_button_down, on_button_up;
112
-
125
+
126
+ std::function<void (int)> on_gamepad_connected, on_gamepad_disconnected;
127
+
113
128
  //! Assignable events that are called by update. You can bind these to your own functions.
114
129
  //! If you use the Window class, it will assign these to its own methods.
115
130
  std::function<void (Touch)> on_touch_began, on_touch_moved, on_touch_ended,
116
131
  on_touch_cancelled;
117
-
132
+
118
133
  //! Returns the currently active TextInput instance, or nullptr.
119
134
  TextInput* text_input() const;
120
135
  //! Sets the currently active TextInput, or resets it to the nullptr.
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -11,7 +11,7 @@ namespace Gosu
11
11
 
12
12
  //! Returns true if the filename has the given extension.
13
13
  //! The comparison is case-insensitive, but you must pass the extension in lower case.
14
- bool has_extension(const std::string& filename, const char* extension);
14
+ bool has_extension(std::string_view filename, std::string_view extension);
15
15
 
16
16
  //! Returns the user's preferred language, at the moment of calling the function. Expect return
17
17
  //! values such as 'en_US', 'de_DE.UTF-8', 'ja', 'zh-Hans'.
File without changes
@@ -16,6 +16,8 @@ void Gosu_Window_set_update(Gosu_Window *window, void function(void *data), void
16
16
  void Gosu_Window_set_draw(Gosu_Window *window, void function(void *data), void* data);
17
17
  void Gosu_Window_set_button_down(Gosu_Window *window, void function(void *data, unsigned btn), void* data);
18
18
  void Gosu_Window_set_button_up(Gosu_Window *window, void function(void *data, unsigned btn), void* data);
19
+ void Gosu_Window_set_gamepad_connected(Gosu_Window *window, void function(void *data, int id), void* data);
20
+ void Gosu_Window_set_gamepad_disconnected(Gosu_Window *window, void function(void *data, int id), void* data);
19
21
  void Gosu_Window_set_drop(Gosu_Window *window, void function(void *data, const char *filename), void* data);
20
22
  void Gosu_Window_set_needs_redraw(Gosu_Window *window, bool function(void *data), void* data);
21
23
  void Gosu_Window_set_needs_cursor(Gosu_Window *window, bool function(void *data), void* data);
@@ -52,7 +52,7 @@ namespace Gosu
52
52
  //! Enters a modal loop where the Window is visible on screen and
53
53
  //! receives calls to draw, update etc.
54
54
  virtual void show();
55
-
55
+
56
56
  //! EXPERIMENTAL - MAY DISAPPEAR WITHOUT WARNING.
57
57
  //! Performs a single main loop step.
58
58
  //! This method is only useful if you want to integrate Gosu with another library that has
@@ -62,7 +62,7 @@ namespace Gosu
62
62
  //! If you discard the return value and keep calling tick(), the window will be shown again,
63
63
  //! or keep being shown.
64
64
  virtual bool tick();
65
-
65
+
66
66
  //! Closes the window if it is currently shown.
67
67
  //! If you do not want the window to close immediately, you should override this method and
68
68
  //! only call the base implementation (Window::close) when needed.
@@ -71,11 +71,11 @@ namespace Gosu
71
71
  //! Called every update_interval milliseconds while the window is being shown.
72
72
  //! Your application's main game logic goes here.
73
73
  virtual void update() {}
74
-
74
+
75
75
  //! Called after every update and when the OS wants the window to repaint itself.
76
76
  //! Your application's rendering code goes here.
77
77
  virtual void draw() {}
78
-
78
+
79
79
  //! Gives the game a chance to say no to being redrawn.
80
80
  //! This is not a definitive answer. The operating system can still force the window to
81
81
  //! redraw itself.
@@ -84,11 +84,11 @@ namespace Gosu
84
84
 
85
85
  //! If this function returns true, the system arrow cursor is drawn while over the window.
86
86
  virtual bool needs_cursor() const { return false; }
87
-
87
+
88
88
  //! This function is called when the window loses focus on some platforms.
89
89
  //! Most importantly, it is called on the iPhone or iPad when the user locks the screen.
90
90
  virtual void lose_focus() {}
91
-
91
+
92
92
  //! This function is called when the operating system's memory is low.
93
93
  //! So far, it is only called in iOS applications.
94
94
  virtual void release_memory() {}
@@ -99,10 +99,18 @@ namespace Gosu
99
99
  //! To support these shortcuts in your application, make sure to call Window::button_down
100
100
  //! in your implementation.
101
101
  virtual void button_down(Gosu::Button);
102
-
102
+
103
103
  //! Same as button_down. Called when the user releases a button.
104
104
  virtual void button_up(Gosu::Button) {}
105
105
 
106
+ //! Called when a gamepad is connected.
107
+ //! \param index the index of the gamepad slot that the gamepad is in.
108
+ virtual void gamepad_connected(int index) {}
109
+
110
+ //! Called when a gamepad is disconnected.
111
+ //! \param index the index of the gamepad slot that the gamepad is in. The slot will be freed immediately after this callback.
112
+ virtual void gamepad_disconnected(int index) {}
113
+
106
114
  //! Called when a file is dropped onto the window.
107
115
  //! \param filename The filename of the dropped file. When multiple files are dropped, this
108
116
  //! method will be called several times.
@@ -115,14 +123,14 @@ namespace Gosu
115
123
  virtual void touch_moved(Touch touch) {}
116
124
  virtual void touch_ended(Touch touch) {}
117
125
  virtual void touch_cancelled(Touch touch) {}
118
-
126
+
119
127
  const Graphics& graphics() const;
120
128
  Graphics& graphics();
121
-
129
+
122
130
  const Input& input() const;
123
131
  Input& input();
124
132
  #endif
125
-
133
+
126
134
  #ifdef GOSU_IS_IPHONE
127
135
  void* uikit_window() const;
128
136
  #endif
@@ -132,18 +140,18 @@ namespace Gosu
132
140
  //! \param window The result describes the screen on which the window is shown, or the
133
141
  //! primary screen if no window is given.
134
142
  unsigned screen_width(Window* window = nullptr);
135
-
143
+
136
144
  //! Returns the height (in pixels) of the user's primary screen.
137
145
  //! \param window The result describes the screen on which the window is shown, or the
138
146
  //! primary screen if no window is given.
139
147
  unsigned screen_height(Window* window = nullptr);
140
-
148
+
141
149
  //! Returns the maximum width (in 'points') that is available for a non-fullscreen Window.
142
150
  //! All windows larger than this size will automatically be shrunk to fit.
143
151
  //! \param window The result describes the screen on which the window is shown, or the
144
152
  //! primary screen if no window is given.
145
153
  unsigned available_width(Window* window = nullptr);
146
-
154
+
147
155
  //! Returns the maximum height (in 'points') that is available for a non-fullscreen Window.
148
156
  //! All windows larger than this size will automatically be shrunk to fit.
149
157
  //! \param window The result describes the screen on which the window is shown, or the
Binary file
Binary file
@@ -17,9 +17,6 @@ if RUBY_PLATFORM =~ /mswin$|mingw32|mingw64|win32\-|\-win32/
17
17
  path_encoding = ENV["PATH"].encoding
18
18
  ENV["PATH"] = "#{binary_path.encode(path_encoding)};#{ENV["PATH"]}"
19
19
  end
20
-
21
- # Add the correct lib directory for the current version of Ruby (major.minor).
22
- $LOAD_PATH.unshift File.join(binary_path, RUBY_VERSION[/^\d+.\d+/])
23
20
  end
24
21
 
25
22
  require "gosu.#{RbConfig::CONFIG["DLEXT"]}"
@@ -78,12 +78,3 @@ class Gosu::Window
78
78
  _tick
79
79
  end
80
80
  end
81
-
82
- # Release OpenAL resources during Ruby's shutdown, not Gosu's.
83
- at_exit do
84
- begin
85
- Gosu::Song.current_song.stop if Gosu::Song.current_song
86
- Gosu._release_all_openal_resources
87
- rescue
88
- end
89
- end
@@ -19,7 +19,8 @@ class Gosu::Window
19
19
  end
20
20
 
21
21
  %w(update draw needs_redraw? needs_cursor?
22
- lose_focus button_down button_up).each do |callback|
22
+ lose_focus button_down button_up
23
+ gamepad_connected gamepad_disconnected drop).each do |callback|
23
24
  define_method "protected_#{callback}" do |*args|
24
25
  begin
25
26
  # If there has been an exception, don't do anything as to not make matters worse.
@@ -47,7 +48,7 @@ class Gosu::Window
47
48
  # doing here.
48
49
  if defined? @_exception
49
50
  if @_exception.backtrace.is_a? Array and not @_exception.backtrace.frozen?
50
- @_exception.backtrace.reject! { |line| line.include? 'lib/gosu/swig_patches.rb' }
51
+ @_exception.backtrace.reject! { |line| line.include? "lib/gosu/swig_patches.rb" }
51
52
  end
52
53
  raise @_exception
53
54
  end
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -32,6 +32,10 @@ module Gosu
32
32
  KB_DOWN = :an_integer
33
33
  KB_END = :an_integer
34
34
 
35
+ KB_PRINTSCREEN = :an_integer
36
+ KB_SCROLLLOCK = :an_integer
37
+ KB_PAUSE = :an_integer
38
+
35
39
  ##
36
40
  # This is the key on the numpad.
37
41
  KB_ENTER = :an_integer
@@ -71,6 +75,7 @@ module Gosu
71
75
  KB_RIGHT_SHIFT = :an_integer
72
76
  KB_SEMICOLON = :an_integer
73
77
  KB_SLASH = :an_integer
78
+ KB_CAPSLOCK = :an_integer
74
79
  KB_SPACE = :an_integer
75
80
  KB_TAB = :an_integer
76
81
  KB_UP = :an_integer
@@ -83,12 +88,32 @@ module Gosu
83
88
  MS_OTHER_0…MS_OTHER_7 = :an_integer
84
89
 
85
90
  GP_BUTTON_0…GP_BUTTON_15 = :an_integer
91
+ GP_LEFT_STICK_X_AXIS = :an_integer
92
+ GP_RIGHT_STICK_X_AXIS = :an_integer
93
+ GP_LEFT_STICK_Y_AXIS = :an_integer
94
+ GP_RIGHT_STICK_Y_AXIS = :an_integer
95
+ GP_LEFT_TRIGGER_AXIS = :an_integer
96
+ GP_RIGHT_TRIGGER_AXIS = :an_integer
97
+ GP_DPAD_DOWN = :an_integer
98
+ GP_DPAD_LEFT = :an_integer
99
+ GP_DPAD_RIGHT = :an_integer
100
+ GP_DPAD_UP = :an_integer
86
101
  GP_DOWN = :an_integer
87
102
  GP_LEFT = :an_integer
88
103
  GP_RIGHT = :an_integer
89
104
  GP_UP = :an_integer
90
105
 
91
106
  GP_0_BUTTON_0…GP_3_BUTTON_15 = :an_integer
107
+ GP_0_LEFT_STICK_X_AXIS…GP_3_LEFT_STICK_X_AXIS = :an_integer
108
+ GP_0_RIGHT_STICK_X_AXIS…GP_3_RIGHT_STICK_X_AXIS = :an_integer
109
+ GP_0_LEFT_STICK_Y_AXIS…GP_3_LEFT_STICK_Y_AXIS = :an_integer
110
+ GP_0_RIGHT_STICK_Y_AXIS…GP_3_RIGHT_STICK_Y_AXIS = :an_integer
111
+ GP_0_LEFT_TRIGGER_AXIS…GP_3_LEFT_TRIGGER_AXIS = :an_integer
112
+ GP_0_RIGHT_TRIGGER_AXIS…GP_3_RIGHT_TRIGGER_AXIS = :an_integer
113
+ GP_0_DPAD_DOWN…GP_3_DPAD_DOWN = :an_integer
114
+ GP_0_DPAD_LEFT…GP_3_DPAD_LEFT = :an_integer
115
+ GP_0_DPAD_RIGHT…GP_3_DPAD_RIGHT = :an_integer
116
+ GP_0_DPAD_UP…GP_3_DPAD_UP = :an_integer
92
117
  GP_0_DOWN…GP_3_DOWN = :an_integer
93
118
  GP_0_LEFT…GP_3_LEFT = :an_integer
94
119
  GP_0_RIGHT…GP_3_RIGHT = :an_integer
@@ -193,14 +218,14 @@ module Gosu
193
218
  ##
194
219
  # @return [Integer] a 32-bit representation of the color in 0xAARRGGBB format.
195
220
  def argb; end
196
-
221
+
197
222
  alias_method :to_i, :argb
198
223
 
199
224
  # Returns a 32-bit representation of the color suitable for use with OpenGL calls. This color is stored in a fixed format in memory and its integer value may vary depending on your system's byte order.
200
225
  #
201
226
  # @return [Integer] a 32-bit OpenGL color.
202
227
  def gl; end
203
-
228
+
204
229
  # Returns an OpenGL integer constant that identifies the RGBA color format that Gosu uses.
205
230
  GL_FORMAT = :some_integer
206
231
 
@@ -316,7 +341,7 @@ module Gosu
316
341
  # @return [Integer] the width of the text, in pixels.
317
342
  # @param text [String]
318
343
  def text_width(text, scale_x=1); end
319
-
344
+
320
345
  ##
321
346
  # Like {#text_width}, but supports the following markup tags: `<b>bold</b>`, `<i>italic</i>`, `<c=rrggbb>colors</c>`.
322
347
  def markup_width(markup, scale_x=1); end
@@ -420,13 +445,13 @@ module Gosu
420
445
 
421
446
  ##
422
447
  # Returns an image that is a smaller, rectangular view of this {Image}.
423
- #
448
+ #
424
449
  # This is a very fast operation, and no new textures will be allocated.
425
450
  # If you update this {Image} or the {#subimage} using {#insert}, the other {Image} will be affected as well.
426
- #
451
+ #
427
452
  # Caveats:
428
453
  # * If you stretch or rotate a {#subimage}, the pixels adjacent to it might bleed into it, as Gosu does not manage the 'tileability' of subimages.
429
- #
454
+ #
430
455
  # @return [Image?] an image that represents a portion of the containing image
431
456
  def subimage(left, top, width, height); end
432
457
 
@@ -450,7 +475,7 @@ module Gosu
450
475
  # @see #draw_as_quad
451
476
  # @see https://github.com/gosu/gosu/wiki/Basic-Concepts#drawing-with-colours Drawing with colors, explained in the Gosu Wiki
452
477
  # @see https://github.com/gosu/gosu/wiki/Basic-Concepts#z-ordering Z-ordering explained in the Gosu Wiki
453
- def draw(x, y, z, scale_x=1, scale_y=1, color=0xff_ffffff, mode=:default); end
478
+ def draw(x, y, z=0, scale_x=1, scale_y=1, color=0xff_ffffff, mode=:default); end
454
479
 
455
480
  ##
456
481
  # Draws the image rotated, with its rotational center at (x, y).
@@ -464,7 +489,7 @@ module Gosu
464
489
  # @see #draw
465
490
  # @see https://github.com/gosu/gosu/wiki/Basic-Concepts#drawing-with-colours Drawing with colors, explained in the Gosu Wiki
466
491
  # @see https://github.com/gosu/gosu/wiki/Basic-Concepts#z-ordering Z-ordering explained in the Gosu Wiki
467
- def draw_rot(x, y, z, angle, center_x=0.5, center_y=0.5, scale_x=1, scale_y=1, color=0xff_ffffff, mode=:default); end
492
+ def draw_rot(x, y, z=0, angle=0, center_x=0.5, center_y=0.5, scale_x=1, scale_y=1, color=0xff_ffffff, mode=:default); end
468
493
 
469
494
  ##
470
495
  # Draws the image as an arbitrary quad. This method can be used for advanced non-rectangular drawing techniques, e.g., faking perspective or isometric projection.
@@ -576,16 +601,16 @@ module Gosu
576
601
  # @param [Float]
577
602
  # @return [Float]
578
603
  attr_writer :volume
579
-
604
+
580
605
  ##
581
606
  # Sets the playback speed. A value of 2.0 will play the sample at 200% speed and one octave higher. A value of 0.5 will play the sample at 50% speed and one octave lower. The valid range of this property depends on the operating system, but values up to 8.0 should work.
582
- # @param [Float]
607
+ # @param [Float]
583
608
  # @return [Float]
584
609
  attr_writer :speed
585
-
610
+
586
611
  ##
587
612
  # Set the amount of panning, i.e. the position of the sound when using stereo speakers. 0.0 is the centre, negative values are to the left, positive values are to the right. If something happens on the edge of the screen, a good value for pan would be ±0.1.
588
- # @param [Float]
613
+ # @param [Float]
589
614
  # @return [Float]
590
615
  attr_writer :pan
591
616
 
@@ -781,7 +806,7 @@ module Gosu
781
806
  ##
782
807
  # Toggles between windowed mode and fullscreen.
783
808
  attr_writer :fullscreen
784
-
809
+
785
810
  ##
786
811
  # @return [true, false] whether this window is resizable.
787
812
  def resizable?; end
@@ -795,7 +820,7 @@ module Gosu
795
820
  #
796
821
  # Resizable fullscreen windows always use the full desktop resolution.
797
822
  # Windows that are larger than the desktop resolution will be shrunk.
798
- #
823
+ #
799
824
  # @overload initialize(width, height, options = {})
800
825
  # @overload initialize(width, height, fullscreen, update_interval = 16.666666)
801
826
  #
@@ -812,18 +837,18 @@ module Gosu
812
837
  #
813
838
  # @return [void]
814
839
  def show; end
815
-
840
+
816
841
  ##
817
842
  # EXPERIMENTAL - MAY DISAPPEAR WITHOUT WARNING.
818
- #
843
+ #
819
844
  # Performs a single step in the main loop.
820
845
  # This can be useful for integrating Gosu with other libraries that have their own main loop, e.g. Ruby/Tk.
821
- #
846
+ #
822
847
  # See: https://www.libgosu.org/cgi-bin/mwf/topic_show.pl?tid=1218
823
- #
848
+ #
824
849
  # If you find a good way to use {#tick}, please let us know on the forum and we can make this a part of Gosu's stable interface.
825
850
  # Thank you!
826
- #
851
+ #
827
852
  # @return [true, false] whether the {Window} should still be shown after this tick
828
853
  def tick; end
829
854
 
@@ -871,7 +896,7 @@ module Gosu
871
896
  #
872
897
  # @return [bool]
873
898
  def close; end
874
-
899
+
875
900
  ##
876
901
  # This method is called before {#update} if a button is pressed while the window has focus.
877
902
  #
@@ -903,6 +928,24 @@ module Gosu
903
928
  # @param filename [String] the filename of the dropped file. When multiple files are dropped, this method will be called several times.
904
929
  def drop(filename); end
905
930
 
931
+ ##
932
+ # Called when a gamepad is connected.
933
+ # If a gamepad is momentarily disconnected and then reconnected, before another gamepad, it will have the same index.
934
+ #
935
+ # @param index [integer] index for looking up gamepad.
936
+ #
937
+ # @see Gosu.gamepad_name
938
+ def gamepad_connected(index); end
939
+
940
+ ##
941
+ # Called when a gamepad is disconnected.
942
+ #
943
+ # @param index [integer] index for looking up gamepad.
944
+ #
945
+ # @see #gamepad_connected
946
+ # @see Gosu.gamepad_name
947
+ def gamepad_disconnected(index); end
948
+
906
949
  # @!endgroup
907
950
  end
908
951
 
@@ -945,6 +988,38 @@ module Gosu
945
988
  # @see Window#button_up
946
989
  def button_down?(id); end
947
990
 
991
+ ##
992
+ # Returns the name of a Gosu::KB_{*} constant. Returns nil if no name is found.
993
+ #
994
+ # @example
995
+ # Gosu.button_name(Gosu::KB_SPACE) #=> "Space"
996
+ #
997
+ # @return [String, nil]
998
+ # @param id [Integer]
999
+ #
1000
+ def button_name(id); end
1001
+
1002
+ ##
1003
+ # Returns the name for gamepad at `index` or nil if there is no connected at the specified index.
1004
+ #
1005
+ # @example
1006
+ # Gosu.gamepad_name(0) #=> "PS4 Controller"
1007
+ #
1008
+ # @return [String, nil]
1009
+ # @param index [Integer]
1010
+ def gamepad_name(index); end
1011
+
1012
+ ##
1013
+ # Returns the value for the specified gamepad axis in the range -1.0..1.0 for joysticks and 0.0..1.0 for triggers.
1014
+ #
1015
+ # @example
1016
+ # Gosu.axis(Gosu::GP_0_LEFT_STICK_Y_AXIS) #=> 0.75
1017
+ #
1018
+ # @return [Float]
1019
+ # @param id [Integer]
1020
+ #
1021
+ def axis(id); end
1022
+
948
1023
  # @!group Drawing primitives
949
1024
 
950
1025
  ##