gosu 0.7.11 → 0.7.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (141) hide show
  1. data/Gosu/Audio.hpp +33 -16
  2. data/Gosu/GraphicsBase.hpp +6 -1
  3. data/Gosu/Input.hpp +8 -2
  4. data/Gosu/Platform.hpp +63 -61
  5. data/Gosu/Window.hpp +11 -0
  6. data/GosuImpl/AudioFmod.cpp +89 -16
  7. data/GosuImpl/AudioSDL.cpp +59 -19
  8. data/GosuImpl/Graphics/BitmapUtils.cpp +3 -0
  9. data/GosuImpl/Graphics/Common.hpp +8 -3
  10. data/GosuImpl/Graphics/DrawOp.hpp +70 -7
  11. data/GosuImpl/Graphics/Graphics.cpp +34 -2
  12. data/GosuImpl/Graphics/TexChunk.cpp +7 -1
  13. data/GosuImpl/Graphics/Texture.cpp +31 -9
  14. data/GosuImpl/Iconv.hpp +3 -0
  15. data/GosuImpl/InputMac.mm +31 -10
  16. data/GosuImpl/InputWin.cpp +8 -0
  17. data/GosuImpl/InputX.cpp +64 -45
  18. data/GosuImpl/Math.cpp +1 -1
  19. data/GosuImpl/RubyGosu.swg +27 -7
  20. data/GosuImpl/RubyGosu_wrap.cxx +338 -205
  21. data/GosuImpl/Utility.cpp +1 -0
  22. data/GosuImpl/WindowMac.mm +29 -3
  23. data/GosuImpl/WindowWin.cpp +16 -5
  24. data/GosuImpl/WindowX.cpp +3 -3
  25. data/README.txt +7 -3
  26. data/Rakefile +2 -1
  27. data/mac/Gosu.icns +0 -0
  28. data/mac/Gosu.xcodeproj/jlnr.mode1v3 +74 -75
  29. data/mac/Gosu.xcodeproj/jlnr.pbxuser +731 -257
  30. data/mac/Gosu.xcodeproj/jlnr.perspectivev3 +1531 -0
  31. data/reference/Async_8hpp-source.html +1 -1
  32. data/reference/Audio_8hpp-source.html +68 -58
  33. data/reference/Audio_8hpp.html +1 -1
  34. data/reference/AutoLink_8hpp-source.html +1 -1
  35. data/reference/AutoLink_8hpp.html +1 -1
  36. data/reference/Bitmap_8hpp-source.html +1 -1
  37. data/reference/Bitmap_8hpp.html +1 -1
  38. data/reference/ButtonsMac_8hpp-source.html +1 -1
  39. data/reference/ButtonsWin_8hpp-source.html +1 -1
  40. data/reference/ButtonsX_8hpp-source.html +1 -1
  41. data/reference/Color_8hpp-source.html +1 -1
  42. data/reference/Color_8hpp.html +1 -1
  43. data/reference/Directories_8hpp-source.html +1 -1
  44. data/reference/Directories_8hpp.html +1 -1
  45. data/reference/Font_8hpp-source.html +1 -1
  46. data/reference/Font_8hpp.html +1 -1
  47. data/reference/Fwd_8hpp-source.html +1 -1
  48. data/reference/Fwd_8hpp.html +1 -1
  49. data/reference/Gosu_8hpp-source.html +1 -1
  50. data/reference/Gosu_8hpp.html +1 -1
  51. data/reference/GraphicsBase_8hpp-source.html +28 -26
  52. data/reference/GraphicsBase_8hpp.html +4 -1
  53. data/reference/Graphics_8hpp-source.html +1 -1
  54. data/reference/Graphics_8hpp.html +1 -1
  55. data/reference/IO_8hpp-source.html +1 -1
  56. data/reference/IO_8hpp.html +1 -1
  57. data/reference/ImageData_8hpp-source.html +1 -1
  58. data/reference/ImageData_8hpp.html +1 -1
  59. data/reference/Image_8hpp-source.html +1 -1
  60. data/reference/Image_8hpp.html +1 -1
  61. data/reference/Input_8hpp-source.html +19 -16
  62. data/reference/Input_8hpp.html +1 -1
  63. data/reference/Math_8hpp-source.html +1 -1
  64. data/reference/Math_8hpp.html +1 -1
  65. data/reference/Platform_8hpp-source.html +22 -20
  66. data/reference/Platform_8hpp.html +1 -1
  67. data/reference/RotFlip_8hpp-source.html +1 -1
  68. data/reference/RotFlip_8hpp.html +1 -1
  69. data/reference/Sockets_8hpp-source.html +1 -1
  70. data/reference/Sockets_8hpp.html +1 -1
  71. data/reference/TextInput_8hpp-source.html +1 -1
  72. data/reference/TextInput_8hpp.html +1 -1
  73. data/reference/Text_8hpp-source.html +1 -1
  74. data/reference/Text_8hpp.html +1 -1
  75. data/reference/Timing_8hpp-source.html +1 -1
  76. data/reference/Timing_8hpp.html +1 -1
  77. data/reference/Utility_8hpp-source.html +1 -1
  78. data/reference/Utility_8hpp.html +1 -1
  79. data/reference/WinUtility_8hpp-source.html +1 -1
  80. data/reference/WinUtility_8hpp.html +1 -1
  81. data/reference/Window_8hpp-source.html +67 -56
  82. data/reference/Window_8hpp.html +1 -1
  83. data/reference/annotated.html +1 -1
  84. data/reference/classGosu_1_1Audio-members.html +1 -1
  85. data/reference/classGosu_1_1Audio.html +1 -1
  86. data/reference/classGosu_1_1Bitmap-members.html +1 -1
  87. data/reference/classGosu_1_1Bitmap.html +1 -1
  88. data/reference/classGosu_1_1Buffer-members.html +1 -1
  89. data/reference/classGosu_1_1Buffer.html +1 -1
  90. data/reference/classGosu_1_1Button-members.html +1 -1
  91. data/reference/classGosu_1_1Button.html +1 -1
  92. data/reference/classGosu_1_1Color-members.html +1 -1
  93. data/reference/classGosu_1_1Color.html +1 -1
  94. data/reference/classGosu_1_1File-members.html +1 -1
  95. data/reference/classGosu_1_1File.html +1 -1
  96. data/reference/classGosu_1_1Font-members.html +1 -1
  97. data/reference/classGosu_1_1Font.html +1 -1
  98. data/reference/classGosu_1_1Graphics-members.html +1 -1
  99. data/reference/classGosu_1_1Graphics.html +1 -1
  100. data/reference/classGosu_1_1Image-members.html +1 -1
  101. data/reference/classGosu_1_1Image.html +1 -1
  102. data/reference/classGosu_1_1ImageData-members.html +1 -1
  103. data/reference/classGosu_1_1ImageData.html +1 -1
  104. data/reference/classGosu_1_1Input-members.html +2 -1
  105. data/reference/classGosu_1_1Input.html +34 -1
  106. data/reference/classGosu_1_1MessageSocket-members.html +1 -1
  107. data/reference/classGosu_1_1MessageSocket.html +1 -1
  108. data/reference/classGosu_1_1Resource-members.html +1 -1
  109. data/reference/classGosu_1_1Resource.html +1 -1
  110. data/reference/classGosu_1_1Sample-members.html +3 -3
  111. data/reference/classGosu_1_1Sample.html +23 -11
  112. data/reference/classGosu_1_1SampleInstance-members.html +4 -1
  113. data/reference/classGosu_1_1SampleInstance.html +11 -2
  114. data/reference/classGosu_1_1Song-members.html +5 -2
  115. data/reference/classGosu_1_1Song.html +78 -7
  116. data/reference/classGosu_1_1TextInput-members.html +1 -1
  117. data/reference/classGosu_1_1TextInput.html +1 -1
  118. data/reference/classGosu_1_1Window-members.html +1 -1
  119. data/reference/classGosu_1_1Window.html +1 -1
  120. data/reference/files.html +1 -1
  121. data/reference/functions.html +14 -6
  122. data/reference/functions_enum.html +1 -1
  123. data/reference/functions_func.html +14 -6
  124. data/reference/functions_vars.html +1 -1
  125. data/reference/hierarchy.html +1 -1
  126. data/reference/index.html +1 -1
  127. data/reference/namespaceGosu.html +20 -1
  128. data/reference/namespaceGosu_1_1Colors.html +1 -1
  129. data/reference/namespaceGosu_1_1Win.html +1 -1
  130. data/reference/namespacemembers.html +3 -1
  131. data/reference/namespacemembers_enum.html +1 -1
  132. data/reference/namespacemembers_eval.html +1 -1
  133. data/reference/namespacemembers_func.html +1 -1
  134. data/reference/namespacemembers_type.html +1 -1
  135. data/reference/namespacemembers_vars.html +3 -1
  136. data/reference/namespaces.html +1 -1
  137. data/windows/Gosu.sln +2 -2
  138. data/windows/Gosu.vcproj +8 -7
  139. data/windows/RubyGosu.vcproj +5 -5
  140. metadata +4 -3
  141. data/GosuImpl/Utility.cpp~RF6c566.TMP +0 -95
