gosu 0.8.7.2-x64-mingw32 → 0.9.0-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d9012667b595b00d15d26b07ed47da2d923602c2
4
- data.tar.gz: 1fb007b4d50bd1dad15cf70920abcb689747c77b
3
+ metadata.gz: 9704d7a5bf616373600f78e20ec4ef65d7600538
4
+ data.tar.gz: b4d4947e6e3dcf31ee013c5aad10b3614ebef51f
5
5
  SHA512:
6
- metadata.gz: d88d930fa97a27cd49cf2d509a743f051a04e8ad6277aa85dbbd0f175391a3dae346adde70256cb7cc7820c417ad287305ec2baed84b44b9d29483fd6807a4cf
7
- data.tar.gz: 4bd4ad9a755c61704e24b6c7afd28f56040691f75535e2b73b4ae446687709c9c4df6c406b5fdccc515ea92d7b4fcb7e1c54a666d630b2d710ec9ee9aa897b3a
6
+ metadata.gz: 0ed0a0e725b7232d3bfe6c805ccb5cf108405964c58f00f423f862923f526f937a2935918960f7a4352237c3a6f5e911a14b091db66d11be4f2d3b45b7d09472
7
+ data.tar.gz: 2a07ea83ac53bc8b1c1d11aa64a52e457a91b3b61fc420b86d5234e282e7d254224b5e8c1a49e06615251c262598997363e9cccebe97305f307d0ec878fb4035
data/Gosu/Audio.hpp CHANGED
@@ -36,6 +36,7 @@ namespace Gosu
36
36
 
37
37
  public:
38
38
  //! Called by Sample, do not use.
39
+ // TODO: See if we can use 'friend' here.
39
40
  SampleInstance(int handle, int extra);
40
41
 
41
42
  bool playing() const;
data/Gosu/Font.hpp CHANGED
@@ -8,6 +8,7 @@
8
8
  #include <Gosu/Color.hpp>
9
9
  #include <Gosu/GraphicsBase.hpp>
10
10
  #include <Gosu/Platform.hpp>
11
+ #include <Gosu/Text.hpp>
11
12
  #include <Gosu/TR1.hpp>
12
13
  #include <string>
13
14
 
@@ -29,8 +30,8 @@ namespace Gosu
29
30
  //! \param fontHeight Height of the font, in pixels.
30
31
  //! \param fontFlags Flags used to render individual characters of
31
32
  //! the font.
32
- Font(Graphics& graphics, const std::wstring& fontName,
33
- unsigned fontHeight, unsigned fontFlags = ffBold);
33
+ Font(unsigned fontHeight, const std::wstring& fontName = defaultFontName(),
34
+ unsigned fontFlags = ffBold);
34
35
 
35
36
  //! Returns the name of the font that was used to create it.
36
37
  std::wstring name() const;
@@ -70,10 +71,13 @@ namespace Gosu
70
71
  void setImage(wchar_t wc, const Gosu::Image& image);
71
72
 
72
73
  #ifndef SWIG
74
+ GOSU_DEPRECATED Font(Graphics& graphics, const std::wstring& fontName,
75
+ unsigned fontHeight, unsigned fontFlags = ffBold);
76
+
73
77
  GOSU_DEPRECATED
74
78
  #endif
75
- //! DEPRECATED: Analogous to draw, but rotates the text by a given angle. Use
76
- //! a simple pushTransform to achieve the same effect.
79
+ //! DEPRECATED: Analogous to draw, but rotates the text by a given angle.
80
+ //! Use Graphics::pushTransform to achieve the same effect.
77
81
  void drawRot(const std::wstring& text, double x, double y, ZPos z, double angle,
78
82
  double factorX = 1, double factorY = 1,
79
83
  Color c = Color::WHITE, AlphaMode mode = amDefault) const;
data/Gosu/Graphics.hpp CHANGED
@@ -12,6 +12,8 @@
12
12
 
13
13
  namespace Gosu
