gosu 0.7.29-i386-mingw32 → 0.7.30-i386-mingw32

Sign up to get free protection for your applications and to get access to all the features.
@@ -20,7 +20,9 @@
20
20
  namespace Gosu
21
21
  {
22
22
  // Deprecated.
23
- class Audio;
23
+ #ifndef SWIG
24
+ GOSU_DEPRECATED class Audio;
25
+ #endif
24
26
 
25
27
  //! An instance of a Sample playing. Can be used to stop sounds dynamically,
26
28
  //! or to check if they are finished.
@@ -94,8 +96,6 @@ namespace Gosu
94
96
  SampleInstance playPan(double pan, double volume = 1, double speed = 1,
95
97
  bool looping = false) const;
96
98
 
97
-
98
- // Deprecated.
99
99
  #ifndef SWIG
100
100
  GOSU_DEPRECATED Sample(Audio& audio, const std::wstring& filename);
101
101
  GOSU_DEPRECATED Sample(Audio& audio, Reader reader);
@@ -150,16 +150,8 @@ namespace Gosu
150
150
  //! Called every tick by Window for management purposes.
151
151
  static void update();
152
152
 
153
- // Deprecated.
154
153
  #ifndef SWIG
155
- //! There are two types of songs that can be loaded as a Song: Streamed
156
- //! songs (like OGG) and modules (like MOD or XM).
157
- enum Type
158
- {
159
- stStream,
160
- stModule
161
- };
162
-
154
+ enum Type { stStream, stModule };
163
155
  GOSU_DEPRECATED Song(Audio&, const std::wstring& filename);
164
156
  GOSU_DEPRECATED Song(Audio&, Type type, Reader reader);
165
157
  #endif
@@ -7,6 +7,7 @@
7
7
  #include <Gosu/Color.hpp>
8
8
  #include <Gosu/Fwd.hpp>
9
9
  #include <Gosu/GraphicsBase.hpp>
10
+ #include <Gosu/Platform.hpp>
10
11
  #include <boost/scoped_ptr.hpp>
11
12
  #include <string>
12
13
  #include <vector>
@@ -23,18 +24,16 @@ namespace Gosu
23
24
  std::vector<Color> pixels;
24
25
 
25
26
  public:
26
- Bitmap();
27
+ Bitmap() : w(0), h(0) {}
28
+ Bitmap(unsigned w, unsigned h, Color c = Color::NONE) : w(w), h(h), pixels(w * h, c) {}
27
29
 
28
- unsigned width() const { return w; }
30
+ unsigned width() const { return w; }
29
31
  unsigned height() const { return h; }
30
32
 
31
33
  void swap(Bitmap& other);
32
34
 
33
35
  void resize(unsigned width, unsigned height, Color c = Color::NONE);
34
-
35
- void fill(Color c);
36
- void replace(Color oldColor, Color newColor);
37
-
36
+
38
37
  //! Returns the color at the specified position. x and y must be on the
39
38
  //! bitmap.
40
39
  Color getPixel(unsigned x, unsigned y) const { return pixels[y * w + x]; }
@@ -56,32 +55,43 @@ namespace Gosu
56
55
 
57
56
  //! Direct access to the array of color values. May be useful for optimized
58
57
  //! OpenGL operations.
59
- const unsigned* data() const { return reinterpret_cast<const unsigned*>(&pixels[0]); }
60
- unsigned* data() { return reinterpret_cast<unsigned*>(&pixels[0]); }
61
- };
58
+ const Color* data() const { return &pixels[0]; }
59
+ Color* data() { return &pixels[0]; }
62
60
 
63
- //! Loads a Windows or OS/2 BMP file into the given bitmap.
64
- Reader loadFromBMP(Bitmap& bmp, Reader reader);
65
- //! Saves the contents of the given bitmap into windows BMP file data.
66
- Writer saveToBMP(const Bitmap& bmp, Writer writer);
67
- //! Loads a PNG file into the given bitmap.
68
- Reader loadFromPNG(Bitmap& bmp, Reader reader);
69
- //! Saves the contents of the given bitmap into PNG file data, 24 bits.
70
- Writer saveToPNG(const Bitmap& bmp, Writer writer);
61
+ // Work with data() instead if you need fast operations.
62
+ GOSU_DEPRECATED void fill(Color c);
63
+ GOSU_DEPRECATED void replace(Color oldColor, Color newColor);
64
+ };
65
+
66
+ //! Loads any supported image into a Bitmap.
67
+ Bitmap loadImageFile(const std::wstring& filename);
68
+ //! Loads any supported image into a Bitmap.
69
+ Bitmap loadImageFile(Reader input);
71
70
 