@@ -40,12 +40,16 @@ namespace Gosu
40
40
  class SampleInstance
41
41
  {
42
42
  int handle, extra;
43
-
43
+ bool alive() const;
44
+
44
45
  public:
45
46
  //! Called by Sample, do not use.
46
47
  SampleInstance(int handle, int extra);
47
48
 
48
49
  bool playing() const;
50
+ bool paused() const;
51
+ void pause();
52
+ void resume();
49
53
  void stop();
50
54
 
51
55
  //! \param volume Can be anything from 0.0 (silence) to 1.0 (full
@@ -54,14 +58,14 @@ namespace Gosu
54
58
  //! \param pan Can be anything from -1.0 (left) to 1.0 (right).
55
59
  void changePan(double pan);
56
60
  //! \param speed Playback speed is only limited by FMOD's
57
- //! capatibilities and can accept very high or low values. Use 1.0 for
61
+ //! capabilities and can accept very high or low values. Use 1.0 for
58
62
  //! normal playback speed.
59
63
  void changeSpeed(double speed);
60
64
  };
61
65
 
62
66
  //! A sample is a short sound that is completely loaded in memory, can be
63
67
  //! played multiple times at once and offers very flexible playback
64
- //! parameters. In short, use samples for everything that's not music.
68
+ //! parameters. Use samples for everything that's not music.
65
69
  class Sample