14
14
  {
15
+ struct DrawOp;
16
+
15
17
  //! Returns the maximum size of an texture that will be allocated
16
18
  //! internally by Gosu.
17
19
  //! Useful when extending Gosu using OpenGL.
@@ -20,9 +22,15 @@ namespace Gosu
20
22
  //! Serves as the target of all drawing and provides primitive drawing
21
23
  //! functionality.
22
24
  //! Usually created internally by Gosu::Window.
25
+ //
26
+ // TODO: This class should be separated into a Gosu::Viewport class, which
27
+ // carries the width/height/fullscreen attributes, and global Gosu::drawFoo
28
+ // functions. A Window then has a Viewport, and in theory, multiple windows
29
+ // could have their own viewports etc.
23
30
  class Graphics
24
31
  {
25
32
  struct Impl;
33
+
26
34
  const GOSU_UNIQUE_PTR<Impl> pimpl;
27
35
 
28
36
  #if defined(GOSU_CPP11_ENABLED)
@@ -37,7 +45,6 @@ namespace Gosu
37
45
  Graphics(unsigned physicalWidth, unsigned physicalHeight, bool fullscreen);
38
46
  ~Graphics();
39
47
 
40
- // TODO: Replace by setBaseTransform()
41
48
  void setResolution(unsigned virtualWidth, unsigned virtualHeight,
42
49
  double horizontalBlackBarWidth = 0, double verticalBlackBarHeight = 0);
43
50
 
@@ -50,65 +57,68 @@ namespace Gosu
50
57
  bool begin(Color clearWithColor = Color::BLACK);
51
58
  //! Every call to begin must have a matching call to end.
52
59
  void end();
60
+
53
61
  //! Flushes the Z queue to the screen and starts a new one.
54
62
  //! Useful for games that are *very* composite in nature (splitscreen).
55
- void flush();
63
+ static void flush();
56
64
 
57
65
  //! Finishes all pending Gosu drawing operations and executes
58
66
  //! the following OpenGL code in a clean environment.
59
- void beginGL();
67
+ static void beginGL();
60
68
  //! Resets Gosu into its default rendering state.
61
- void endGL();
69
+ static void endGL();
62
70
  //! Schedules a custom GL functor to be executed at a certain Z level.
63
71
  //! The functor is called in a clean GL context (as given by beginGL/endGL).
64
72
  //! Gosu's rendering up to the Z level may not yet have been glFlush()ed.
65
73
  //! Note: You may not call any Gosu rendering functions from within the
66
74
  //! functor, and you must schedule it from within Window::draw's call tree.
67
- void scheduleGL(const std::tr1::function<void()>& functor, ZPos z);
75
+ static void scheduleGL(const std::tr1::function<void()>& functor, ZPos z);
68
76
 
69
77
  //! Enables clipping to a specified rectangle.
70
- void beginClipping(double x, double y, double width, double height);
78
+ static void beginClipping(double x, double y, double width, double height);
71
79
  //! Disables clipping.
72
- void endClipping();
80
+ static void endClipping();
73
81
 
74
82
  //! Starts recording a macro. Cannot be nested.
75
- void beginRecording();
83
+ static void beginRecording();
76
84
  //! Finishes building the macro and returns it as a drawable object.
77
85
  //! The width and height affect nothing about the recording process,
78
86
  //! the resulting macro will simply return these values when you ask
79
87
  //! it.
80
88
  //! Most usually, the return value is passed to Image::Image().
81
- GOSU_UNIQUE_PTR<Gosu::ImageData> endRecording(int width, int height);
89
+ static GOSU_UNIQUE_PTR<Gosu::ImageData> endRecording(int width, int height);
82
90
 
83
91
  //! Pushes one transformation onto the transformation stack.
84
- void pushTransform(const Transform& transform);
92
+ static void pushTransform(const Transform& transform);
85
93
  //! Pops one transformation from the transformation stack.
86
- void popTransform();
94
+ static void popTransform();
87
95
 
88
96
  //! Draws a line from one point to another (last pixel exclusive).
89
97
  //! Note: OpenGL lines are not reliable at all and may have a missing pixel at the start
90
98
  //! or end point. Please only use this for debugging purposes. Otherwise, use a quad or
91
99
  //! image to simulate lines, or contribute a better drawLine to Gosu.
92
- void drawLine(double x1, double y1, Color c1,
100
+ static void drawLine(double x1, double y1, Color c1,
93
101
  double x2, double y2, Color c2,
94
102
  ZPos z, AlphaMode mode = amDefault);
95
103
 
96
- void drawTriangle(double x1, double y1, Color c1,
104
+ static void drawTriangle(double x1, double y1, Color c1,
97
105
  double x2, double y2, Color c2,
98
106
  double x3, double y3, Color c3,
99
107
  ZPos z, AlphaMode mode = amDefault);
100
108
 
101
- void drawQuad(double x1, double y1, Color c1,
109
+ static void drawQuad(double x1, double y1, Color c1,
102
110
  double x2, double y2, Color c2,
103
111
  double x3, double y3, Color c3,
104
112
  double x4, double y4, Color c4,
105
113
  ZPos z, AlphaMode mode = amDefault);
114
+
115
+ //! For internal use only.
116
+ static void scheduleDrawOp(const DrawOp& op);
106
117
 
107
- //! Turns a portion of a bitmap into something that can be drawn on
108
- //! this graphics object.
109
- GOSU_UNIQUE_PTR<ImageData> createImage(const Bitmap& src,
118
+ //! Turns a portion of a bitmap into something that can be drawn on a Graphics object.
119
+ static GOSU_UNIQUE_PTR<ImageData> createImage(const Bitmap& src,
110
120
  unsigned srcX, unsigned srcY, unsigned srcWidth, unsigned srcHeight,
111
- unsigned borderFlags);
121
+ unsigned imageFlags);
112
122
  };
113
123
  }
114
124
 
@@ -31,11 +31,11 @@ namespace Gosu
31
31
  //! The color's channels will be multiplied with each other.
32
32
  MULTIPLY
33
33
  };
34
- GOSU_DEPRECATED constexpr AlphaMode amDefault = AlphaMode::DEFAULT;
35
- GOSU_DEPRECATED constexpr AlphaMode amInterpolate = AlphaMode::INTERPOLATE;
36
- GOSU_DEPRECATED constexpr AlphaMode amAdd = AlphaMode::ADD;
37
- GOSU_DEPRECATED constexpr AlphaMode amAdditive = AlphaMode::ADD;
38
- GOSU_DEPRECATED constexpr AlphaMode amMultiply = AlphaMode::MULTIPLY;
34
+ constexpr AlphaMode amDefault = AlphaMode::DEFAULT;
35
+ constexpr AlphaMode amInterpolate = AlphaMode::INTERPOLATE;
36
+ constexpr AlphaMode amAdd = AlphaMode::ADD;
37
+ constexpr AlphaMode amAdditive = AlphaMode::ADD;
38
+ constexpr AlphaMode amMultiply = AlphaMode::MULTIPLY;
39
39
  #else
40
40
  enum AlphaMode
41
41
  {
@@ -68,15 +68,19 @@ namespace Gosu
68
68
  taJustify
69
69
  };
70
70
 
71
- //! Flags that affect the tileability of an image.
72
- enum BorderFlags
71
+ enum ImageFlags
73
72
  {
74
- bfSmooth = 0,
75
- bfTileableLeft = 1,
76
- bfTileableTop = 2,
77
- bfTileableRight = 4,
78
- bfTileableBottom = 8,
79
- bfTileable = bfTileableLeft | bfTileableTop | bfTileableRight | bfTileableBottom
73
+ //! Flags that affect the tileability of an image.
74
+ ifSmooth = 0,
75
+ // Note: No constant for '1', but Gosu treats '1' as ifTileable for
76
+ // backward compatibility reasons (this used to be a bool).
77
+ ifTileableLeft = 2,
78
+ ifTileableTop = 4,
79
+ ifTileableRight = 8,
80
+ ifTileableBottom = 16,
81
+ ifTileable = ifTileableLeft | ifTileableTop | ifTileableRight | ifTileableBottom
82
+
83
+ // TODO - ifNearestNeighbor to replace undocumentedRetrofication.
80
84
  };
81
85
 
82
86
  #ifdef GOSU_IS_MAC
data/Gosu/Image.hpp CHANGED
@@ -19,31 +19,29 @@ namespace Gosu
19
19
  std::tr1::shared_ptr<ImageData> data;
20
20
 
21
21
  public:
22
- //! Loads an image from a given filename that can be drawn onto
23
- //! graphics.
24
- //! This constructor can handle PNG and BMP images. A color key of #ff00ff is
25
- //! automatically applied to BMP type images. For more flexibility, use the
26
- //! corresponding constructor that uses a Bitmap object.
27
- Image(Graphics& graphics, const std::wstring& filename,
28
- bool tileable = false);
29
- //! Loads a portion of the the image at the given filename that can be
30
- //! drawn onto graphics.
31
- //! This constructor can handle PNG and BMP images. A color key of #ff00ff is
32
- //! automatically applied to BMP type images. For more flexibility, use the
33
- //! corresponding constructor that uses a Bitmap object.
34
- Image(Graphics& graphics, const std::wstring& filename, unsigned srcX,
22
+ //! Loads an image from a given filename.
23
+ //!
24
+ //! A color key of #ff00ff is automatically applied to BMP image files.
25
+ //! For more flexibility, use the corresponding constructor that uses a Bitmap object.
26
+ explicit Image(const std::wstring& filename,
27
+ unsigned imageFlags = ifSmooth);
28
+
29
+ //! Loads a portion of the the image at the given filename..
30
+ //!
31
+ //! A color key of #ff00ff is automatically applied to BMP image files.
32
+ //! For more flexibility, use the corresponding constructor that uses a Bitmap object.
33
+ Image(const std::wstring& filename, unsigned srcX,
35
34
  unsigned srcY, unsigned srcWidth, unsigned srcHeight,
36
- bool tileable = false);
35
+ unsigned imageFlags = ifSmooth);
37
36
 
38
- //! Converts the given bitmap into an image that can be drawn onto
39
- //! graphics.
40
- Image(Graphics& graphics, const Bitmap& source,
41
- bool tileable = false);
42
- //! Converts a portion of the given bitmap into an image that can be
43
- //! drawn onto graphics.
44
- Image(Graphics& graphics, const Bitmap& source, unsigned srcX,
37
+ //! Converts the given bitmap into an image.
38
+ explicit Image(const Bitmap& source,
39
+ unsigned imageFlags = ifSmooth);
40
+
41
+ //! Converts a portion of the given bitmap into an image.
42
+ Image(const Bitmap& source, unsigned srcX,
45
43
  unsigned srcY, unsigned srcWidth, unsigned srcHeight,
46
- bool tileable = false);
44
+ unsigned imageFlags = ifSmooth);
47
45
 
48
46
  //! Creates an Image from a user-supplied instance of the ImageData interface.
49
47
  explicit Image(GOSU_UNIQUE_PTR<ImageData> data);
@@ -56,8 +54,8 @@ namespace Gosu
56
54
  double factorX = 1, double factorY = 1,
57
55
  Color c = Color::WHITE,
58
56
  AlphaMode mode = amDefault) const;
59
- //! Like draw(), but allows to give modulation colors for all four
60
- //! corners.
57
+ //! Like draw(), but with modulation colors for all four corners.
58
+ //! TODO: This can be an overload of draw() - in any case the name is terrible.
61
59
  void drawMod(double x, double y, ZPos z,
62
60
  double factorX, double factorY,
63
61
  Color c1, Color c2, Color c3, Color c4,
@@ -77,46 +75,57 @@ namespace Gosu
77
75
  double factorX = 1, double factorY = 1,
78
76
  Color c = Color::WHITE,
79
77
  AlphaMode mode = amDefault) const;
80
-
78
+
79
+ #ifndef SWIG
81
80
  //! Provides access to the underlying image data object.
82
81
  ImageData& getData() const;
82
+
83
+ GOSU_DEPRECATED Image(Graphics& graphics, const std::wstring& filename,
84
+ bool tileable = false);
85
+ GOSU_DEPRECATED Image(Graphics& graphics, const std::wstring& filename, unsigned srcX,
86
+ unsigned srcY, unsigned srcWidth, unsigned srcHeight,
87
+ bool tileable = false);
88
+ GOSU_DEPRECATED Image(Graphics& graphics, const Bitmap& source,
89
+ bool tileable = false);
90
+ GOSU_DEPRECATED Image(Graphics& graphics, const Bitmap& source, unsigned srcX,
91
+ unsigned srcY, unsigned srcWidth, unsigned srcHeight,
92
+ bool tileable = false);
93
+ #endif
83
94
  };