71
+ //! Saves a Bitmap to a file.
72
+ void saveImageFile(const Bitmap& bitmap, const std::wstring& filename);
73
+ //! Saves a Bitmap to an arbitrary resource.
74
+ void saveImageFile(const Bitmap& bitmap, Gosu::Writer writer,
75
+ const std::wstring& formatHint = L"png");
76
+
72
77
  //! Set the alpha value of all pixels which are equal to the color key
73
78
  //! to zero. Color values are adjusted so that no borders show up when
74
79
  //! the image is stretched or rotated.
75
80
  void applyColorKey(Bitmap& bitmap, Color key);
76
81
 
82
+ //! The reverse of applyColorKey. Resets all fully transparent pixels by
83
+ //! a background color, makes all other pixels fully opaque.
84
+ void unapplyColorKey(Bitmap& bitmap, Color background);
85
+
77
86
  void applyBorderFlags(Bitmap& dest, const Bitmap& source,
78
87
  unsigned srcX, unsigned srcY, unsigned srcWidth, unsigned srcHeight,
79
88
  unsigned borderFlags);
80
-
81
- //! Loads any supported image into a Bitmap object.
82
- Bitmap loadImageFile(const std::wstring& filename);
83
- //! Loads any supported image into a Bitmap object.
84
- Bitmap loadImageFile(Gosu::Reader input);
89
+
90
+ // Use loadImageFile/saveImageFile instead.
91
+ GOSU_DEPRECATED Reader loadFromBMP(Bitmap& bmp, Reader reader);
92
+ GOSU_DEPRECATED Writer saveToBMP(const Bitmap& bmp, Writer writer);
93
+ GOSU_DEPRECATED Reader loadFromPNG(Bitmap& bmp, Reader reader);
94
+ GOSU_DEPRECATED Writer saveToPNG(const Bitmap& bmp, Writer writer);
85
95
  }
86
96
 
87
97
  #endif
@@ -9,7 +9,7 @@
9
9
 
10
10
  namespace Gosu
11
11
  {
12
- //! Represents an ARGB color value with 8 bits for each channel. Can be
12
+ //! Represents an RGBA color value with 8 bits for each channel. Can be
13
13
  //! implicitly constructed from literals of the form 0xaarrggbb. Has fast
14
14
  //! value semantics.
15
15
  //! The four-byte layout in memory is RGBA. On Big-Endian machines the
@@ -138,6 +138,12 @@ namespace Gosu
138
138
  return alpha() << 24 | blue() << 16 | green() << 8 | red();
139
139
  }
140
140
 
141
+ //! Returns the internal representation of the color (RGBA in memory).
142
+ boost::uint32_t gl() const
143
+ {
144
+ return rep;
145
+ }
146
+
141
147
  static const Color NONE;
142
148
  static const Color BLACK;
143
149
  static const Color GRAY;
@@ -152,24 +158,20 @@ namespace Gosu
152
158
  static const Color CYAN;
153
159
  };
154
160
 
155
- // Causes weird errors when included in the SWIG wrapping process.
156
- // If, with a future version of SWIG, this can be included and
157
- // require 'gosu'; include Gosu
158
- // works from within Ruby, the #ifndef guard can be removed.
159
161
  #ifndef SWIG
160
162
  inline bool operator<(Color a, Color b)
161
163
  {
162
- return a.argb() < b.argb();
164
+ return a.gl() < b.gl();
163
165
  }
164
166
 
165
167
  inline bool operator==(Color a, Color b)
166
168
  {
167
- return a.argb() == b.argb();
169
+ return a.gl() == b.gl();
168
170
  }
169
171
 
170
172
  inline bool operator!=(Color a, Color b)
171
173
  {
172
- return a.argb() != b.argb();
174
+ return a.gl() != b.gl();
173
175
  }