66
70
  {
67
71
  struct SampleData;
@@ -82,20 +86,22 @@ namespace Gosu
82
86
  //! \param volume Can be anything from 0.0 (silence) to 1.0 (full
83
87
  //! volume).
84
88
  //! \param speed Playback speed is only limited by FMOD's
85
- //! capatibilities and can accept very high or low values. Use 1.0 for
89
+ //! capabilities and can accept very high or low values. Use 1.0 for
86
90
  //! normal playback speed.
87
- SampleInstance play(double volume = 1, double speed = 1) const;
91
+ SampleInstance play(double volume = 1, double speed = 1,
92
+ bool looping = false) const;
88
93
 
89
94
  //! Plays the sample with panning. Even if pan is 0.0, the sample will
90
95
  //! not be as loud as if it were played by calling play() due to the
91
- //! way FMOD's panning works.
96
+ //! way the panning works.
92
97
  //! \param pan Can be anything from -1.0 (left) to 1.0 (right).
93
98
  //! \param volume Can be anything from 0.0 (silence) to 1.0 (full
94
99
  //! volume).
95
- //! \param speed Playback speed is only limited by FMOD's
96
- //! capatibilities and can accept very high or low values. Use 1.0 for
97
- //! normal playback speed.
98
- SampleInstance playPan(double pan, double volume = 1, double speed = 1) const;
100
+ //! \param speed Playback speed is only limited by FMOD's (or
101
+ //! SDL_mixer's, respectively) capabilities and can accept very high
102
+ //! or low values. Use 1.0 for normal playback speed.
103
+ SampleInstance playPan(double pan, double volume = 1, double speed = 1,
104
+ bool looping = false) const;
99
105
  };