84
95
 
85
- std::vector<Gosu::Image> loadTiles(Graphics& graphics, const Bitmap& bmp, int tileWidth, int tileHeight, bool tileable);
86
- std::vector<Gosu::Image> loadTiles(Graphics& graphics, const std::wstring& bmp, int tileWidth, int tileHeight, bool tileable);
96
+ #ifndef SWIG
97
+ //! Convenience function that slices an image file into a grid and creates images from them.
98
+ //! \param tileWidth If positive, specifies the width of one tile in pixels.
99
+ //! If negative, the bitmap is divided into -tileWidth rows.
100
+ //! \param tileHeight See tileWidth.
101
+ std::vector<Gosu::Image> loadTiles(const Bitmap& bmp,
102
+ int tileWidth, int tileHeight, unsigned imageFlags = ifSmooth);
87
103
 
88
- //! Convenience function that splits a BMP or PNG file into an array
89
- //! of small rectangles and creates images from them.
90
- //! \param tileWidth If positive, specifies the width of one tile in
91
- //! pixels. If negative, the bitmap is divided into -tileWidth rows.
104
+ //! Convenience function that slices a bitmap into a grid and creates images from them.
105
+ //! \param tileWidth If positive, specifies the width of one tile in pixels.
106
+ //! If negative, the bitmap is divided into -tileWidth rows.
92
107
  //! \param tileHeight See tileWidth.