174
176
  #endif
175
177
 
@@ -14,15 +14,6 @@ namespace Gosu
14
14
  //! lower ZPos value, that is, they are performed last.
15
15
  typedef double ZPos;
16
16
 
17
- //! The lowest possible Z position. By using this, you tell Gosu that
18
- //! your drawing operation does not need Z ordering and can be performed
19
- //! immediately.
20
- //! Deprecated because this turned out not be very useful in optimizing.
21
- #ifndef SWIG
22
- GOSU_DEPRECATED
23
- #endif
24
- const double zImmediate = -std::numeric_limits<double>::infinity();
25
-
26
17
  //! Determines the way colors are combined when one is drawn onto
27
18
  //! another.
28
19
  enum AlphaMode
@@ -64,6 +55,11 @@ namespace Gosu
64
55
  bfTileableBottom = 8,
65
56
  bfTileable = bfTileableLeft | bfTileableTop | bfTileableRight | bfTileableBottom
66
57
  };
58
+
59
+ #ifndef SWIG
60
+ // A not so useful optimization.
61
+ GOSU_DEPRECATED const double zImmediate = -std::numeric_limits<double>::infinity();
62
+ #endif
67
63
  }
68
64
 
69
65
  #endif
@@ -5,17 +5,17 @@
5
5
  #define GOSU_PLATFORM_HPP
6
6
 
7
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
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
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
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
19
  #endif
20
20
 
21
21
  #include <algorithm>
@@ -42,9 +42,9 @@ namespace Gosu
42
42
  #undef CONV_FUN2
43
43
 
44
44
  #if defined(_MSC_VER)
45
- #define GOSU_NORETURN __declspec(noreturn)
45
+ # define GOSU_NORETURN __declspec(noreturn)
46
46
  #elif defined(__GNUC__)
47
- #define GOSU_NORETURN __attribute__ ((noreturn))
47
+ # define GOSU_NORETURN __attribute__ ((noreturn))
48
48
  #endif
49
49
 
50
50
  #if defined(WIN32)
@@ -62,10 +62,10 @@ namespace Gosu
62
62
  # endif
63
63
  #endif
64
64
 
65
- #if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
66
- # define GOSU_DEPRECATED __attribute__((__deprecated__))
67
- #elif defined(GOSU_IS_WIN)
65
+ #if defined(GOSU_IS_WIN)
68
66
  # define GOSU_DEPRECATED __declspec(deprecated)
67
+ #elif (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
68
+ # define GOSU_DEPRECATED __attribute__((__deprecated__))
69
69
  #else
70
70
  # define GOSU_DEPRECATED
71
71
  #endif
@@ -3,7 +3,7 @@
3
3
 
4
4
  #define GOSU_MAJOR_VERSION 0
5
5
  #define GOSU_MINOR_VERSION 7
6
- #define GOSU_POINT_VERSION 29
7
- #define GOSU_VERSION "0.7.29"
6
+ #define GOSU_POINT_VERSION 30
7
+ #define GOSU_VERSION "0.7.30"
8
8
 
9
9
  #endif
