gosu 0.7.39-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. data/COPYING +34 -0
  2. data/Gosu/Async.hpp +50 -0
  3. data/Gosu/Audio.hpp +163 -0
  4. data/Gosu/AutoLink.hpp +16 -0
  5. data/Gosu/Bitmap.hpp +96 -0
  6. data/Gosu/ButtonsMac.hpp +140 -0
  7. data/Gosu/ButtonsWin.hpp +140 -0
  8. data/Gosu/ButtonsX.hpp +141 -0
  9. data/Gosu/Color.hpp +204 -0
  10. data/Gosu/Directories.hpp +36 -0
  11. data/Gosu/Font.hpp +83 -0
  12. data/Gosu/Fwd.hpp +31 -0
  13. data/Gosu/Gosu.hpp +34 -0
  14. data/Gosu/Graphics.hpp +120 -0
  15. data/Gosu/GraphicsBase.hpp +66 -0
  16. data/Gosu/IO.hpp +259 -0
  17. data/Gosu/Image.hpp +138 -0
  18. data/Gosu/ImageData.hpp +58 -0
  19. data/Gosu/Input.hpp +161 -0
  20. data/Gosu/Inspection.hpp +14 -0
  21. data/Gosu/Math.hpp +135 -0
  22. data/Gosu/Platform.hpp +73 -0
  23. data/Gosu/Sockets.hpp +137 -0
  24. data/Gosu/TR1.hpp +44 -0
  25. data/Gosu/Text.hpp +71 -0
  26. data/Gosu/TextInput.hpp +70 -0
  27. data/Gosu/Timing.hpp +16 -0
  28. data/Gosu/Utility.hpp +28 -0
  29. data/Gosu/Version.hpp +526 -0
  30. data/Gosu/WinUtility.hpp +75 -0
  31. data/Gosu/Window.hpp +124 -0
  32. data/README.txt +25 -0
  33. data/examples/ChipmunkIntegration.rb +275 -0
  34. data/examples/CptnRuby.rb +223 -0
  35. data/examples/MoreChipmunkAndRMagick.rb +155 -0
  36. data/examples/OpenGLIntegration.rb +226 -0
  37. data/examples/RMagickIntegration.rb +417 -0
  38. data/examples/TextInput.rb +154 -0
  39. data/examples/Tutorial.rb +131 -0
  40. data/examples/media/Beep.wav +0 -0
  41. data/examples/media/CptnRuby Gem.png +0 -0
  42. data/examples/media/CptnRuby Map.txt +25 -0
  43. data/examples/media/CptnRuby Tileset.png +0 -0
  44. data/examples/media/CptnRuby.png +0 -0
  45. data/examples/media/Cursor.png +0 -0
  46. data/examples/media/Earth.png +0 -0
  47. data/examples/media/Explosion.wav +0 -0
  48. data/examples/media/Landscape.svg +10 -0
  49. data/examples/media/LargeStar.png +0 -0
  50. data/examples/media/Smoke.png +0 -0
  51. data/examples/media/Soldier.png +0 -0
  52. data/examples/media/Space.png +0 -0
  53. data/examples/media/Star.png +0 -0
  54. data/examples/media/Starfighter.bmp +0 -0
  55. data/lib/FreeImage.dll +0 -0
  56. data/lib/OpenAL32.dll +0 -0
  57. data/lib/gosu.for_1_8.so +0 -0
  58. data/lib/gosu.for_1_9.so +0 -0
  59. data/lib/gosu.rb +17 -0
  60. data/lib/gosu/patches.rb +75 -0
  61. data/lib/gosu/preview.rb +121 -0
  62. data/lib/gosu/run.rb +11 -0
  63. data/lib/gosu/swig_patches.rb +48 -0
  64. data/lib/gosu/zen.rb +28 -0
  65. data/lib/libsndfile.dll +0 -0
  66. metadata +138 -0