93
- //! \param appendTo STL container to which the images will be appended.
94
- //! Must provide a push_back member function; vector<tr1::shared_ptr<Image>>
95
- //! or boost::ptr_vector<Image> are good choices.
108
+ std::vector<Gosu::Image> loadTiles(const std::wstring& filename,
109
+ int tileWidth, int tileHeight, unsigned imageFlags = ifSmooth);
110
+
111
+ GOSU_DEPRECATED std::vector<Gosu::Image> loadTiles(Graphics& graphics, const Bitmap& bmp, int tileWidth, int tileHeight, bool tileable);
112
+ GOSU_DEPRECATED std::vector<Gosu::Image> loadTiles(Graphics& graphics, const std::wstring& bmp, int tileWidth, int tileHeight, bool tileable);
96
113
  template<typename Container>
97
- void imagesFromTiledBitmap(Graphics& graphics, const std::wstring& filename, int tileWidth, int tileHeight, bool tileable, Container& appendTo)
114
+ GOSU_DEPRECATED void imagesFromTiledBitmap(Graphics& graphics, const std::wstring& filename, int tileWidth, int tileHeight, bool tileable, Container& appendTo)
98
115
  {
99
116
  std::vector<Gosu::Image> tiles = loadTiles(graphics, filename, tileWidth, tileHeight, tileable);
100
117
  for (int i = 0, num = tiles.size(); i < num; ++i)
101
118
  appendTo.push_back(typename Container::value_type(new Gosu::Image(tiles[i])));
102
119
  }