data/README.txt CHANGED
@@ -1,26 +1,25 @@
1
-  Moin and welcome to Gosu!
2
-
3
-  Gosu's main website is http://www.libgosu.org/ which always has the latest
4
- links to all relevant information.
5
-
6
-  The actual source code, wiki, issue tracker etc. are currently moving away
7
- from Gosu's old Google Code project to GitHub:
8
-
9
- http://code.google.com/p/gosu/ -> http://github.com/jlnr/gosu/
10
-
11
-  The best entry point into Gosu's documentation is still this wiki page:
12
-
13
- http://code.google.com/p/gosu/wiki/DocsOverview
14
-
15
-  Try doing the tutorial there if you don't know how to start out. Or look at
16
- one of the games in the Gosu Users board.
17
-
18
-  Remember that Gosu is licensed under the MIT license and feel invited to fork,
19
- port and transmogrify all parts of it. The only license that may affect you by
20
- indirection is libogg's (BSD-style). If you release a Gosu game in any common
21
- binary form, you will need to mention use of libogg and libvorbis somewhere.
22
-
23
-  Complaints, questions, feedback?
24
- * Visit the boards, http://www.libgosu.org/
25
- * try your luck in the chat, irc://irc.freenode.org/gosu
26
- * or e-mail me. Have fun, write games! julian@raschke.de
1
+  Moin and welcome to Gosu!
2
+
3
+  Gosu's main website is http://www.libgosu.org/, which always has the latest
4
+ links to all relevant information.
5
+
6
+  The actual source code, wiki, issue tracker etc. are all hosted on GitHub:
7
+
8
+ http://github.com/jlnr/gosu/
9
+
10
+  The best entry point into Gosu's documentation is the wiki home page:
11
+
12
+ http://github.com/jlnr/gosu/wiki
13
+
14
+  Try doing the tutorial there if you don't know how to start out. Or look at
15
+ one of the games in the Gosu Users board.
16
+
17
+  Remember that Gosu is licensed under the MIT license and feel invited to fork,
18
+ port and transmogrify all parts of it. The only license that may affect you by
19
+ indirection is libogg's (BSD-style). If you release a Gosu game in any common
20
+ binary form, you will need to mention use of libogg and libvorbis somewhere.
21
+
22
+  Complaints, questions, feedback?
23
+ * Visit the boards, http://www.libgosu.org/
24
+ * try your luck in the chat, irc://irc.freenode.org/gosu
25
+ * or e-mail me. Have fun, write games! julian@raschke.de
@@ -21,29 +21,78 @@ NULL_PIXEL = Magick::Pixel.from_color('none')
21
21
  # Design:
22
22
  # * Dynamic map creation at startup, holding it as RMagick Image in @image
23
23
  # * Testing for solidity by testing @image's pixel values
24
- # * Drawing by (re)creating an array of Gosu::Image instances, each representing
25
- # a part of the large @image
24
+ # * Drawing from a Gosu::Image instance
26
25
  # * Blasting holes into the map is implemented by drawing and erasing portions
27
- # of @image, then setting the corresponding Gosu::Image instances to nil, so
28
- # they will be recreated in Map#draw
29
- # Note: The splitting is done because recreating such a large Gosu::Image for
30
- # every map change would be a very noticeable delay!
26
+ # of @image, then recreating the corresponding area in the Gosu::Image
31
27
 
32
28
  class Map
33
29
  WIDTH, HEIGHT = 800, 600
34
- TILE_SIZE = 100
35
- TILES_X = WIDTH / TILE_SIZE
36
- TILES_Y = HEIGHT / TILE_SIZE
37
30
 
38
- def initialize(window)
31
+ def initialize window
39
32
  # We'll need the window later for re-creating Gosu images.
40
33
  @window = window
41
34
 
42
35
  # Let's start with something simple and load the sky via RMagick.
43
- # Loading JPEG files isn't possible with Gosu, so say wow!
44
- sky = Magick::Image.read("media/Sky.jpg").first
36
+ # Loading SVG files isn't possible with Gosu, so say wow!
37
+ # (Seems to take a while though)
38
+ sky = Magick::Image.read("media/Landscape.svg").first
45
39
  @sky = Gosu::Image.new(window, sky, true)
40
+
41
+ # Create the map an stores the RMagick image in @image
42
+ create_rmagick_map
46
43
 