100
106
 
101
107
  //! Songs are less flexible than samples in that they can only be played
@@ -126,12 +132,23 @@ namespace Gosu
126
132
  Song(Audio&, Type type, Reader reader);
127
133
 
128
134
  ~Song();
129
-
130
- //! Starts playback of the song. This will stop all other songs and
131
- //! cause the currently played song to restart if called on the
132
- //! current song.
133
- void play();
134
- //! Stops playback of this song if it is currently played.
135
+
136
+ //! Returns the song currently being played or paused, or 0 if
137
+ //! no song has been played yet or the last song has finished
138
+ //! playing.
139
+ static Song* currentSong();
140
+
141
+ //! Starts or resumes playback of the song. This will stop all other
142
+ //! songs and set the current song to this object.
143
+ void play(bool looping = false);
144
+ //! Pauses playback of the song. It is not considered being played.
145
+ //! currentSong will stay the same.
146
+ void pause();
147
+ //! Returns true if the song is the current song, but in paused
148
+ //! mode.
149
+ bool paused() const;
150
+ //! Stops playback of this song if it is currently played or paused.
151
+ //! Afterwards, currentSong will return 0.
135
152
  void stop();
136
153
  //! Returns if the song is currently playing.
137
154
  bool playing() const;
@@ -4,7 +4,7 @@
4
4
  #ifndef GOSU_GRAPHICSBASE_HPP
5
5
  #define GOSU_GRAPHICSBASE_HPP
6
6
 
7
- #include <boost/cstdint.hpp>
7
+ #include <limits>
8
8
 
9
9
  namespace Gosu
