gosu 0.8.6-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +7 -0
  2. data/Gosu/Audio.hpp +171 -0
  3. data/Gosu/AutoLink.hpp +16 -0
  4. data/Gosu/Bitmap.hpp +96 -0
  5. data/Gosu/Buttons.hpp +265 -0
  6. data/Gosu/Color.hpp +204 -0
  7. data/Gosu/Directories.hpp +36 -0
  8. data/Gosu/Font.hpp +83 -0
  9. data/Gosu/Fwd.hpp +31 -0
  10. data/Gosu/Gosu.hpp +34 -0
  11. data/Gosu/Graphics.hpp +115 -0
  12. data/Gosu/GraphicsBase.hpp +110 -0
  13. data/Gosu/IO.hpp +269 -0
  14. data/Gosu/Image.hpp +122 -0
  15. data/Gosu/ImageData.hpp +61 -0
  16. data/Gosu/Input.hpp +149 -0
  17. data/Gosu/Inspection.hpp +14 -0
  18. data/Gosu/Math.hpp +135 -0
  19. data/Gosu/Platform.hpp +93 -0
  20. data/Gosu/Sockets.hpp +156 -0
  21. data/Gosu/TR1.hpp +56 -0
  22. data/Gosu/Text.hpp +71 -0
  23. data/Gosu/TextInput.hpp +70 -0
  24. data/Gosu/Timing.hpp +16 -0
  25. data/Gosu/Utility.hpp +28 -0
  26. data/Gosu/Version.hpp +19 -0
  27. data/Gosu/WinUtility.hpp +75 -0
  28. data/Gosu/Window.hpp +145 -0
  29. data/examples/ChipmunkIntegration.rb +275 -0
  30. data/examples/CptnRuby.rb +223 -0
  31. data/examples/GosuZen.rb +68 -0
  32. data/examples/MoreChipmunkAndRMagick.rb +155 -0
  33. data/examples/OpenGLIntegration.rb +226 -0
  34. data/examples/RMagickIntegration.rb +417 -0
  35. data/examples/TextInput.rb +154 -0
  36. data/examples/Tutorial.rb +131 -0
  37. data/examples/media/Beep.wav +0 -0
  38. data/examples/media/CptnRuby Gem.png +0 -0
  39. data/examples/media/CptnRuby Map.txt +25 -0
  40. data/examples/media/CptnRuby Tileset.png +0 -0
  41. data/examples/media/CptnRuby.png +0 -0
  42. data/examples/media/Cursor.png +0 -0
  43. data/examples/media/Earth.png +0 -0
  44. data/examples/media/Explosion.wav +0 -0
  45. data/examples/media/Landscape.svg +10 -0
  46. data/examples/media/LargeStar.png +0 -0
  47. data/examples/media/Smoke.png +0 -0
  48. data/examples/media/Soldier.png +0 -0
  49. data/examples/media/Space.png +0 -0
  50. data/examples/media/Star.png +0 -0
  51. data/examples/media/Starfighter.bmp +0 -0
  52. data/lib/gosu.rb +20 -0
  53. data/lib/gosu/patches.rb +81 -0
  54. data/lib/gosu/preview.rb +139 -0
  55. data/lib/gosu/run.rb +11 -0
  56. data/lib/gosu/swig_patches.rb +60 -0
  57. data/lib/gosu/zen.rb +89 -0
  58. data/lib64/2.1/gosu.so +0 -0
  59. data/lib64/FreeImage.dll +0 -0
  60. data/lib64/OpenAL32.dll +0 -0
  61. data/lib64/SDL2.dll +0 -0
  62. data/lib64/libsndfile.dll +0 -0
  63. metadata +110 -0