44
+ # Copy the RMagick Image to a Gosu Image (still unchanged)
45
+ @gosu_image = Gosu::Image.new(window, @image, true)
46
+ end
47
+
48
+ def solid? x, y
49
+ # Map is open at the top.
50
+ return false if y < 0
51
+ # Map is closed on all other sides.
52
+ return true if x < 0 or x >= 800 or y >= 600
53
+ # Inside of the map, determine solidity from the map image.
54
+ @image.pixel_color(x, y) != NULL_PIXEL
55
+ end
56
+
57
+ def draw
58
+ # Sky background.
59
+ @sky.draw(0, 0, 0)
60
+ # The landscape.
61
+ @gosu_image.draw 0, 0, 0
62
+ end
63
+
64
+ # Radius of a crater.
65
+ RADIUS = 25
66
+ # Radius of a crater, Shadow included.
67
+ SH_RADIUS = 45
68
+
69
+ # Create the crater image (basically a circle shape that is used to erase
70
+ # parts of the map) and the crater shadow image.
71
+ CRATER_IMAGE = begin
72
+ crater = Magick::Image.new(2 * RADIUS, 2 * RADIUS) { self.background_color = 'none' }
73
+ gc = Magick::Draw.new
74
+ gc.fill('black').circle(RADIUS, RADIUS, RADIUS, 0)
75
+ gc.draw crater
76
+ crater
77
+ end
78
+ CRATER_SHADOW = CRATER_IMAGE.shadow(0, 0, (SH_RADIUS - RADIUS) / 2, 1)
79
+
80
+ def blast x, y
81
+ # Draw the shadow (twice for more intensity), then erase a circle from the map.
82
+ @image.composite!(CRATER_SHADOW, x - SH_RADIUS, y - SH_RADIUS, Magick::AtopCompositeOp)
83
+ @image.composite!(CRATER_SHADOW, x - SH_RADIUS, y - SH_RADIUS, Magick::AtopCompositeOp)
84
+ @image.composite!(CRATER_IMAGE, x - RADIUS, y - RADIUS, Magick::DstOutCompositeOp)
85
+
86
+ # Isolate the affected portion of the RMagick image.
87
+ dirty_portion = @image.crop(x - SH_RADIUS, y - SH_RADIUS, SH_RADIUS * 2, SH_RADIUS * 2)
88
+ # Overwrite this part of the Gosu image. If the crater begins outside of the map, still
89
+ # just update the inner part.
90
+ @gosu_image.insert dirty_portion, [x - SH_RADIUS, 0].max, [y - SH_RADIUS, 0].max
91
+ end
92
+
93
+ private
94
+
95
+ def create_rmagick_map
47
96
  # This is the one large RMagick image that represents the map.
48
97
  @image = Magick::Image.new(WIDTH, HEIGHT) { self.background_color = 'none' }
49
98
 
@@ -55,8 +104,8 @@ class Map
55
104
  gc.stroke('#603000').stroke_width(1.5)
56
105
  # Draw a smooth bezier island onto the map!
57
106
  polypoints = [0, HEIGHT]
58
- 0.upto(TILES_X) do |x|
59
- polypoints += [x * TILE_SIZE, HEIGHT * 0.2 + rand(HEIGHT * 0.8)]
107
+ 0.upto(8) do |x|
108
+ polypoints += [x * 100, HEIGHT * 0.2 + rand(HEIGHT * 0.8)]
60
109
  end
61
110
  polypoints += [WIDTH, HEIGHT]
62
111
  gc.bezier(*polypoints)
@@ -75,80 +124,6 @@ class Map
75
124
  star_y += 20 until solid?(WIDTH / 2, star_y)
76
125
  @image.composite!(star, (WIDTH - star.columns) / 2, star_y - star.rows * 0.85,
77
126
  Magick::DstOverCompositeOp)