10
10
  {
@@ -12,6 +12,11 @@ namespace Gosu
12
12
  //! system. Draw calls with higher ZPos values will cover those with a
13
13
  //! lower ZPos value, that is, they are performed last.
14
14
  typedef double ZPos;
15
+
16
+ //! The lowest possible Z position. By using this, you tell Gosu that
17
+ //! your drawing operation does not need Z ordering and can be performed
18
+ //! immediately.
19
+ const double zImmediate = -std::numeric_limits<double>::infinity();
15
20
 
16
21
  //! Determines the way colors are combined when one is drawn onto
17
22
  //! another.
@@ -76,8 +76,8 @@ namespace Gosu
76
76
  #endif
77
77
 
78
78
  #ifdef GOSU_IS_X
79
- Input(::Display* dpy);
80
- bool feedXEvent(::XEvent& event, Window* window);
79
+ Input(::Display* display, ::Window window);
80
+ bool feedXEvent(::XEvent& event);
81
81
  #endif
82
82
 
83
83
  ~Input();
@@ -96,6 +96,12 @@ namespace Gosu
96
96
  double mouseX() const;
97
97
  //! See mouseX.
98
98
  double mouseY() const;
99
+
100
+ //! Immediately moves the mouse as far towards the desired position
101
+ //! as possible. x and y are relativ to the window just as in the mouse
102
+ //! position accessors.
103
+ void setMousePosition(double x, double y);
104
+
99
105
  // Undocumented for the moment.
100
106
  void setMouseFactors(double factorX, double factorY);
101
107
 
@@ -1,61 +1,63 @@
1
- //! \file Platform.hpp
2
- //! Macros and utility functions to facilitate programming on all of Gosu's supported platforms.
3
-
4
- #ifndef GOSU_PLATFORM_HPP
5
- #define GOSU_PLATFORM_HPP
6
-
7
- #ifdef __BIG_ENDIAN__
8
- #define IDENTITY_FUN bigToNative
9
- #define IDENTITY_FUN2 nativeToBig
10
- #define CONV_FUN littleToNative
11
- #define CONV_FUN2 nativeToLittle
12
- #else
13
- #define IDENTITY_FUN littleToNative
14
- #define IDENTITY_FUN2 nativeToLittle
15
- #define CONV_FUN bigToNative
16
- #define CONV_FUN2 nativeToBig
17
- #endif
18
-
19
- #include <algorithm>
20
-
21
- namespace Gosu
22
- {
23
- template<typename T> T IDENTITY_FUN(T t) { return t; }
24
- template<typename T> T IDENTITY_FUN2(T t) { return t; }
25
-
26
- template<typename T>
27
- T CONV_FUN(T t)
28
- {
29
- char* begin = reinterpret_cast<char*>(&t);
30
- std::reverse(begin, begin + sizeof t);
31
- return t;
32
- }
33
-
34
- template<typename T> T CONV_FUN2(T t) { return CONV_FUN(t); }
35
- }
36
-
37
- #undef IDENTITY_FUN
38
- #undef IDENTITY_FUN2
39
- #undef CONV_FUN
40
- #undef CONV_FUN2
41
-
42
- #ifdef _MSC_VER
43
- #define GOSU_NORETURN __declspec(noreturn)
44
- #endif
45
-
46
- #ifdef __GNUC__
47
- #define GOSU_NORETURN __attribute__ ((noreturn))
48
- #endif
49
-
50
- #ifdef WIN32
51
- # define GOSU_IS_WIN
52
- #else
53
- # define GOSU_IS_UNIX
54
- # if defined(__linux) || defined(__FreeBSD__)
55
- # define GOSU_IS_X
56
- # else
57
- # define GOSU_IS_MAC
58
- # endif
59
- #endif
60
-
61
- #endif
1
+ //! \file Platform.hpp
2
+ //! Macros and utility functions to facilitate programming on all of Gosu's supported platforms.
3
+
4
+ #ifndef GOSU_PLATFORM_HPP
5
+ #define GOSU_PLATFORM_HPP
6
+
7
+ #ifdef __BIG_ENDIAN__
8
+ #define IDENTITY_FUN bigToNative
9
+ #define IDENTITY_FUN2 nativeToBig
10
+ #define CONV_FUN littleToNative
11
+ #define CONV_FUN2 nativeToLittle
12
+ #else
13
+ #define IDENTITY_FUN littleToNative
14
+ #define IDENTITY_FUN2 nativeToLittle
15
+ #define CONV_FUN bigToNative
16
+ #define CONV_FUN2 nativeToBig
17
+ #endif
18
+
19
+ #include <algorithm>
20
+
21
+ namespace Gosu
22
+ {
23
+ template<typename T> T IDENTITY_FUN(T t) { return t; }
24
+ template<typename T> T IDENTITY_FUN2(T t) { return t; }
25
+
26
+ template<typename T>
27
+ T CONV_FUN(T t)
28
+ {
29
+ char* begin = reinterpret_cast<char*>(&t);
30
+ std::reverse(begin, begin + sizeof t);
31
+ return t;
32
+ }
33
+
34
+ template<typename T> T CONV_FUN2(T t) { return CONV_FUN(t); }
35
+ }
36
+
37
+ #undef IDENTITY_FUN
38
+ #undef IDENTITY_FUN2
39
+ #undef CONV_FUN
40
+ #undef CONV_FUN2
41
+
42
+ #if defined(_MSC_VER)
43
+ #define GOSU_NORETURN __declspec(noreturn)
44
+ #elif defined(__GNUC__)
45
+ #define GOSU_NORETURN __attribute__ ((noreturn))
46
+ #endif
47
+
48
+ #if defined(WIN32)
49
+ # define GOSU_IS_WIN
50
+ #else
51
+ # define GOSU_IS_UNIX
52
+ # if defined(__linux) || defined(__FreeBSD__)
53
+ # define GOSU_IS_X
54
+ # else
55
+ # define GOSU_IS_MAC
56
+ # include <TargetConditionals.h>
57
+ # if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
58
+ # define GOSU_IS_IPHONE
59
+ # endif
60
+ # endif
61
+ #endif
62
+
63
+ #endif
@@ -11,6 +11,7 @@
11
11
  #include <boost/shared_ptr.hpp>
12
12
  #include <boost/function.hpp>
13
13
  #include <string>
14
+ #include <vector>
14
15
 
15
16
  #ifdef GOSU_IS_WIN
16
17
  #include <windows.h>
@@ -18,6 +19,11 @@
18
19
 
19
20
  namespace Gosu
20
21
  {
22
+ #ifdef GOSU_IS_IPHONE
23
+ struct Touch { double x, y; };
24
+ typedef std::vector<Touch> Touches;
25
+ #endif
26
+
21
27
  //! Convenient all-in-one class that serves as the foundation of a standard
22
28
  //! Gosu application. Manages initialization of all of Gosu's core components
23
29
  //! and provides timing functionality.
@@ -76,6 +82,11 @@ namespace Gosu
76
82
  typedef boost::shared_ptr<boost::function<void()> > SharedContext;
77
83
  SharedContext createSharedContext();
78
84
  #endif
85
+ #ifdef GOSU_IS_IPHONE
86
+ virtual void touchesBegan(const Touches& touches) {}
87
+ virtual void touchesMoved(const Touches& touches) {}
88
+ virtual void touchesEnded(const Touches& touches) {}
89
+ #endif
79
90
 
80
91
  #endif
81
92
  };
@@ -96,6 +96,21 @@ bool Gosu::SampleInstance::playing() const
96
96
  return FSOUND_IsPlaying(handle);
97
97
  }