103
-
104
- //! Convenience function that splits a bitmap into an area of array
105
- //! rectangles and creates images from them.
106
- //! \param tileWidth If positive, specifies the width of one tile in
107
- //! pixels. If negative, the bitmap is divided into -tileWidth rows.
108
- //! \param tileHeight See tileWidth.
109
- //! \param appendTo STL container to which the images will be appended.
110
- //! Must provide a push_back member function; std::vector<std::tr1::shared_ptr<Image>>
111
- //! or boost::ptr_vector<Image> are good choices.
112
120
  template<typename Container>
113
- void imagesFromTiledBitmap(Graphics& graphics, const Bitmap& bmp,
121
+ GOSU_DEPRECATED void imagesFromTiledBitmap(Graphics& graphics, const Bitmap& bmp,
114
122
  int tileWidth, int tileHeight, bool tileable, Container& appendTo)
115
123
  {
116
124
  std::vector<Gosu::Image> tiles = loadTiles(graphics, bmp, tileWidth, tileHeight, tileable);
117
125
  for (int i = 0, num = tiles.size(); i < num; ++i)
118
126
  appendTo.push_back(typename Container::value_type(new Gosu::Image(tiles[i])));
119
127
  }
128
+ #endif
120
129
  }
121
130
 
122
131
  #endif
data/Gosu/Input.hpp CHANGED
@@ -103,7 +103,7 @@ namespace Gosu
103
103
 
104
104
  //! Returns true if a button is currently pressed.
105
105
  //! Updated every tick.
106
- bool down(Button btn) const;
106
+ static bool down(Button btn);
107
107
 
108
108
  //! Returns the horizontal position of the mouse relative to the top
109
109
  //! left corner of the window given to Input's constructor.
@@ -112,8 +112,8 @@ namespace Gosu
112
112
  double mouseY() const;
113
113
 
114
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.
115
+ //! as possible. x and y are relative to the window, just as in mouseX()
116
+ //! and mouseY(), so (0, 0) is the top left corner of the window..
117
117
  void setMousePosition(double x, double y);