78
-
79
- # Creates an X*Y array for the Gosu images.
80
- # (Initialized to nil automatically).
81
- @gosu_images = Array.new(TILES_X) { Array.new(TILES_Y) }
82
- end
83
-
84
- def solid?(x, y)
85
- # Map is open at the top.
86
- return false if y < 0
87
- # Map is closed on all other sides.
88
- return true if x < 0 or x >= 800 or y >= 600
89
- # Inside of the map, determine solidity from the map image.
90
- @image.pixel_color(x, y) != NULL_PIXEL
91
- end
92
-
93
- def draw
94
- # Sky background.
95
- @sky.draw(0, 0, 0)
96
- # All the tiles.
97
- TILES_Y.times do |y|
98
- TILES_X.times do |x|
99
- # Recreate images that haven't been created yet, or need to be recreated
100
- # due to map changes.
101
- if @gosu_images[x][y].nil? then
102
- part = @image.crop(x * TILE_SIZE, y * TILE_SIZE, TILE_SIZE, TILE_SIZE)
103
- @gosu_images[x][y] = Gosu::Image.new(@window, part, true)
104
- end
105
- # At last - draw it!
106
- @gosu_images[x][y].draw(x * TILE_SIZE, y * TILE_SIZE, 0)
107
- end
108
- end
109
- end
110
-
111
- # Radius of a crater.
112
- RADIUS = 25
113
- # Radius of a crater, SHadow included.
114
- SH_RADIUS = 45
115
-
116
- def blast(x, y)
117
- # This code assumes at most 2x2 tiles are affected by a blast, so
118
- # don't change the RADIUS to 200 or something ;)
119
- # Calculate the x/y indices of the two to four affected tiles.
120
- # (left/right and top/bottom might be the same).
121
-
122
- left = (x - SH_RADIUS) / TILE_SIZE
123
- right = (x + SH_RADIUS) / TILE_SIZE
124
- top = (y - SH_RADIUS) / TILE_SIZE
125
- bottom = (y + SH_RADIUS) / TILE_SIZE
126
-
127
- # Set affected images to nil.
128
- # A 'double-free' doesn't hurt if e.g. left == right! However, we have to watch out
129
- # for out-of-bounds errors.
130
-
131
- @gosu_images[left][top] = nil unless left < 0 or top < 0
132
- @gosu_images[right][top] = nil unless right >= TILES_X or top < 0
133
- @gosu_images[left][bottom] = nil unless left < 0 or bottom >= TILES_Y
134
- @gosu_images[right][bottom] = nil unless right >= TILES_X or bottom >= TILES_Y
135
-
136
- # Create the crater image (basically a circle shape that is used to erase
137
- # parts of the map) and the crater shadow image, if they don't exist
138
- # already.
139
-
140
- if @crater_image.nil? then
141
- @crater_image = Magick::Image.new(2 * RADIUS, 2 * RADIUS) { self.background_color = 'none' }
142
- gc = Magick::Draw.new
143
- gc.fill('black').circle(RADIUS, RADIUS, RADIUS, 0)
144
- gc.draw(@crater_image)
145
- @crater_shadow = @crater_image.shadow(0, 0, (SH_RADIUS - RADIUS) / 2, 1)
146
- end
147
-
148
- # Draw the shadow (twice for more intensity), then erase a circle from the map.
149
- @image.composite!(@crater_shadow, x - SH_RADIUS, y - SH_RADIUS, Magick::AtopCompositeOp)
150
- @image.composite!(@crater_shadow, x - SH_RADIUS, y - SH_RADIUS, Magick::AtopCompositeOp)
151
- @image.composite!(@crater_image, x - RADIUS, y - RADIUS, Magick::DstOutCompositeOp)
152
127
  end
153
128
  end
154
129
 
@@ -266,7 +241,7 @@ class Player
266
241
  @window.objects << Missile.new(@window, x + 10 * @dir, y - 10, @angle * @dir)
267
242
  end
268
243
 
269
- def hit_by?(missile)
244
+ def hit_by? missile
270
245
  if Gosu::distance(missile.x, missile.y, x, y) < 30 then
271
246
  # Was hit :(
272
247
  @dead = true
@@ -281,11 +256,11 @@ end
281
256
 
282
257
  class Missile
283
258
  attr_reader :x, :y, :vx, :vy
259
+
260
+ # All missile instances use the same sound.
261
+ EXPLOSION = Gosu::Sample.new("media/Explosion.wav")
284
262
 
285
263
  def initialize(window, x, y, angle)
286
- # All missile instances use the same sound.
287
- @@explosion_sound ||= Gosu::Sample.new(window, "media/Explosion.wav")
288
-
289
264
  # Horizontal/vertical velocity.
290
265
  @vx, @vy = Gosu::offset_x(angle, 20).to_i, Gosu::offset_y(angle, 20).to_i
291
266
 
@@ -303,7 +278,7 @@ class Missile
303
278
  5.times { @window.objects << Particle.new(@window, x - 25 + rand(51), y - 25 + rand(51)) }
304
279
  @window.map.blast(x, y)
305
280
  # Weeee, stereo sound!
306
- @@explosion_sound.play_pan((2 * @x - Map::WIDTH) / Map::WIDTH)
281
+ EXPLOSION.play_pan((2 * @x - Map::WIDTH) / Map::WIDTH)
307
282
  return false
308
283
  else
309
284
  return true
@@ -360,7 +335,7 @@ class GameWindow < Gosu::Window
360
335
 
361
336
  def initialize()