98
98
 
99
+ bool Gosu::SampleInstance::paused() const
100
+ {
101
+ return FSOUND_GetPaused(handle);
102
+ }
103
+
104
+ void Gosu::SampleInstance::pause()
105
+ {
106
+ FSOUND_SetPaused(handle, 1);
107
+ }
108
+
109
+ void Gosu::SampleInstance::resume()
110
+ {
111
+ FSOUND_SetPaused(handle, 0);
112
+ }
113
+
99
114
  void Gosu::SampleInstance::stop()
100
115
  {
101
116
  FSOUND_StopSound(handle);
@@ -164,12 +179,15 @@ Gosu::Sample::~Sample()
164
179
  {
165
180
  }
166
181
 
167
- Gosu::SampleInstance Gosu::Sample::play(double volume, double speed) const
182
+ Gosu::SampleInstance Gosu::Sample::play(double volume, double speed,
183
+ bool looping) const
168
184
  {
169
185
  int handle = FSOUND_PlaySound(FSOUND_FREE, data->rep);
170
186
  int freq;
171
187
  if (handle > 0)
172
188
  {
189
+ if (looping)
190
+ FSOUND_SetLoopMode(handle, FSOUND_LOOP_NORMAL);
173
191
  freq = FSOUND_GetFrequency(handle);
174
192
  FSOUND_SetPan(handle, FSOUND_STEREOPAN);
175
193
  }
@@ -180,12 +198,15 @@ Gosu::SampleInstance Gosu::Sample::play(double volume, double speed) const
180
198
  return result;
181
199
  }
182
200
 
183
- Gosu::SampleInstance Gosu::Sample::playPan(double pan, double volume, double speed) const
201
+ Gosu::SampleInstance Gosu::Sample::playPan(double pan, double volume,
202
+ double speed, bool looping) const
184
203
  {
185
204
  int handle = FSOUND_PlaySound(FSOUND_FREE, data->rep);
186
205
  int freq;
187
206
  if (handle > 0)
188
207
  {
208
+ if (looping)
209
+ FSOUND_SetLoopMode(handle, FSOUND_LOOP_NORMAL);
189
210
  freq = FSOUND_GetFrequency(handle);
190
211
  }
191
212
 
@@ -207,7 +228,9 @@ protected:
207
228
  public:
208
229
  virtual ~BaseData() {}
209
230
 
210
- virtual void play() = 0;
231
+ virtual void play(bool looping) = 0;
232
+ virtual void pause() = 0;
233
+ virtual bool paused() const = 0;
211
234
  virtual void stop() = 0;
212
235
 
213
236
  double volume() const
@@ -254,8 +277,8 @@ public:
254
277
  }
255
278
  #endif
256
279
 
257
- stream = FSOUND_Stream_Open(&buffer[0], FSOUND_LOADMEMORY, 0,
258
- buffer.size());
280
+ stream = FSOUND_Stream_Open(&buffer[0], FSOUND_LOADMEMORY | FSOUND_LOOP_NORMAL,
281
+ 0, buffer.size());
259
282
  if (stream == 0)
260
283
  throwLastFMODError();
261
284
 
@@ -274,15 +297,33 @@ public:
274
297
  FSOUND_Stream_Close(stream);
275
298
  }