118
118
 
119
119
  // Undocumented for the moment. Also applies to currentTouches().
@@ -132,11 +132,11 @@ namespace Gosu
132
132
  void update();
133
133
 
134
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.
135
+ //! If you use the Window class, it will assign these to its own methods.
136
136
  std::tr1::function<void (Button)> onButtonDown, onButtonUp;
137
137
 
138
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.
139
+ //! If you use the Window class, it will assign these to its own methods.
140
140
  std::tr1::function<void (Touch)> onTouchBegan, onTouchMoved, onTouchEnded;
141
141
 
142
142
  //! Returns the currently active TextInput instance, or 0.
data/Gosu/Version.hpp CHANGED
@@ -2,9 +2,9 @@
2
2
  #define GOSU_VERSION_HPP
3
3
 
4
4
  #define GOSU_MAJOR_VERSION 0
5
- #define GOSU_MINOR_VERSION 8
6
- #define GOSU_POINT_VERSION 7
7
- #define GOSU_VERSION "0.8.7.2"
5
+ #define GOSU_MINOR_VERSION 9
6
+ #define GOSU_POINT_VERSION 0
7
+ #define GOSU_VERSION "0.9.0"
8
8
 
9
9
  #define GOSU_COPYRIGHT_NOTICE \
10
10
  "This software uses the following third-party libraries:\n" \
data/Gosu/Window.hpp CHANGED
@@ -57,7 +57,7 @@ namespace Gosu
57
57
  //! \param height See width.
58
58
  //! \param updateInterval Interval in milliseconds between two calls
59
59
  //! to the update member function.