@@ -0,0 +1,61 @@
1
+ //! \file ImageData.hpp
2
+ //! Interface of the ImageData class.
3
+
4
+ #ifndef GOSU_IMAGEDATA_HPP
5
+ #define GOSU_IMAGEDATA_HPP
6
+
7
+ #include <Gosu/Color.hpp>
8
+ #include <Gosu/GraphicsBase.hpp>
9
+ #include <Gosu/Fwd.hpp>
10
+ #include <Gosu/Platform.hpp>
11
+
12
+ namespace Gosu
13
+ {
14
+ //! Contains information about the underlying OpenGL texture and the
15
+ //! u/v space used for image data. Can be retrieved from some images
16
+ //! to use them in OpenGL operations.
17
+ struct GLTexInfo
18
+ {
19
+ int texName;
20
+ float left, right, top, bottom;
21
+ };
22
+
23
+ //! The ImageData class is an abstract base class for drawable images.
24
+ //! Instances of classes derived by ImageData are usually returned by
25
+ //! Graphics::createImage and usually only used to implement drawing
26
+ //! primitives like Image, which then provide a more specialized and
27
+ //! intuitive drawing interface.
28
+ class ImageData
29
+ {
30
+ // Non-copyable
31
+ ImageData(const ImageData&);
32
+ ImageData& operator=(const ImageData&);
33
+
34
+ public:
35
+ ImageData()
36
+ {
37
+ }
38
+
39
+ virtual ~ImageData()
40
+ {
41
+ }
42
+
43
+ virtual int width() const = 0;
44
+ virtual int height() const = 0;
45
+
46
+ virtual void draw(double x1, double y1, Color c1,
47
+ double x2, double y2, Color c2,
48
+ double x3, double y3, Color c3,
49
+ double x4, double y4, Color c4,
50
+ ZPos z, AlphaMode mode) const = 0;
51
+
52
+ virtual const GLTexInfo* glTexInfo() const = 0;
53
+ virtual Bitmap toBitmap() const = 0;
54
+
55
+ virtual GOSU_UNIQUE_PTR<ImageData> subimage(int x, int y, int width, int height) const = 0;
56
+
57
+ virtual void insert(const Bitmap& bitmap, int x, int y) = 0;
58
+ };
59
+ }
60
+
61
+ #endif
@@ -0,0 +1,149 @@
1
+ //! \file Input.hpp
2
+ //! Interface of the Input class.
3
+
4
+ #ifndef GOSU_INPUT_HPP
5
+ #define GOSU_INPUT_HPP
6
+
7
+ #include <Gosu/Fwd.hpp>
8
+ #include <Gosu/Platform.hpp>
9
+ #include <Gosu/Buttons.hpp>
10
+ #include <Gosu/TR1.hpp>
11
+
12
+ #ifdef GOSU_IS_WIN
13
+ #ifndef NOMINMAX
14
+ #define NOMINMAX
15
+ #endif
16
+ #include <windows.h>
17
+ #endif
18
+
19
+ #ifdef GOSU_IS_X
20
+ #include <X11/Xlib.h>
21
+ #include <X11/Xutil.h>
22
+ #endif
23
+
24
+ #include <vector>
25
+
26
+ namespace Gosu
27
+ {
28
+ //! Very lightweight class that identifies a button (keyboard, mouse or other device).
29
+ class Button
30
+ {
31
+ unsigned id_;
32
+
33
+ public:
34
+ //! For internal use.
35
+ explicit Button(unsigned id) : id_(id) {}
36
+ //! For internal use.
37
+ unsigned id() const { return id_; }
38
+
39
+ //! Default constructor; == noButton.
40
+ Button() : id_(noButton) {}
41
+
42
+ //! Conversion from ButtonName constants.
43
+ Button(ButtonName name) : id_(name) {}
44
+ };
45
+
46
+ //! Tests whether two Buttons identify the same physical button.
47
+ inline bool operator==(Button lhs, Button rhs)
48
+ {
49
+ return lhs.id() == rhs.id();
50
+ }
51
+ inline bool operator!=(Button lhs, Button rhs)
52
+ {
53
+ return !(lhs == rhs);
54
+ }
55
+ inline bool operator<(Button lhs, Button rhs)
56
+ {
57
+ return lhs.id() < rhs.id();
58
+ }
59
+
60
+ //! Struct that saves information about a touch on the surface of a multi-
61
+ //! touch device.
62
+ //! Available even on non-iPhone platforms to make it easier to compile the
63
+ //! same source for multiple platforms.
64
+ struct Touch
65
+ {
66
+ //! Allows for identification of a touch across calls.
67
+ void* id;
68
+ //! Position of a touch on the touch screen.
69
+ float x, y;
70
+ };
71
+ typedef std::vector<Touch> Touches;
72
+
73
+ //! Manages initialization and shutdown of the input system. Only one Input
74
+ //! instance can exist per application.
75
+ class Input
76
+ {
77
+ struct Impl;
78
+ const GOSU_UNIQUE_PTR<Impl> pimpl;
79
+ #if defined(GOSU_CPP11_ENABLED)
80
+ // explicitly forbid copying and moving
81
+ Input(Input&&) = delete;
82
+ Input& operator=(Input&&) = delete;
83
+ Input(const Input&) = delete;
84
+ Input& operator=(const Input&) = delete;
85
+ #endif
86
+
87
+ public:
88
+ #ifdef GOSU_IS_IPHONE
89
+ Input(void* view, float updateInterval);
90
+ void feedTouchEvent(int type, void* touches);
91
+ #else
92
+ Input();
93
+ bool feedSDLEvent(void* event);
94
+ #endif
95
+
96
+ ~Input();
97
+
98
+ //! Returns the character a button usually produces, or 0.
99
+ static wchar_t idToChar(Button btn);
100
+ //! Returns the button that has to be pressed to produce the
101
+ //! given character, or noButton.
102
+ static Button charToId(wchar_t ch);
103
+
104
+ //! Returns true if a button is currently pressed.
105
+ //! Updated every tick.
106
+ bool down(Button btn) const;
107
+
108
+ //! Returns the horizontal position of the mouse relative to the top
109
+ //! left corner of the window given to Input's constructor.
110
+ double mouseX() const;
111
+ //! See mouseX.
112
+ double mouseY() const;
113
+
114
+ //! Immediately moves the mouse as far towards the desired position
115
+ //! as possible. x and y are relativ to the window just as in the mouse
116
+ //! position accessors.
117
+ void setMousePosition(double x, double y);
118
+
119
+ // Undocumented for the moment. Also applies to currentTouches().
120
+ void setMouseFactors(double factorX, double factorY, double offsetX = 0, double offsetY = 0);
121
+
122
+ //! Currently known touches.
123
+ const Touches& currentTouches() const;
124
+
125
+ //! Accelerometer positions in all three dimensions (smoothened).
126
+ double accelerometerX() const;
127
+ double accelerometerY() const;
128
+ double accelerometerZ() const;
129
+
130
+ //! Collects new information about which buttons are pressed, where the
131
+ //! mouse is and calls onButtonUp/onButtonDown, if assigned.
132
+ void update();
133
+
134
+ //! Assignable events that are called by update. You can bind these to your own functions.
135
+ //! If you use the Window class, it will assign forward these to its own methods.
136
+ std::tr1::function<void (Button)> onButtonDown, onButtonUp;
137
+
138
+ //! Assignable events that are called by update. You can bind these to your own functions.
139
+ //! If you use the Window class, it will assign forward these to its own methods.
140
+ std::tr1::function<void (Touch)> onTouchBegan, onTouchMoved, onTouchEnded;
141
+
142
+ //! Returns the currently active TextInput instance, or 0.
143
+ TextInput* textInput() const;
144
+ //! Sets the currently active TextInput, or clears it (input = 0).
145
+ void setTextInput(TextInput* input);
146
+ };
147
+ }
148
+
149
+ #endif
@@ -0,0 +1,14 @@
1
+ //! \file Inspection.hpp
2
+ //! A special set of functions designed for tuning Gosu games.
3
+
4
+ #ifndef GOSU_INSPECTION_HPP
5
+ #define GOSU_INSPECTION_HPP
6
+
7
+ namespace Gosu
8
+ {
9
+ //! Returns the current framerate, as determined by an unspecified and possibly
10
+ //! horrible algorithm.
11
+ int fps();
12
+ }
13
+
14
+ #endif
@@ -0,0 +1,135 @@
1
+ //! \file Math.hpp
2
+ //! Contains simple math functionality.
3
+
4
+ #ifndef GOSU_MATH_HPP
5
+ #define GOSU_MATH_HPP
6
+
7
+ namespace Gosu
8
+ {
9
+ //! Pi.
10
+ const double pi = 3.1415926536;
11
+
12
+ //! Truncates the fractional part of a real value. Equivalent to
13
+ //! static_cast<long>.
14
+ inline long trunc(double value)
15
+ {
16
+ return static_cast<long>(value);
17
+ }
18
+
19
+ //! Rounds a real value towards the next integer.
20
+ inline long round(double value)
21
+ {
22
+ if (value >= 0)
23
+ return static_cast<long>(value + 0.5);
24
+ else
25
+ return static_cast<long>(value - 0.5);
26
+ }
27
+
28
+ //! Returns a real value between min (inclusive) and max (exclusive).
29
+ //! Uses std::rand, so you should call std::srand before using it.
30
+ double random(double min, double max);
31
+
32
+ //! Translates between Gosu's angle system (where 0� is at the top)
33
+ //! and radians (where 0 is at the right).
34
+ inline double gosuToRadians(double angle)
35
+ {
36
+ return (angle - 90) * pi / 180;
37
+ }
38
+ //! Translates between Gosu's angle system (where 0� is at the top)
39
+ //! and radians (where 0 is at the right).
40
+ inline double radiansToGosu(double angle)
41
+ {
42
+ return angle * 180 / pi + 90;
43
+ }
44
+
45
+ //! Translates between degrees (used by Gosu) and radians, i.e. it
46
+ //! does not change the 'origin' of the angle system.
47
+ inline double degreesToRadians(double angle)
48
+ {
49
+ return angle * pi / 180;
50
+ }
51
+ //! Translates between degrees (used by Gosu) and radians, i.e. it
52
+ //! does not change the 'origin' of the angle system.
53
+ inline double radiansToDegrees(double angle)
54
+ {
55
+ return angle * 180 / pi;
56
+ }
57
+
58
+ //! Returns the horizontal distance between the origin and the point to
59
+ //! which you would get if you moved radius pixels in the direction
60
+ //! specified by angle.
61
+ //! \param angle Angle in degrees where 0.0 means upwards.
62
+ double offsetX(double angle, double radius);
63
+ //! Returns the vertical distance between the origin and the point to
64
+ //! which you would get if you moved radius pixels in the direction
65
+ //! specified by angle.
66
+ //! \param angle Angle in degrees where 0.0 means upwards.
67
+ double offsetY(double angle, double radius);
68
+ //! Returns the angle from point 1 to point 2 in degrees, where 0.0 means
69
+ //! upwards. Returns def if both points are equal.
70
+ double angle(double fromX, double fromY, double toX, double toY,
71
+ double def = 0);
72
+ //! Returns the smallest angle that can be added to angle1 to get to
73
+ //! angle2 (can be negative if counter-clockwise movement is shorter).
74
+ double angleDiff(double angle1, double angle2);
75
+ //! Normalizes an angle to fit into the range [0; 360[.
76
+ double normalizeAngle(double angle);
77
+
78
+ //! Returns value * value.
79
+ template<typename T>
80
+ T square(T value)
81
+ {
82
+ return value * value;
83
+ }
84
+
85
+ //! Returns min if value is smaller than min, max if value is larger than
86
+ //! max and value otherwise.
87
+ template<typename T>
88
+ T clamp(T value, T min, T max)
89
+ {
90
+ if (value < min)
91
+ return min;
92
+ if (value > max)
93
+ return max;
94
+ return value;
95
+ }
96
+
97
+ // Backward compatibility with 0.7.x
98
+ template<typename T>
99
+ T boundBy(T value, T min, T max)
100
+ {
101
+ return clamp(value, min, max);
102
+ }
103
+
104
+ //! Returns (value-min) % (max-min) + min, where % always has a positive
105
+ //! result for max > min. The results are undefined for max <= min.
106
+ //! Note: This means that max is exclusive.
107
+ int wrap(int value, int min, int max);
108
+ //! Returns (value-min) % (max-min) + min, where % always has a positive
109
+ //! result for max > min. The results are undefined for max <= min.
110
+ //! Note: This means that max is exclusive.
111
+ float wrap(float value, float min, float max);
112
+ //! Returns (value-min) % (max-min) + min, where % always has a positive
113
+ //! result for max > min. The results are undefined for max <= min.
114
+ //! Note: This means that max is exclusive.
115
+ double wrap(double value, double min, double max);
116
+
117
+ //! Returns the square of the distance between two points.
118
+ inline double distanceSqr(double x1, double y1, double x2, double y2)
119
+ {
120
+ return square(x1 - x2) + square(y1 - y2);
121
+ }
122
+
123
+ //! Returns the distance between two points.
124
+ double distance(double x1, double y1, double x2, double y2);
125
+
126
+ //! Interpolates a value between a and b, weight being the bias towards the second value.
127
+ //! Examples: interpolate(0, 10, 0.5) == 5, interpolate(-10, 10, 0.25) == 5, interpolate(0, 10, -0.5) == -5.
128
+ template<typename T>
129
+ T interpolate(T a, T b, double weight = 0.5)
130
+ {
131
+ return a * (1.0 - weight) + b * weight;
132
+ }
133
+ }
134
+
135
+ #endif
@@ -0,0 +1,93 @@
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 GOSU_IS_BIG_ENDIAN
9
+ # define IDENTITY_FUN bigToNative
10
+ # define IDENTITY_FUN2 nativeToBig
11
+ # define CONV_FUN littleToNative
12
+ # define CONV_FUN2 nativeToLittle
13
+ #else
14
+ # define GOSU_IS_LITTLE_ENDIAN
15
+ # define IDENTITY_FUN littleToNative
16
+ # define IDENTITY_FUN2 nativeToLittle
17
+ # define CONV_FUN bigToNative
18
+ # define CONV_FUN2 nativeToBig
19
+ #endif
20
+
21
+ #include <algorithm>
22
+
23
+ namespace Gosu
24
+ {
25
+ template<typename T> T IDENTITY_FUN(T t) { return t; }
26
+ template<typename T> T IDENTITY_FUN2(T t) { return t; }
27
+
28
+ template<typename T>
29
+ T CONV_FUN(T t)
30
+ {
31
+ char* begin = reinterpret_cast<char*>(&t);
32
+ std::reverse(begin, begin + sizeof t);
33
+ return t;
34
+ }
35
+
36
+ template<typename T> T CONV_FUN2(T t) { return CONV_FUN(t); }
37
+ }
38
+
39
+ #undef IDENTITY_FUN
40
+ #undef IDENTITY_FUN2
41
+ #undef CONV_FUN
42
+ #undef CONV_FUN2
43
+
44
+ #if defined(_MSC_VER)
45
+ # define GOSU_NORETURN __declspec(noreturn)
46
+ #elif defined(__GNUC__)
47
+ # define GOSU_NORETURN __attribute__ ((noreturn))
48
+ #endif
49
+
50
+ #if defined(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
+ # include <TargetConditionals.h>
59
+ # if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
60
+ # define GOSU_IS_IPHONE
61
+ # endif
62
+ # endif
63
+ #endif
64
+
65
+ #if defined (GOSU_IS_IPHONE) || defined(__arm__)
66
+ # define GOSU_IS_OPENGLES
67
+ #endif
68
+
69
+ #ifndef SWIG
70
+ # if _MSC_VER >= 1700 || ((__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && defined(__GXX_EXPERIMENTAL_CXX0X__))
71
+ # define GOSU_CPP11_ENABLED
72
+ # endif
73
+ #endif
74
+
75
+ #ifdef GOSU_CPP11_ENABLED
76
+ # define GOSU_UNIQUE_PTR std::unique_ptr
77
+ # define GOSU_MOVE_UNIQUE_PTR(ptr) std::move(ptr)
78
+ #else
79
+ # define GOSU_UNIQUE_PTR std::auto_ptr
80
+ # define GOSU_MOVE_UNIQUE_PTR(ptr) (ptr)
81
+ #endif
82
+
83
+ #ifndef GOSU_DEPRECATED
84
+ # if defined(GOSU_IS_WIN)
85
+ # define GOSU_DEPRECATED __declspec(deprecated)
86
+ # elif (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
87
+ # define GOSU_DEPRECATED __attribute__((__deprecated__))
88
+ # else
89
+ # define GOSU_DEPRECATED
90
+ # endif
91
+ #endif
92
+
93
+ #endif