276
299
 
277
- void play()
300
+ void play(bool looping)
278
301
  {
279
- handle = FSOUND_Stream_Play(FSOUND_FREE, stream);
302
+ if (handle == -1)
303
+ {
304
+ handle = FSOUND_Stream_Play(FSOUND_FREE, stream);
305
+ FSOUND_Stream_SetLoopCount(stream, looping ? -1 : 0);
306
+ }
307
+ else if (paused())
308
+ FSOUND_SetPaused(handle, 0);
280
309
  applyVolume();
281
310
  }
282
311
 
312
+ void pause()
313
+ {
314
+ if (handle != -1)
315
+ FSOUND_SetPaused(handle, 1);
316
+ }
317
+
318
+ bool paused() const
319
+ {
320
+ return handle != -1 && FSOUND_GetPaused(handle);
321
+ }
322
+
283
323
  void stop()
284
324
  {
285
325
  fmodCheck(FSOUND_Stream_Stop(stream));
326
+ handle = -1; // The end callback is NOT being called!
286
327
  }
287
328
 
288
329
  void applyVolume()
@@ -321,15 +362,30 @@ public:
321
362
  FMUSIC_FreeSong(module_);
322
363
  }
323
364
 
324
- void play()
365
+ void play(bool looping)
325
366
  {
326
- FMUSIC_PlaySong(module_);
367
+ if (paused())
368
+ FMUSIC_SetPaused(module_, 0);
369
+ else
370
+ FMUSIC_PlaySong(module_);
371
+ FMUSIC_SetLooping(module_, looping);
327
372
  applyVolume();
328
373
  }
374
+
375
+ void pause()
376
+ {
377
+ FMUSIC_SetPaused(module_, 1);
378
+ }
379
+
380
+ bool paused() const
381
+ {
382
+ return FMUSIC_GetPaused(module_);
383
+ }
329
384
 
330
385
  void stop()
331
386
  {
332
387
  fmodCheck(FMUSIC_StopSong(module_));
388
+ FMUSIC_SetPaused(module_, false);
333
389
  }
334
390
 
335
391
  void applyVolume()
@@ -381,20 +437,37 @@ Gosu::Song::~Song()
381
437
  stop();
382
438
  }
383
439
 
384
- void Gosu::Song::play()
440
+ Gosu::Song* Gosu::Song::currentSong()
385
441
  {
386
- if (curSong)
442
+ return curSong;
443
+ }
444
+
445
+ void Gosu::Song::play(bool looping)
446
+ {
447
+ if (curSong && curSong != this)
448
+ {
387
449
  curSong->stop();
450
+ assert(curSong == 0);
451
+ }
452
+
453
+ data->play(looping);
454
+ curSong = this; // may be redundant
455
+ }
388
456
 
389
- assert(curSong == 0);
457
+ void Gosu::Song::pause()
458
+ {
459
+ if (curSong == this)
460
+ data->pause(); // may be redundant
461
+ }
390
462
 
391
- data->play();
392
- curSong = this;
463
+ bool Gosu::Song::paused() const
464
+ {
465
+ return curSong == this && data->paused();
393
466
  }
394
467
 
395
468
  void Gosu::Song::stop()
396
469
  {
397
- if (playing())
470
+ if (curSong == this)
398
471
  {
399
472
  data->stop();
400
473
  curSong = 0;
@@ -403,7 +476,7 @@ void Gosu::Song::stop()
403
476
 
404
477
  bool Gosu::Song::playing() const
405
478
  {
406
- return curSong == this;
479
+ return curSong == this && !data->paused();
407
480
  }
408
481
 
409
482
  double Gosu::Song::volume() const