60
- Window(unsigned width, unsigned height, bool fullscreen,
60
+ Window(unsigned width, unsigned height, bool fullscreen = false,
61
61
  double updateInterval = 16.666666);
62
62
  virtual ~Window();
63
63
 
@@ -113,13 +113,6 @@ namespace Gosu
113
113
  const Input& input() const;
114
114
  Input& input();
115
115
 
116
- #ifdef GOSU_IS_UNIX
117
- // Context for creating shared contexts.
118
- // Only on Unices (so far).
119
- typedef std::tr1::shared_ptr<std::tr1::function<void()> > SharedContext;
120
- SharedContext createSharedContext();
121
- #endif
122
-
123
116
  #ifdef GOSU_IS_IPHONE
124
117
  void* rootViewController() const;
125
118
  // iPhone-only callbacks for touch events.
data/lib/gosu/patches.rb CHANGED
@@ -1,76 +1,112 @@
1
- # Extend Numeric with simple angle conversion methods.
1
+ # Extend Numeric with simple angle conversion methods,
2
+ # for easier integration with Chipmunk.
2
3
  class ::Numeric
3
4
  def degrees_to_radians
4
5
  self * Math::PI / 180.0
5
6
  end
7
+
6
8
  def radians_to_degrees
7
9
  self * 180.0 / Math::PI
8
10
  end
11
+
9
12
  def gosu_to_radians
10
13
  (self - 90) * Math::PI / 180.0
11
14
  end
15
+
12
16
  def radians_to_gosu
13
17
  self * 180.0 / Math::PI + 90
14
18
  end
15
19
  end
16
-
17
- # Backwards compatibility: import constants into Gosu::Button.
20
+
21
+ # Backwards compatibility:
22
+ # Import constants into Gosu::Button.
18
23
  module Gosu::Button
19
24
  Gosu.constants.each { |c| const_set(c, Gosu.const_get(c)) }
20
25
  end
21
26
 
22
- # Backwards compatibility: Window arguments to Sample and Song
27
+ # Backwards compatibility:
28
+ # The old version of from_text has been deprecated in Gosu 0.9.
29
+ class Gosu::Image
30
+ class << self
31
+ alias from_text_without_window from_text
32
+ end
33
+
34
+ def self.from_text(*args)
35
+ if args.size == 4
36
+ from_text_without_window(args[1], args[3], :font => args[2])
37
+ elsif args.size == 7
38
+ from_text_without_window(args[1], args[3], :font => args[2],
39
+ :spacing => args[4], :width => args[5], :align => args[6])
40
+ else
41
+ from_text_without_window(*args)
42
+ end
43
+ end
44
+ end
45
+
46
+ # Backwards compatibility:
47
+ # Passing a Window Sample#initialize has been deprecated in Gosu 0.7.17.
23
48
  class Gosu::Sample
24
- alias initialize_ initialize
49
+ alias initialize_without_window initialize
25
50
 
26
51
  def initialize(*args)
27
52
  args.shift if args.first.is_a? Gosu::Window
28
- initialize_(*args)
53
+ initialize_without_window(*args)
29
54
  end
30
55
  end
56
+
57
+ # Backwards compatibility:
58
+ # Passing a Window to Song#initialize has been deprecated in Gosu 0.7.17.
31
59
  class Gosu::Song
32
- alias initialize_ initialize
60
+ alias initialize_without_window initialize
33
61
 
34
62
  def initialize(*args)
35
63
  args.shift if args.first.is_a? Gosu::Window
36
- initialize_(*args)
64
+ initialize_without_window(*args)
37
65
  end
38
66
  end
39
67
 
40
- # Color constants (SWIG messes up constants somehow)
41
- class Gosu::Color
42
- class Constant < Gosu::Color
43
- private
44
- def alpha=; end
45
- def red=; end
46
- def green=; end
47
- def blue=; end
48
- def hue=; end
49
- def saturation=; end
50
- def value=; end
68
+ # Color constants.
69
+ # This is cleaner than having SWIG define them.
70
+ module Gosu
71
+ class ImmutableColor < Color
72
+ private :alpha=, :red=, :green=, :blue=, :hue=, :saturation=, :value=
51
73
  end
52
74
 
53
- NONE = Gosu::Color::Constant.argb(0x00000000)
54
- BLACK = Gosu::Color::Constant.argb(0xff000000)
55
- GRAY = Gosu::Color::Constant.argb(0xff808080)
56
- WHITE = Gosu::Color::Constant.argb(0xffffffff)
57
- AQUA = Gosu::Color::Constant.argb(0xff00ffff)
58
- RED = Gosu::Color::Constant.argb(0xffff0000)
59
- GREEN = Gosu::Color::Constant.argb(0xff00ff00)
60
- BLUE = Gosu::Color::Constant.argb(0xff0000ff)
61
- YELLOW = Gosu::Color::Constant.argb(0xffffff00)
62
- FUCHSIA = Gosu::Color::Constant.argb(0xffff00ff)
63
- CYAN = Gosu::Color::Constant.argb(0xff00ffff)
75
+ class Color
76
+ NONE = Gosu::ImmutableColor.new(0x00_000000)
77
+ BLACK = Gosu::ImmutableColor.new(0xff_000000)
78
+ GRAY = Gosu::ImmutableColor.new(0xff_808080)
79
+ WHITE = Gosu::ImmutableColor.new(0xff_ffffff)
80
+ AQUA = Gosu::ImmutableColor.new(0xff_00ffff)
81
+ RED = Gosu::ImmutableColor.new(0xff_ff0000)
82
+ GREEN = Gosu::ImmutableColor.new(0xff_00ff00)
83
+ BLUE = Gosu::ImmutableColor.new(0xff_0000ff)
84
+ YELLOW = Gosu::ImmutableColor.new(0xff_ffff00)
85
+ FUCHSIA = Gosu::ImmutableColor.new(0xff_ff00ff)
86
+ CYAN = Gosu::ImmutableColor.new(0xff_00ffff)
87
+ end
64
88
  end
65
89
 
66
- # Instance methods for button_id_to_char and char_to_button_id
67
90
  class Gosu::Window
68
- def button_id_to_char(id)
69
- self.class.button_id_to_char(id)
91
+ # Backwards compatibility:
92
+ # Class methods that have been turned into module methods.
93
+ def self.button_id_to_char(id)
94
+ Gosu.button_id_to_char(id)
95
+ end
96
+
97
+ def self.char_to_button_id(ch)
98
+ Gosu.char_to_button_id(ch)
70
99
  end
71
100
 
72
- def char_to_button_id(ch)
73
- self.class.char_to_button_id(ch)
101
+ # Backwards compatibility:
102
+ # Instance methods taht have been turned into module methods.
103
+ %w(draw_line draw_triangle draw_quad
104
+ flush gl clip_to record
105
+ transform translate rotate scale
106
+ button_id_to_char char_to_button_id button_down?).each do |method|
107
+ define_method method.to_sym do |*args, &block|
108
+ Gosu.send method, *args, &block
109
+ end
74
110
  end
75
111
  end
76
112