362
337
  super(800, 600, false)
363
- self.caption = "Medal of Anna - Gosu & RMagick Integration Demo"
338
+ self.caption = "Gosu & RMagick Integration Demo"
364
339
 
365
340
  # Texts to display in the appropriate situations.
366
341
  @player_instructions = []
@@ -369,10 +344,10 @@ class GameWindow < Gosu::Window
369
344
  @player_instructions << Gosu::Image.from_text(self,
370
345
  "It is the #{ plr == 0 ? 'green' : 'red' } toy soldier's turn.\n" +
371
346
  "(Arrow keys to walk and aim, Return to jump, Space to shoot)",
372
- Gosu::default_font_name, 25, 0, width, :center)
347
+ Gosu::default_font_name, 30, 0, width, :center)
373
348
  @player_won_messages << Gosu::Image.from_text(self,
374
349
  "The #{ plr == 0 ? 'green' : 'red' } toy soldier has won!",
375
- Gosu::default_font_name, 25, 5, width, :center)
350
+ Gosu::default_font_name, 30, 5, width, :center)
376
351
  end
377
352
 
378
353
  # Create everything!
@@ -403,7 +378,7 @@ class GameWindow < Gosu::Window
403
378
  cur_text.draw(x + 1, y, 0, 1, 1, 0xff000000)
404
379
  cur_text.draw(x, y - 1, 0, 1, 1, 0xff000000)
405
380
  cur_text.draw(x, y + 1, 0, 1, 1, 0xff000000)
406
- cur_text.draw(x, y, 0, 1, 1, 0xffffffff)
381
+ cur_text.draw(x, y, 0, 1, 1, 0xffffffff)
407
382
  end
408
383
  end
409
384
 
@@ -418,18 +393,17 @@ class GameWindow < Gosu::Window
418
393
  # If it's a player's turn, forward controls.
419
394
  if not @waiting and not @players[@current_player].dead then
420
395
  player = @players[@current_player]
421
- player.aim_up if button_down? Gosu::KbUp
422
- player.aim_down if button_down? Gosu::KbDown
396
+ player.aim_up if button_down? Gosu::KbUp
397
+ player.aim_down if button_down? Gosu::KbDown
423
398
  player.try_walk(-1) if button_down? Gosu::KbLeft
424
- player.try_walk(1) if button_down? Gosu::KbRight
425
- player.try_jump if button_down? Gosu::KbReturn
399
+ player.try_walk(+1) if button_down? Gosu::KbRight
400
+ player.try_jump if button_down? Gosu::KbReturn
426
401
  end
427
402
  end
428
403
 
429
404
  def button_down(id)
430
405
  if id == Gosu::KbSpace and not @waiting and not @players[@current_player].dead then
431
- # Shoot! This is handled in button_down because holding space shouldn't
432
- # auto-fire - the shots would come from different players.
406
+ # Shoot! This is handled in button_down because holding space shouldn't auto-fire.
433
407
  @players[@current_player].shoot
434
408
  @current_player = 1 - @current_player
435
409
  @waiting = true
@@ -0,0 +1,10 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" clip-rule="evenodd" stroke-miterlimit="10" viewBox="0 0 850.39 637.80">
3
+ <desc>SVG generated by Lineform</desc>
4
+ <defs/>
5
+ <g>
6
+ <rect width="940.00" height="734.00" x="-25.50" y="-55.50" fill="#5FB7FF" stroke="#000000" stroke-width="2.20"/>
7
+ <path d="M 223.50 49.00 C 171.16 49.00 118.84 59.51 78.91 80.50 C -0.96 122.48 -0.96 190.52 78.91 232.50 C 134.24 261.59 213.37 270.50 283.34 259.28 C 350.32 290.78 452.18 289.47 516.06 255.19 C 582.65 219.45 582.65 161.55 516.06 125.81 C 482.95 108.04 439.59 99.12 396.19 99.03 C 388.26 92.46 378.99 86.23 368.09 80.50 C 328.16 59.51 275.84 49.00 223.50 49.00 Z M 223.50 49.00 " fill="#FFFFFF" stroke="#BFBFBF" stroke-width="6.00"/>
8
+ <path d="M 735.48 183.00 C 699.52 183.00 663.55 187.05 636.11 195.16 C 607.54 203.59 593.99 214.76 595.17 225.81 C 561.74 227.76 529.60 233.37 503.83 242.72 C 438.71 266.35 438.71 304.65 503.83 328.28 C 568.96 351.91 674.56 351.91 739.69 328.28 C 787.65 310.88 800.17 285.50 777.48 263.91 C 798.41 261.97 818.28 258.74 834.86 253.84 C 889.73 237.64 889.73 211.36 834.86 195.16 C 807.42 187.05 771.44 183.00 735.48 183.00 Z M 735.48 183.00 " fill="#FFFFFF" stroke="#BFBFBF" stroke-width="6.00"/>
9
+ </g>
10
+ </svg>
Binary file
Binary file
@@ -14,26 +14,26 @@ class ::Numeric
14
14
  end