data/COPYING ADDED
@@ -0,0 +1,34 @@
1
+ Copyright (C) 2004-2011 Julian Raschke, Jan Lücker and all contributors.
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a
4
+ copy of this software and associated documentation files (the "Software"),
5
+ to deal in the Software without restriction, including without limitation
6
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
7
+ and/or sell copies of the Software, and to permit persons to whom the
8
+ Software is furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
19
+ DEALINGS IN THE SOFTWARE.
20
+
21
+ Julian Raschke julian@raschke.de
22
+ Jan Lücker jan.luecker@gmx.de
23
+ http://www.libgosu.org/
24
+
25
+ ***
26
+
27
+ This does NOT apply to audiere.dll shipped with the Windows versions of
28
+ Gosu. Audiere is a separate library licensed under the Lesser General
29
+ Public License. Please consult http://audiere.sf.net/ for more details.
30
+
31
+ This does also NOT apply to libogg and libvorbis, which are included in
32
+ all source and binary distributions of Gosu, sometimes via audiere. These
33
+ projects are licensed under a BSD-like license, and their copyright terms
34
+ need to be supplied even with binary redistributions (e.g. Gosu games).
data/Gosu/Async.hpp ADDED
@@ -0,0 +1,50 @@
1
+ // Undocumented for the first few iterations. Interface may change rapidly.
2
+ // This is mainly a proof of concept. Stability will be the highest on OS X.
3
+
4
+ #if 0
5
+ #ifndef GOSU_ASYNC_HPP
6
+ #define GOSU_ASYNC_HPP
7
+
8
+ #include <Gosu/Fwd.hpp>
9
+ #include <Gosu/TR1.hpp>
10
+ #include <thread>
11
+ #include <memory>
12
+ #include <string>
13
+
14
+ namespace Gosu
15
+ {
16
+ template<typename Result>
17
+ class AsyncResult
18
+ {
19
+ std::tr1::shared_ptr<std::tr1::try_mutex> mutex;
20
+ std::tr1::shared_ptr<std::auto_ptr<Result> > result;
21
+
22
+ public:
23
+ AsyncResult(const std::tr1::shared_ptr<std::tr1::try_mutex>& mutex,
24
+ const std::tr1::shared_ptr<std::auto_ptr<Result> >& result)
25
+ : mutex(mutex), result(result)
26
+ {
27
+ }
28
+
29
+ bool hasValue() const
30
+ {
31
+ std::tr1::try_mutex::scoped_try_lock lock(*mutex);
32
+ return lock && result->get();
33
+ }
34
+
35
+ std::auto_ptr<Result> takeValue()
36
+ {
37
+ std::tr1::try_mutex::scoped_lock lock(*mutex);
38
+ return *result;
39
+ }
40
+ };
41
+
42
+ // TODO: Will only work if the window doesn't die inbetween.
43
+ // TODO: More functions to come; or a general interface?
44
+
45
+ AsyncResult<Image>
46
+ asyncNewImage(Window& window, const std::wstring& filename);
47
+ }
48
+
49
+ #endif
50
+ #endif
data/Gosu/Audio.hpp ADDED
@@ -0,0 +1,163 @@
1
+ //! \file Audio.hpp
2
+ //! Contains all the classes of Gosu's audio system.
3
+
4
+ #ifndef GOSU_AUDIO_HPP
5
+ #define GOSU_AUDIO_HPP
6
+
7
+ #ifdef WIN32
8
+ #ifndef NOMINMAX
9
+ #define NOMINMAX
10
+ #endif
11
+ #include <windows.h>
12
+ #endif
13
+ #include <Gosu/Fwd.hpp>
14
+ #include <Gosu/IO.hpp>
15
+ #include <Gosu/Platform.hpp>
16
+ #include <Gosu/TR1.hpp>
17
+ #include <memory>
18
+ #include <string>
19
+
20
+ namespace Gosu
21
+ {
22
+ // Deprecated.
23
+ #ifndef SWIG
24
+ GOSU_DEPRECATED class Audio;
25
+ #endif
26
+
27
+ //! An instance of a Sample playing. Can be used to stop sounds dynamically,
28
+ //! or to check if they are finished.
29
+ //! It is recommended that you throw away sample instances if possible,
30
+ //! as they could accidentally refer to other sounds being played after
31
+ //! a very long time has passed.
32
+ class SampleInstance
33
+ {
34
+ int handle, extra;
35
+ bool alive() const;
36
+
37
+ public:
38
+ //! Called by Sample, do not use.
39
+ SampleInstance(int handle, int extra);
40
+
41
+ bool playing() const;
42
+ bool paused() const;
43
+ //! Pauses this instance to be resumed afterwards. It will still keep a channel filled while paused.
44
+ void pause();
45
+ void resume();
46
+ //! Stops this instance of a sound being played.
47
+ //! Calling this twice, or too late, does not do any harm.
48
+ void stop();
49
+
50
+ //! \param volume Can be anything from 0.0 (silence) to 1.0 (full
51
+ //! volume).
52
+ void changeVolume(double volume);
53
+ //! \param pan Can be anything from -1.0 (left) to 1.0 (right).
54
+ void changePan(double pan);
55
+ //! \param speed Playback speed is only limited by FMOD's
56
+ //! capabilities and can accept very high or low values. Use 1.0 for
57
+ //! normal playback speed.
58
+ void changeSpeed(double speed);
59
+ };
60
+
61
+ //! A sample is a short sound that is completely loaded in memory, can be
62
+ //! played multiple times at once and offers very flexible playback
63
+ //! parameters. Use samples for everything that's not music.
64
+ class Sample
65
+ {
66
+ struct SampleData;
67
+ std::tr1::shared_ptr<SampleData> data;
68
+
69
+ public:
70
+ //! Constructs a sample that can be played on the specified audio
71
+ //! system and loads the sample from a file.
72
+ explicit Sample(const std::wstring& filename);
73
+
74
+ //! Constructs a sample that can be played on the specified audio
75
+ //! system and loads the sample data from a stream.
76
+ explicit Sample(Reader reader);
77
+
78
+ //! Plays the sample without panning.
79
+ //! \param volume Can be anything from 0.0 (silence) to 1.0 (full
80
+ //! volume).
81
+ //! \param speed Playback speed is only limited by the underlying audio library,
82
+ //! and can accept very high or low values. Use 1.0 for
83
+ //! normal playback speed.
84
+ SampleInstance play(double volume = 1, double speed = 1,
85
+ bool looping = false) const;
86
+
87
+ //! Plays the sample with panning. Even if pan is 0.0, the sample will
88
+ //! not be as loud as if it were played by calling play() due to the
89
+ //! way the panning works.
90
+ //! \param pan Can be anything from -1.0 (left) to 1.0 (right).
91
+ //! \param volume Can be anything from 0.0 (silence) to 1.0 (full
92
+ //! volume).
93
+ //! \param speed Playback speed is only limited by by the underlying audio library,
94
+ //! and can accept very high
95
+ //! or low values. Use 1.0 for normal playback speed.
96
+ SampleInstance playPan(double pan, double volume = 1, double speed = 1,
97
+ bool looping = false) const;
98
+
99
+ #ifndef SWIG
100
+ GOSU_DEPRECATED Sample(Audio& audio, const std::wstring& filename);
101
+ GOSU_DEPRECATED Sample(Audio& audio, Reader reader);
102
+ #endif
103
+ };
104
+
105
+ //! Songs are less flexible than samples in that they can only be played
106
+ //! one at a time and without panning or speed parameters.
107
+ class Song
108
+ {
109
+ class BaseData;
110
+ class ModuleData;
111
+ class StreamData;
112
+ Song(const Song&);
113
+ Song& operator=(const Song&);
114
+ std::auto_ptr<BaseData> data;
115
+
116
+ public:
117
+ //! Constructs a song that can be played on the provided audio system
118
+ //! and loads the song from a file. The type is determined from the
119
+ //! filename.
120
+ explicit Song(const std::wstring& filename);
121
+
122
+ //! Constructs a song of the specified type that can be played on the
123
+ //! provided audio system and loads the song data from a stream.
124
+ explicit Song(Reader reader);
125
+
126
+ ~Song();
127
+
128
+ //! Returns the song currently being played or paused, or 0 if
129
+ //! no song has been played yet or the last song has finished
130
+ //! playing.
131
+ static Song* currentSong();
132
+
133
+ //! Starts or resumes playback of the song. This will stop all other
134
+ //! songs and set the current song to this object.
135
+ void play(bool looping = false);
136
+ //! Pauses playback of the song. It is not considered being played.
137
+ //! currentSong will stay the same.
138
+ void pause();
139
+ //! Returns true if the song is the current song, but in paused
140
+ //! mode.
141
+ bool paused() const;
142
+ //! Stops playback of this song if it is currently played or paused.
143
+ //! Afterwards, currentSong will return 0.
144
+ void stop();
145
+ //! Returns true if the song is currently playing.
146
+ bool playing() const;
147
+ //! Returns the current volume of the song.
148
+ double volume() const;
149
+ //! Changes the volume of the song.
150
+ void changeVolume(double volume);
151
+
152
+ //! Called every tick by Window for management purposes.
153
+ static void update();
154
+
155
+ #ifndef SWIG
156
+ enum Type { stStream, stModule };
157
+ GOSU_DEPRECATED Song(Audio&, const std::wstring& filename);
158
+ GOSU_DEPRECATED Song(Audio&, Type type, Reader reader);
159
+ #endif
160
+ };
161
+ }
162
+
163
+ #endif
data/Gosu/AutoLink.hpp ADDED
@@ -0,0 +1,16 @@
1
+ //! \file AutoLink.hpp
2
+ //! Contains pragmas that make MSVC link against all the necessary libraries
3
+ //! automatically.
4
+
5
+ #ifdef _MSC_VER
6
+ #ifndef GOSU_AUTOLINK_HPP
7
+ #define GOSU_AUTOLINK_HPP
8
+
9
+ #ifdef NDEBUG
10
+ #pragma comment(lib, "Gosu.lib")
11
+ #else
12
+ #pragma comment(lib, "GosuDebug.lib")
13
+ #endif
14
+
15
+ #endif
16
+ #endif
data/Gosu/Bitmap.hpp ADDED
@@ -0,0 +1,96 @@
1
+ //! \file Bitmap.hpp
2
+ //! Interface of the Bitmap class.
3
+
4
+ #ifndef GOSU_BITMAP_HPP
5
+ #define GOSU_BITMAP_HPP
6
+
7
+ #include <Gosu/Color.hpp>
8
+ #include <Gosu/Fwd.hpp>
9
+ #include <Gosu/GraphicsBase.hpp>
10
+ #include <Gosu/Platform.hpp>
11
+ #include <string>
12
+ #include <vector>
13
+
14
+ namespace Gosu
15
+ {
16
+ //! Rectangular area of pixels, each represented by a Color value. Provides
17
+ //! minimal drawing functionality and serves as a temporary holder for
18
+ //! graphical resources which are usually turned into Images later.
19
+ //! Has (expensive) value semantics.
20
+ class Bitmap
21
+ {
22
+ unsigned w, h;
23
+ std::vector<Color> pixels;
24
+
25
+ public:
26
+ Bitmap() : w(0), h(0) {}
27
+ Bitmap(unsigned w, unsigned h, Color c = Color::NONE) : w(w), h(h), pixels(w * h, c) {}
28
+
29
+ unsigned width() const { return w; }
30
+ unsigned height() const { return h; }
31
+
32
+ void swap(Bitmap& other);
33
+
34
+ void resize(unsigned width, unsigned height, Color c = Color::NONE);
35
+
36
+ //! Returns the color at the specified position. x and y must be on the
37
+ //! bitmap.
38
+ Color getPixel(unsigned x, unsigned y) const { return pixels[y * w + x]; }
39
+
40
+ //! Sets the pixel at the specified position to a color. x and y must
41
+ //! be on the bitmap.
42
+ void setPixel(unsigned x, unsigned y, Color c) { pixels[y * w + x] = c; }
43
+
44
+ //! Inserts a bitmap at the given position. Parts of the inserted
45
+ //! bitmap that would be outside of the target bitmap will be
46
+ //! clipped away.
47
+ void insert(const Bitmap& source, int x, int y);
48
+
49
+ //! Inserts a portion of a bitmap at the given position. Parts of the
50
+ //! inserted bitmap that would be outside of the target bitmap will be
51
+ //! clipped away.
52
+ void insert(const Bitmap& source, int x, int y, unsigned srcX,
53
+ unsigned srcY, unsigned srcWidth, unsigned srcHeight);
54
+
55
+ //! Direct access to the array of color values. May be useful for optimized
56
+ //! OpenGL operations.
57
+ const Color* data() const { return &pixels[0]; }
58
+ Color* data() { return &pixels[0]; }
59
+
60
+ // Work with data() instead if you need fast operations.
61
+ GOSU_DEPRECATED void fill(Color c);
62
+ GOSU_DEPRECATED void replace(Color oldColor, Color newColor);
63
+ };
64
+
65
+ //! Loads any supported image into a Bitmap.
66
+ void loadImageFile(Bitmap& bitmap, const std::wstring& filename);
67
+ //! Loads any supported image into a Bitmap.
68
+ void loadImageFile(Bitmap& bitmap, Reader input);
69
+
70
+ //! Saves a Bitmap to a file.
71
+ void saveImageFile(const Bitmap& bitmap, const std::wstring& filename);
72
+ //! Saves a Bitmap to an arbitrary resource.
73
+ void saveImageFile(const Bitmap& bitmap, Gosu::Writer writer,
74
+ const std::wstring& formatHint = L"png");
75
+
76
+ //! Set the alpha value of all pixels which are equal to the color key
77
+ //! to zero. Color values are adjusted so that no borders show up when
78
+ //! the image is stretched or rotated.
79
+ void applyColorKey(Bitmap& bitmap, Color key);
80
+
81
+ //! The reverse of applyColorKey. Resets all fully transparent pixels by
82
+ //! a background color, makes all other pixels fully opaque.
83
+ void unapplyColorKey(Bitmap& bitmap, Color background);
84
+
85
+ void applyBorderFlags(Bitmap& dest, const Bitmap& source,
86
+ unsigned srcX, unsigned srcY, unsigned srcWidth, unsigned srcHeight,
87
+ unsigned borderFlags);
88
+
89
+ // Use loadImageFile/saveImageFile instead.
90
+ GOSU_DEPRECATED Reader loadFromBMP(Bitmap& bmp, Reader reader);
91
+ GOSU_DEPRECATED Writer saveToBMP(const Bitmap& bmp, Writer writer);
92
+ GOSU_DEPRECATED Reader loadFromPNG(Bitmap& bmp, Reader reader);
93
+ GOSU_DEPRECATED Writer saveToPNG(const Bitmap& bmp, Writer writer);
94
+ }
95
+
96
+ #endif
@@ -0,0 +1,140 @@
1
+ #ifndef GOSU_BUTTONSMAC_HPP
2
+ #define GOSU_BUTTONSMAC_HPP
3
+
4
+ namespace Gosu
5
+ {
6
+ //! List of button ids that can be used with Gosu::Input.
7
+ //! This enumeration contains ids for keyboard keys (kb*),
8
+ //! mouse buttons and mouse wheel (ms*) and gamepad buttons (gp*).
9
+ enum ButtonName
10
+ {
11
+ kbRangeBegin = 0x00,
12
+ kbEscape = 0x35,
13
+ kbF1 = 0x7a,
14
+ kbF2 = 0x78,
15
+ kbF3 = 0x63,
16
+ kbF4 = 0x76,
17
+ kbF5 = 0x60,
18
+ kbF6 = 0x61,
19
+ kbF7 = 0x62,
20
+ kbF8 = 0x64,
21
+ kbF9 = 0x65,
22
+ kbF10 = 0x6d,
23
+ kbF11 = 0x67,
24
+ kbF12 = 0x6f,
25
+ kb1 = 0x12,
26
+ kb2 = 0x13,
27
+ kb3 = 0x14,
28
+ kb4 = 0x15,
29
+ kb5 = 0x17,
30
+ kb6 = 0x16,
31
+ kb7 = 0x1a,
32
+ kb8 = 0x1c,
33
+ kb9 = 0x19,
34
+ kb0 = 0x1d,
35
+ kbA = 0x00,
36
+ kbB = 0x0b,
37
+ kbC = 0x08,
38
+ kbD = 0x02,
39
+ kbE = 0x0e,
40
+ kbF = 0x03,
41
+ kbG = 0x05,
42
+ kbH = 0x04,
43
+ kbI = 0x22,
44
+ kbJ = 0x26,
45
+ kbK = 0x28,
46
+ kbL = 0x25,
47
+ kbM = 0x2e,
48
+ kbN = 0x2d,
49
+ kbO = 0x1f,
50
+ kbP = 0x23,
51
+ kbQ = 0x0c,
52
+ kbR = 0x0f,
53
+ kbS = 0x01,
54
+ kbT = 0x11,
55
+ kbU = 0x20,
56
+ kbV = 0x09,
57
+ kbW = 0x0d,
58
+ kbX = 0x07,
59
+ kbY = 0x10,
60
+ kbZ = 0x06,
61
+ kbTab = 0x30,
62
+ kbReturn = 0x24,
63
+ kbSpace = 0x31,
64
+ kbLeftShift = 0x38,
65
+ kbRightShift = 0x3c,
66
+ kbLeftControl = 0x3b,
67
+ kbRightControl = 0x3e,
68
+ kbLeftAlt = 0x3a,
69
+ kbRightAlt = 0x3d,
70
+ kbLeftMeta = 0x37,
71
+ kbRightMeta = 0x36,
72
+ kbBackspace = 0x33,
73
+ kbLeft = 0x7b,
74
+ kbRight = 0x7c,
75
+ kbUp = 0x7e,
76
+ kbDown = 0x7d,
77
+ kbHome = 0x73,
78
+ kbEnd = 0x77,
79
+ kbInsert = 0x72,
80
+ kbDelete = 0x75,
81
+ kbPageUp = 0x74,
82
+ kbPageDown = 0x79,
83
+ kbEnter = 0x4c,
84
+ kbNumpad1 = 0x53,
85
+ kbNumpad2 = 0x54,
86
+ kbNumpad3 = 0x55,
87
+ kbNumpad4 = 0x56,
88
+ kbNumpad5 = 0x57,
89
+ kbNumpad6 = 0x58,
90
+ kbNumpad7 = 0x59,
91
+ kbNumpad8 = 0x5b,
92
+ kbNumpad9 = 0x5c,
93
+ kbNumpad0 = 0x52,
94
+ kbNumpadAdd = 0x45,
95
+ kbNumpadSubtract = 0x4e,
96
+ kbNumpadMultiply = 0x43,
97
+ kbNumpadDivide = 0x4b,
98
+ kbRangeEnd = 0xffff,
99
+
100
+ msRangeBegin,
101
+ msLeft = msRangeBegin,
102
+ msRight,
103
+ msMiddle,
104
+ msWheelUp,
105
+ msWheelDown,
106
+ msRangeEnd,
107
+
108
+ gpRangeBegin,
109
+ gpLeft = gpRangeBegin,
110
+ gpRight,
111
+ gpUp,
112
+ gpDown,
113
+ gpButton0,
114
+ gpButton1,
115
+ gpButton2,
116
+ gpButton3,
117
+ gpButton4,
118
+ gpButton5,
119
+ gpButton6,
120
+ gpButton7,
121
+ gpButton8,
122
+ gpButton9,
123
+ gpButton10,
124
+ gpButton11,
125
+ gpButton12,
126
+ gpButton13,
127
+ gpButton14,
128
+ gpButton15,
129
+ gpRangeEnd = gpButton15,
130
+
131
+ kbNum = kbRangeEnd - kbRangeBegin + 1,
132
+ msNum = msRangeEnd - msRangeBegin + 1,
133
+ gpNum = gpRangeEnd - gpRangeBegin + 1,
134
+
135
+ numButtons = gpRangeEnd + 1,
136
+ noButton = 0xffffffff
137
+ };
138
+ }
139
+
140
+ #endif