15
15
  end
16
16
 
17
- # Backwards compatibility: import the constants into Gosu::Button.
17
+ # Backwards compatibility: import constants into Gosu::Button.
18
18
  module Gosu::Button
19
19
  Gosu.constants.each { |c| const_set(c, Gosu.const_get(c)) }
20
20
  end
21
21
 
22
22
  # Backwards compatibility: Window arguments to Sample and Song
23
23
  class Gosu::Sample
24
- alias new_initialize initialize
24
+ alias initialize_ initialize
25
25
 
26
26
  def initialize(*args)
27
27
  args.shift if args.first.is_a? Gosu::Window
28
- new_initialize(*args)
28
+ initialize_(*args)
29
29
  end
30
30
  end
31
31
  class Gosu::Song
32
- alias new_initialize initialize
32
+ alias initialize_ initialize
33
33
 
34
34
  def initialize(*args)
35
35
  args.shift if args.first.is_a? Gosu::Window
36
- new_initialize(*args)
36
+ initialize_(*args)
37
37
  end
38
38
  end
39
39
 
@@ -1,6 +1,28 @@
1
1
  # SWIG workarounds
2
2
  # These are offloaded into a separate file because rb_eval_string() is weird on Ruby 1.8.
3
3
 
4
+ # Exceptions in Window callbacks often get lost, this is especially annoying in draw/update.
5
+ # It is not clear whether this is a SWIG issue or if some stack frame is not exception
6
+ # compatible, but I just call update_ and draw_ in the Ruby wrapper so I can add this
7
+ # custom debugging help:
8
+ class Gosu::Window
9
+ def update_
10
+ update
11
+ rescue Exception => e
12
+ puts e.inspect
13
+ puts e.backtrace
14
+ raise e
15
+ end
16
+
17
+ def draw_
18
+ draw
19
+ rescue Exception => e
20
+ puts e.inspect
21
+ puts e.backtrace
22
+ raise e
23
+ end
24
+ end
25
+
4
26
  # SWIG doesn't understand the C++ overloading.
5
27
  class Gosu::Image
6
28
  def self.from_text(*args)
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gosu
3
3
  version: !ruby/object:Gem::Version
4
- hash: 57
4
+ hash: 63
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 7
9
- - 29
10
- version: 0.7.29
9
+ - 30
10
+ version: 0.7.30
11
11
  platform: i386-mingw32
12
12
  authors:
13
13
  - Julian Raschke
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-03-30 00:00:00 +08:00
19
+ date: 2011-04-30 00:00:00 +08:00
20
20
  default_executable:
21
21
  dependencies: []
22
22
 
@@ -78,8 +78,8 @@ files:
78
78
  - examples/media/Cursor.png
79
79
  - examples/media/Earth.png
80
80
  - examples/media/Explosion.wav
81
+ - examples/media/Landscape.svg
81
82
  - examples/media/LargeStar.png
82
- - examples/media/Sky.jpg
83
83
  - examples/media/Smoke.png
84
84
  - examples/media/Soldier.png
85
85
  - examples/media/Space.png
@@ -120,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
120
120
  requirements: []
121
121
 
122
122
  rubyforge_project:
123
- rubygems_version: 1.6.0
123
+ rubygems_version: 1.6.2
124
124
  signing_key:
125
125
  specification_version: 3
126
126
  summary: 2D game development library.
Binary file