rubygame 2.6.2 → 2.6.3

Sign up to get free protection for your applications and to get access to all the features.
data/NEWS CHANGED
@@ -1,5 +1,38 @@
1
1
  = NEWS
2
2
 
3
+ == Rubygame 2.6.3
4
+
5
+ Release focus: Bug fixes.
6
+
7
+ === Fixes
8
+
9
+ - Fixed: MouseMoved events always reported that all buttons were
10
+ being pressed, even when they were not. [#38]
11
+
12
+ - Fixed: MousePressed and MouseReleased events would raise an error
13
+ for mouse buttons larger than 5. [#40]
14
+
15
+ - Fixed: KeyPressed and KeyReleased events always reported that all
16
+ modifier keys were being pressed, even when they were not. [#41]
17
+
18
+ - Fixed: Rubygame would generate spurious WindowUnminimized,
19
+ InputFocusGained, and MouseFocusGained events (or the opposite)
20
+ whenever any one of those events actually occurred.
21
+
22
+ - Fixed: Surface#convert would raise NameError if no Screen was open,
23
+ due to a typo. [#42]
24
+
25
+ === Other Changes
26
+
27
+ - Rubygame will now skip auto-initialization if the RUBYGAME_NOINIT
28
+ environment variable (`ENV["RUBYGAME_NOINIT"]`) is set to "1",
29
+ "true", or "yes" (case insensitive). You must set the environment
30
+ variable *before* doing `require "rubygame"`. This is intended
31
+ for special cases where auto-initialization is not wanted.
32
+
33
+
34
+
35
+
3
36
  == Rubygame 2.6.2
4
37
 
5
38
  Release focus: Bug fixes.
@@ -89,5 +89,9 @@ end
89
89
  require File.join( this_dir, "rubygame", "screen" )
90
90
 
91
91
 
92
- Rubygame.init
93
- at_exit { Rubygame.quit }
92
+ # Handle initialization automatically unless the RUBYGAME_NOINIT
93
+ # environmental variable is set to something truthy.
94
+ unless /^(1|t|true|y|yes)$/i =~ ENV["RUBYGAME_NOINIT"]
95
+ Rubygame.init
96
+ at_exit { Rubygame.quit }
97
+ end
@@ -102,9 +102,19 @@ module Rubygame
102
102
  end
103
103
 
104
104
  def self.make_sdl_rgba( color ) # :nodoc:
105
- r,g,b,a = convert_color(color).collect!{ |c| c.to_i }[0,4]
106
- a = 255 if a.nil?
107
- [r,g,b,a]
105
+ @rgba_cache ||= {}
106
+ @rgba_cache[color] ||=
107
+ begin
108
+ r,g,b,a = convert_color(color).collect!{ |c| c.to_i }[0,4]
109
+ a ||= 255
110
+ [r,g,b,a].freeze
111
+ end
112
+ end
113
+
114
+
115
+ def self.remove_from_cache( color_name )
116
+ @rgba_cache ||= {}
117
+ @rgba_cache.delete( color_name )
108
118
  end
109
119
 
110
120
  end
@@ -59,6 +59,14 @@ module Rubygame
59
59
  end
60
60
  alias :inspect :to_s
61
61
 
62
+ def hash
63
+ @hash ||= ((@h.hash << 4) +
64
+ (@s.hash << 3) +
65
+ (@l.hash << 2) +
66
+ (@a.hash << 1) +
67
+ self.class.hash)
68
+ end
69
+
62
70
  class << self
63
71
 
64
72
  def new_from_rgba( rgba )
@@ -59,6 +59,14 @@ module Rubygame
59
59
  end
60
60
  alias :inspect :to_s
61
61
 
62
+ def hash
63
+ @hash ||= ((@h.hash << 4) +
64
+ (@s.hash << 3) +
65
+ (@v.hash << 2) +
66
+ (@a.hash << 1) +
67
+ self.class.hash)
68
+ end
69
+
62
70
  class << self
63
71
 
64
72
  def new_from_rgba( rgba )
@@ -63,6 +63,14 @@ module Rubygame
63
63
  end
64
64
  alias :inspect :to_s
65
65
 
66
+ def hash
67
+ @hash ||= ((@r.hash << 4) +
68
+ (@g.hash << 3) +
69
+ (@b.hash << 2) +
70
+ (@a.hash << 1) +
71
+ self.class.hash)
72
+ end
73
+
66
74
  class << self
67
75
  def new_from_rgba( rgba )
68
76
  new( rgba )
@@ -48,6 +48,9 @@ class Rubygame::Color::Palette
48
48
 
49
49
  # Store a color by name in this palette. See #sanitize_name
50
50
  def []=( name, color )
51
+ # Uncache colors with this name, to avoid using obsolete value.
52
+ Rubygame::Color.remove_from_cache( name )
53
+
51
54
  name = sanitize_name( name )
52
55
  @colors[name] = color
53
56
  end
@@ -257,7 +257,7 @@ class Rubygame::Mixer::Sample
257
257
  def self.load_audio( filename )
258
258
  Rubygame.deprecated( "Rubygame::Mixer::Sample", "3.0" )
259
259
 
260
- chunk = SDL::Mixer.LoadWAV( filename )
260
+ chunk = SDL::Mixer.LoadWAV( filename.to_s )
261
261
 
262
262
  if( chunk.pointer.null? )
263
263
  raise( Rubygame::SDLError,
@@ -331,7 +331,7 @@ class Rubygame::Mixer::Music
331
331
  def self.load_audio
332
332
  Rubygame.deprecated( "Rubygame::Mixer::Music", "3.0" )
333
333
 
334
- music = SDL::Mixer.LoadMUS( filename )
334
+ music = SDL::Mixer.LoadMUS( filename.to_s )
335
335
 
336
336
  if( music.pointer.null? )
337
337
  raise( Rubygame::SDLError,
@@ -144,14 +144,14 @@ module Rubygame
144
144
  gain = ev.gain
145
145
 
146
146
  # any_state = SDL::APPACTIVE | SDL::APPINPUTFOCUS | SDL::APPMOUSEFOCUS
147
- # if( state & any_state == 0 )
147
+ # if (state & any_state) == 0
148
148
  # raise( Rubygame::SDLError, "Unknown ACTIVEEVENT state #{state}. "+
149
149
  # "This is a bug in Rubygame." )
150
150
  # end
151
151
 
152
152
  events = []
153
153
 
154
- if( SDL::APPACTIVE & state )
154
+ if (SDL::APPACTIVE & state) != 0
155
155
  if( gain == 1 )
156
156
  events << WindowUnminimized.new
157
157
  else
@@ -159,7 +159,7 @@ module Rubygame
159
159
  end
160
160
  end
161
161
 
162
- if( SDL::APPINPUTFOCUS & state )
162
+ if (SDL::APPINPUTFOCUS & state) != 0
163
163
  if( gain == 1 )
164
164
  events << InputFocusGained.new
165
165
  else
@@ -167,7 +167,7 @@ module Rubygame
167
167
  end
168
168
  end
169
169
 
170
- if( SDL::APPMOUSEFOCUS & state )
170
+ if (SDL::APPMOUSEFOCUS & state) != 0
171
171
  if( gain == 1 )
172
172
  events << MouseFocusGained.new
173
173
  else
@@ -320,17 +320,17 @@ module Rubygame
320
320
  return [] if mods == 0
321
321
 
322
322
  array = []
323
- array << :left_shift if( mods & SDL::KMOD_LSHIFT )
324
- array << :right_shift if( mods & SDL::KMOD_RSHIFT )
325
- array << :left_ctrl if( mods & SDL::KMOD_LCTRL )
326
- array << :right_ctrl if( mods & SDL::KMOD_RCTRL )
327
- array << :left_alt if( mods & SDL::KMOD_LALT )
328
- array << :right_alt if( mods & SDL::KMOD_RALT )
329
- array << :left_meta if( mods & SDL::KMOD_LMETA )
330
- array << :right_meta if( mods & SDL::KMOD_RMETA )
331
- array << :numlock if( mods & SDL::KMOD_NUM )
332
- array << :capslock if( mods & SDL::KMOD_CAPS )
333
- array << :mode if( mods & SDL::KMOD_MODE )
323
+ array << :left_shift if (mods & SDL::KMOD_LSHIFT) != 0
324
+ array << :right_shift if (mods & SDL::KMOD_RSHIFT) != 0
325
+ array << :left_ctrl if (mods & SDL::KMOD_LCTRL ) != 0
326
+ array << :right_ctrl if (mods & SDL::KMOD_RCTRL ) != 0
327
+ array << :left_alt if (mods & SDL::KMOD_LALT ) != 0
328
+ array << :right_alt if (mods & SDL::KMOD_RALT ) != 0
329
+ array << :left_meta if (mods & SDL::KMOD_LMETA ) != 0
330
+ array << :right_meta if (mods & SDL::KMOD_RMETA ) != 0
331
+ array << :numlock if (mods & SDL::KMOD_NUM ) != 0
332
+ array << :capslock if (mods & SDL::KMOD_CAPS ) != 0
333
+ array << :mode if (mods & SDL::KMOD_MODE ) != 0
334
334
 
335
335
  return array
336
336
  end
@@ -378,7 +378,7 @@ module Rubygame
378
378
  when SDL::BUTTON_RIGHT; :mouse_right
379
379
  when SDL::BUTTON_WHEELUP; :mouse_wheel_up
380
380
  when SDL::BUTTON_WHEELDOWN; :mouse_wheel_down
381
- else; ("mouse_%d"%button).to_sym
381
+ else; ("mouse_%d"%ev.button).to_sym
382
382
  end
383
383
 
384
384
  pos = [ev.x, ev.y]
@@ -402,11 +402,13 @@ module Rubygame
402
402
  mods = ev.state
403
403
 
404
404
  btns = []
405
- btns << :mouse_left if( mods & SDL::BUTTON_LMASK )
406
- btns << :mouse_middle if( mods & SDL::BUTTON_MMASK )
407
- btns << :mouse_right if( mods & SDL::BUTTON_RMASK )
408
- btns << :mouse_wheel_up if( mods & (1<<(SDL::BUTTON_WHEELUP - 1)) )
409
- btns << :mouse_wheel_down if( mods & (1<<(SDL::BUTTON_WHEELDOWN - 1)) )
405
+ btns << :mouse_left if (mods & SDL::BUTTON_LMASK) != 0
406
+ btns << :mouse_middle if (mods & SDL::BUTTON_MMASK) != 0
407
+ btns << :mouse_right if (mods & SDL::BUTTON_RMASK) != 0
408
+ btns << :mouse_wheel_up if (mods &
409
+ (1 << (SDL::BUTTON_WHEELUP - 1))) != 0
410
+ btns << :mouse_wheel_down if (mods &
411
+ (1 << (SDL::BUTTON_WHEELDOWN - 1))) != 0
410
412
 
411
413
  pos = [ev.x, ev.y]
412
414
  rel = [ev.xrel, ev.yrel]
@@ -76,7 +76,7 @@ class Rubygame::Surface
76
76
  # XPM:: "XPixMap" format.
77
77
  #
78
78
  def load( filename )
79
- surf = SDL::Image.Load( filename )
79
+ surf = SDL::Image.Load( filename.to_s )
80
80
 
81
81
  if( surf.pointer.null? )
82
82
  raise( Rubygame::SDLError, "Couldn't load image \"%s\": %s"%\
@@ -76,7 +76,7 @@ class Rubygame::Music
76
76
  def load( filename )
77
77
  Rubygame.open_audio
78
78
 
79
- music = SDL::Mixer.LoadMUS( filename )
79
+ music = SDL::Mixer.LoadMUS( filename.to_s )
80
80
 
81
81
  if( music.pointer.null? )
82
82
  raise( Rubygame::SDLError, "Could not load Music file '%s': %s"%
@@ -0,0 +1,612 @@
1
+ #--
2
+ # Rubygame -- Ruby code and bindings to SDL to facilitate game creation
3
+ # Copyright (C) 2004-2007 John Croisant
4
+ #
5
+ # This library is free software; you can redistribute it and/or
6
+ # modify it under the terms of the GNU Lesser General Public
7
+ # License as published by the Free Software Foundation; either
8
+ # version 2.1 of the License, or (at your option) any later version.
9
+ #
10
+ # This library is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ # Lesser General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public
16
+ # License along with this library; if not, write to the Free Software
17
+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
+ #++
19
+
20
+ #--
21
+ # Table of Contents:
22
+ #
23
+ # class Rect
24
+ # GENERAL:
25
+ # initialize
26
+ # new_from_object
27
+ # to_s
28
+ # to_a, to_ary
29
+ # []
30
+ # ATTRIBUTES:
31
+ # x, y, w, h [<- accessors]
32
+ # width, height, size
33
+ # left, top, right, bottom
34
+ # center, centerx, centery
35
+ # topleft, topright
36
+ # bottomleft, bottomright
37
+ # midleft, midtop, midright, midbottom
38
+ # UTILITY METHODS:
39
+ # clamp, clamp!
40
+ # clip, clip!
41
+ # collide_hash, collide_hash_all
42
+ # collide_array, collide_array_all
43
+ # collide_point?
44
+ # collide_rect?
45
+ # contain?
46
+ # inflate, inflate!
47
+ # move, move!
48
+ # normalize, normalize!
49
+ # union, union!
50
+ # union_all, union_all!
51
+ #
52
+ # class Surface
53
+ # make_rect
54
+ #
55
+ #++
56
+
57
+ module Rubygame
58
+
59
+ # A Rect is a representation of a rectangle, with four core attributes
60
+ # (x offset, y offset, width, and height) and a variety of functions
61
+ # for manipulating and accessing these attributes.
62
+ #
63
+ # Like all coordinates in Rubygame (and its base library, SDL), x and y
64
+ # offsets are measured from the top-left corner of the screen, with greater
65
+ # y offsets being lower. Thus, specifying the x and y offsets of the Rect
66
+ # is equivalent to setting the location of its top-left corner.
67
+ #
68
+ # In Rubygame, Rects are used for collision detection and describing
69
+ # the area of a Surface to operate on.
70
+ class Rect < Array
71
+
72
+ #--
73
+ # GENERAL
74
+ #++
75
+
76
+ # Create a new Rect, attempting to extract its own information from
77
+ # the given arguments. The arguments must fall into one of these cases:
78
+ #
79
+ # - 4 integers +(x, y, w, h)+.
80
+ # - 1 Rect or Array containing 4 integers +([x, y, w, h])+.
81
+ # - 2 Arrays containing 2 integers each +([x,y], [w,h])+.
82
+ # - 1 object with a +rect+ attribute which is a valid Rect object.
83
+ #
84
+ # All rect core attributes (x,y,w,h) must be integers.
85
+ #
86
+ def initialize(*argv)
87
+ case argv.length
88
+ when 1
89
+ if argv[0].kind_of? Array; super(argv[0])
90
+ elsif argv[0].respond_to? :rect; super(argv[0])
91
+ end
92
+ when 2
93
+ super(argv[0].concat(argv[1]))
94
+ when 4
95
+ super(argv)
96
+ end
97
+ return self
98
+ end
99
+
100
+ # Extract or generate a Rect from the given object, if possible, using the
101
+ # following process:
102
+ #
103
+ # 1. If it's a Rect already, return a duplicate Rect.
104
+ # 2. Elsif it's an Array with at least 4 values, make a Rect from it.
105
+ # 3. Elsif it has a +rect+ attribute., perform (1) and (2) on that.
106
+ # 4. Otherwise, raise TypeError.
107
+ #
108
+ # See also Surface#make_rect()
109
+ def Rect.new_from_object(object)
110
+ case(object)
111
+ when Rect
112
+ return object.dup
113
+ when Array
114
+ if object.length >= 4
115
+ return Rect.new(object)
116
+ else
117
+ raise(ArgumentError,"Array does not have enough indices to be made into a Rect (%d for 4)."%object.length )
118
+ end
119
+ else
120
+ begin
121
+ case(object.rect)
122
+ when Rect
123
+ return object.rect.dup
124
+ when Array
125
+ if object.rect.length >= 4
126
+ return Rect.new(object.rect)
127
+ else
128
+ raise(ArgumentError,"Array does not have enough indices to be made into a Rect (%d for 4)."%object.rect.length )
129
+ end
130
+ end # case object.rect
131
+ rescue NoMethodError # if no rect.rect
132
+ raise(TypeError,"Object must be a Rect or Array [x,y,w,h], or have an attribute called 'rect'. (Got %s instance.)"%object.class)
133
+ end
134
+ end # case object
135
+ end
136
+
137
+
138
+ # Print the Rect in the form "+#<Rect [x,y,w,h]>+"
139
+ def to_s; "#<Rect [%s,%s,%s,%s]>"%self; end
140
+
141
+ # Print the Rect in the form "+#<Rect:id [x,y,w,h]>+"
142
+ def inspect; "#<Rect:#{self.object_id} [%s,%s,%s,%s]>"%self; end
143
+
144
+
145
+ # Returns an SDL::Rect version of this Rect. Float values are
146
+ # rounded to the nearest integer.
147
+ #
148
+ def to_sdl # :nodoc:
149
+ SDL::Rect.new( self.collect{|n| n.round } )
150
+ end
151
+
152
+
153
+ #--
154
+ # ATTRIBUTES
155
+ #++
156
+
157
+ # Returns self.at(0)
158
+ def x; return self.at(0); end
159
+ # Sets self[0] to +val+
160
+ def x=(val); self[0] = val; end
161
+
162
+ alias left x
163
+ alias left= x=;
164
+ alias l x
165
+ alias l= x=;
166
+
167
+ # Returns self.at(1)
168
+ def y; return self.at(1); end
169
+ # Sets self[1] to +val+
170
+ def y=(val); self[1] = val; end
171
+
172
+ alias top y
173
+ alias top= y=;
174
+ alias t y
175
+ alias t= y=;
176
+
177
+ # Returns self.at(2)
178
+ def w; return self.at(2); end
179
+ # Sets self[2] to +val+
180
+ def w=(val); self[2] = val; end
181
+
182
+ alias width w
183
+ alias width= w=;
184
+
185
+ # Returns self.at(3)
186
+ def h; return self.at(3); end
187
+ # Sets self[3] to +val+
188
+ def h=(val); self[3] = val; end
189
+
190
+ alias height h
191
+ alias height= h=;
192
+
193
+ # Return the width and height of the Rect.
194
+ def size; return self[2,2]; end
195
+
196
+ # Set the width and height of the Rect.
197
+ def size=(size)
198
+ raise ArgumentError, "Rect#size= takes an Array of form [width, height]." if size.size != 2
199
+ self[2,2] = size
200
+ size
201
+ end
202
+
203
+ # Return the x coordinate of the right side of the Rect.
204
+ def right; return self.at(0)+self.at(2); end
205
+
206
+ # Set the x coordinate of the right side of the Rect by translating the
207
+ # Rect (adjusting the x offset).
208
+ def right=(r); self[0] = r - self.at(2); return r; end
209
+
210
+ alias r right
211
+ alias r= right=;
212
+
213
+ # Return the y coordinate of the bottom side of the Rect.
214
+ def bottom; return self.at(1)+self.at(3); end
215
+
216
+ # Set the y coordinate of the bottom side of the Rect by translating the
217
+ # Rect (adjusting the y offset).
218
+ def bottom=(b); self[1] = b - self.at(3); return b; end
219
+
220
+ alias b bottom
221
+ alias b= bottom=;
222
+
223
+ # Return the x and y coordinates of the center of the Rect.
224
+ def center; return self.centerx, self.centery; end
225
+
226
+ # Set the x and y coordinates of the center of the Rect by translating the
227
+ # Rect (adjusting the x and y offsets).
228
+ def center=(center)
229
+ raise ArgumentError, "Rect#center= takes an Array of the form [x,y]." if center.size != 2
230
+ self.centerx, self.centery = center
231
+ center
232
+ end
233
+ alias c center
234
+ alias c= center=;
235
+
236
+ # Return the x coordinate of the center of the Rect
237
+ def centerx; return self.at(0)+(self.at(2).div(2)); end
238
+
239
+ # Set the x coordinate of the center of the Rect by translating the
240
+ # Rect (adjusting the x offset).
241
+ def centerx=(x); self[0] = x - (self.at(2).div(2)); return x; end
242
+
243
+ alias cx centerx
244
+ alias cx= centerx=;
245
+
246
+ # Return the y coordinate of the center of the Rect
247
+ def centery; return self.at(1)+(self.at(3).div(2)); end
248
+
249
+ # Set the y coordinate of the center of the Rect by translating the
250
+ # Rect (adjusting the y offset).
251
+ def centery=(y); self[1] = y- (self.at(3).div(2)); return y; end
252
+
253
+ alias cy centery
254
+ alias cy= centery=;
255
+
256
+ # Return the x and y coordinates of the top-left corner of the Rect
257
+ def topleft; return self[0,2].to_a; end
258
+
259
+ # Set the x and y coordinates of the top-left corner of the Rect by
260
+ # translating the Rect (adjusting the x and y offsets).
261
+ def topleft=(topleft)
262
+ raise ArgumentError, "Rect#topright= takes an Array of form [x, y]." if topleft.size != 2
263
+ self[0,2] = topleft
264
+ return topleft
265
+ end
266
+
267
+ alias tl topleft
268
+ alias tl= topleft=;
269
+
270
+ # Return the x and y coordinates of the top-right corner of the Rect
271
+ def topright; return self.right, self.at(1); end
272
+
273
+ # Set the x and y coordinates of the top-right corner of the Rect by
274
+ # translating the Rect (adjusting the x and y offsets).
275
+ def topright=(topright)
276
+ raise ArgumentError, "Rect#topright= takes an Array of form [x, y]." if topright.size != 2
277
+ self.right, self[1] = topright
278
+ return topright
279
+ end
280
+
281
+ alias tr topright
282
+ alias tr= topright=;
283
+
284
+ # Return the x and y coordinates of the bottom-left corner of the Rect
285
+ def bottomleft; return self.at(0), self.bottom; end
286
+
287
+ # Set the x and y coordinates of the bottom-left corner of the Rect by
288
+ # translating the Rect (adjusting the x and y offsets).
289
+ def bottomleft=(bottomleft)
290
+ raise ArgumentError, "Rect#bottomleft= takes an Array of form [x, y]." if bottomleft.size != 2
291
+ self[0], self.bottom = bottomleft
292
+ return bottomleft
293
+ end
294
+
295
+ alias bl bottomleft
296
+ alias bl= bottomleft=;
297
+
298
+ # Return the x and y coordinates of the bottom-right corner of the Rect
299
+ def bottomright; return self.right, self.bottom; end
300
+
301
+ # Set the x and y coordinates of the bottom-right corner of the Rect by
302
+ # translating the Rect (adjusting the x and y offsets).
303
+ def bottomright=(bottomright)
304
+ raise ArgumentError, "Rect#bottomright= takes an Array of form [x, y]." if bottomright.size != 2
305
+ self.right, self.bottom = bottomright
306
+ return bottomright
307
+ end
308
+
309
+ alias br bottomright
310
+ alias br= bottomright=;
311
+
312
+ # Return the x and y coordinates of the midpoint on the left side of the
313
+ # Rect.
314
+ def midleft; return self.at(0), self.centery; end
315
+
316
+ # Set the x and y coordinates of the midpoint on the left side of the Rect
317
+ # by translating the Rect (adjusting the x and y offsets).
318
+ def midleft=(midleft)
319
+ raise ArgumentError, "Rect#midleft= takes an Array of form [x, y]." if midleft.size != 2
320
+ self[0], self.centery = midleft
321
+ return midleft
322
+ end
323
+
324
+ alias ml midleft
325
+ alias ml= midleft=;
326
+
327
+ # Return the x and y coordinates of the midpoint on the left side of the
328
+ # Rect.
329
+ def midtop; return self.centerx, self.at(1); end
330
+
331
+ # Set the x and y coordinates of the midpoint on the top side of the Rect
332
+ # by translating the Rect (adjusting the x and y offsets).
333
+ def midtop=(midtop)
334
+ raise ArgumentError, "Rect#midtop= takes an Array of form [x, y]." if midtop.size != 2
335
+ self.centerx, self[1] = midtop
336
+ return midtop
337
+ end
338
+
339
+ alias mt midtop
340
+ alias mt= midtop=;
341
+
342
+ # Return the x and y coordinates of the midpoint on the left side of the
343
+ # Rect.
344
+ def midright; return self.right, self.centery; end
345
+
346
+ # Set the x and y coordinates of the midpoint on the right side of the Rect
347
+ # by translating the Rect (adjusting the x and y offsets).
348
+ def midright=(midright)
349
+ raise ArgumentError, "Rect#midright= takes an Array of form [x, y]." if midright.size != 2
350
+ self.right, self.centery = midright
351
+ return midright
352
+ end
353
+
354
+ alias mr midright
355
+ alias mr= midright=;
356
+
357
+ # Return the x and y coordinates of the midpoint on the left side of the
358
+ # Rect.
359
+ def midbottom; return self.centerx, self.bottom; end
360
+
361
+ # Set the x and y coordinates of the midpoint on the bottom side of the
362
+ # Rect by translating the Rect (adjusting the x and y offsets).
363
+ def midbottom=(midbottom)
364
+ raise ArgumentError, "Rect#midbottom= takes an Array of form [x, y]." if midbottom.size != 2
365
+ self.centerx, self.bottom = midbottom
366
+ return midbottom
367
+ end
368
+
369
+ alias mb midbottom
370
+ alias mb= midbottom=;
371
+
372
+ #--
373
+ # UTILITY METHODS
374
+ #++
375
+
376
+
377
+ # As #clamp!, but the original caller is not changed.
378
+ def clamp(rect)
379
+ self.dup.clamp!(rect)
380
+ end
381
+
382
+ # Translate the calling Rect to be entirely inside the given Rect. If
383
+ # the caller is too large along either axis to fit in the given rect,
384
+ # it is centered with respect to the given rect, along that axis.
385
+ def clamp!(rect)
386
+ nself = self.normalize
387
+ rect = Rect.new_from_object(rect)
388
+ #If self is inside given, there is no need to move self
389
+ unless rect.contain?(nself)
390
+
391
+ #If self is too wide:
392
+ if nself.at(2) >= rect.at(2)
393
+ self[0] = rect.centerx - nself.at(2).div(2)
394
+ #Else self is not too wide
395
+ else
396
+ #If self is to the left of arg
397
+ if nself.at(0) < rect.at(0)
398
+ self[0] = rect.at(0)
399
+ #If self is to the right of arg
400
+ elsif nself.right > rect.right
401
+ self[0] = rect.right - nself.at(2)
402
+ #Otherwise, leave x alone
403
+ end
404
+ end
405
+
406
+ #If self is too tall:
407
+ if nself.at(3) >= rect.at(3)
408
+ self[1] = rect.centery - nself.at(3).div(2)
409
+ #Else self is not too tall
410
+ else
411
+ #If self is above arg
412
+ if nself.at(1) < rect.at(1)
413
+ self[1] = rect.at(1)
414
+ #If self below arg
415
+ elsif nself.bottom > rect.bottom
416
+ self[1] = rect.bottom - nself.at(3)
417
+ #Otherwise, leave y alone
418
+ end
419
+ end
420
+ end
421
+ return self
422
+ end
423
+
424
+ # As #clip!, but the original caller is not changed.
425
+ def clip(rect)
426
+ self.dup.clip!(rect)
427
+ end
428
+
429
+ # Crop the calling Rect to be entirely inside the given Rect. If the
430
+ # caller does not intersect the given Rect at all, its width and height
431
+ # are set to zero, but its x and y offsets are not changed.
432
+ #
433
+ # As a side effect, the Rect is normalized.
434
+ def clip!(rect)
435
+ nself = self.normalize
436
+ other = Rect.new_from_object(rect).normalize!
437
+ if self.collide_rect?(other)
438
+ self[0] = [nself.at(0), other.at(0)].max
439
+ self[1] = [nself.at(1), other.at(1)].max
440
+ self[2] = [nself.right, other.right].min - self.at(0)
441
+ self[3] = [nself.bottom, other.bottom].min - self.at(1)
442
+ else #if they do not intersect at all:
443
+ self[0], self[1] = nself.topleft
444
+ self[2], self[3] = 0, 0
445
+ end
446
+ return self
447
+ end
448
+
449
+ # Iterate through all key/value pairs in the given hash table, and
450
+ # return the first pair whose value is a Rect that collides with the
451
+ # caller.
452
+ #
453
+ # Because a hash table is unordered, you should not expect any
454
+ # particular Rect to be returned first.
455
+ def collide_hash(hash_rects)
456
+ hash_rects.each { |key,value|
457
+ if value.collide_rect?+(self); return [key,value]; end
458
+ }
459
+ return nil
460
+ end
461
+
462
+ # Iterate through all key/value pairs in the given hash table, and
463
+ # return an Array of every pair whose value is a Rect that collides
464
+ # the caller.
465
+ #
466
+ # Because a hash table is unordered, you should not expect the returned
467
+ # pairs to be in any particular order.
468
+ def collide_hash_all(hash_rects)
469
+ hash_rects.select { |key,value|
470
+ value.collide_rect?+(self)
471
+ }
472
+ end
473
+
474
+ # Iterate through all elements in the given Array, and return
475
+ # the *index* of the first element which is a Rect that collides with
476
+ # the caller.
477
+ def collide_array(array_rects)
478
+ for i in (0...(array_rects.length))
479
+ if array_rects[i].collide_rect?(self)
480
+ return i
481
+ end
482
+ end
483
+ return nil
484
+ end
485
+
486
+ # Iterate through all elements in the given Array, and return
487
+ # an Array containing the *indices* of every element that is a Rect
488
+ # that collides with the caller.
489
+ def collide_array_all(array_rects)
490
+ indexes = []
491
+ for i in (0...(array_rects.length))
492
+ if array_rects[i].collide_rect?(self)
493
+ indexes += [i]
494
+ end
495
+ end
496
+ return indexes
497
+ end
498
+
499
+ # True if the point is inside (including on the border) of the caller.
500
+ # If you have Array of coordinates, you can use collide_point?(*coords).
501
+ def collide_point?(x,y)
502
+ nself = normalize()
503
+ x.between?(nself.left,nself.right) && y.between?(nself.top,nself.bottom)
504
+ end
505
+
506
+ # True if the caller and the given Rect overlap (or touch) at all.
507
+ def collide_rect?(rect)
508
+ nself = self.normalize
509
+ rect = Rect.new_from_object(rect).normalize!
510
+ return ((nself.l >= rect.l && nself.l <= rect.r) or (rect.l >= nself.l && rect.l <= nself.r)) &&
511
+ ((nself.t >= rect.t && nself.t <= rect.b) or (rect.t >= nself.t && rect.t <= nself.b))
512
+ end
513
+
514
+ # True if the given Rect is totally within the caller. Borders may
515
+ # overlap.
516
+ def contain?(rect)
517
+ nself = self.normalize
518
+ rect = Rect.new_from_object(rect).normalize!
519
+ return (nself.left <= rect.left and rect.right <= nself.right and
520
+ nself.top <= rect.top and rect.bottom <= nself.bottom)
521
+ end
522
+
523
+ # As #inflate!, but the original caller is not changed.
524
+ def inflate(x,y)
525
+ return self.class.new(self.at(0) - x.div(2),
526
+ self.at(1) - y.div(2),
527
+ self.at(2) + x,
528
+ self.at(3) + y)
529
+ end
530
+
531
+ # Increase the Rect's size is the x and y directions, while keeping the
532
+ # same center point. For best results, expand by an even number.
533
+ # X and y inflation can be given as an Array or as separate values.
534
+ def inflate!(x,y)
535
+ self[0] -= x.div(2)
536
+ self[1] -= y.div(2)
537
+ self[2] += x
538
+ self[3] += y
539
+ return self
540
+ end
541
+
542
+ # As #move!, but the original caller is not changed.
543
+ def move(x,y)
544
+ self.dup.move!(x,y)
545
+ end
546
+
547
+ # Translate the Rect by the given amounts in the x and y directions.
548
+ # Positive values are rightward for x and downward for y.
549
+ # X and y movement can be given as an Array or as separate values.
550
+ def move!(x,y)
551
+ self[0]+=x; self[1]+=y
552
+ return self
553
+ end
554
+
555
+ # As #normalize!, but the original caller is not changed.
556
+ def normalize
557
+ self.dup.normalize!()
558
+ end
559
+
560
+ # Fix Rects that have negative width or height, without changing the
561
+ # area it represents. Has no effect on Rects with non-negative width
562
+ # and height. Some Rect methods will automatically normalize the Rect.
563
+ def normalize!
564
+ if self.at(2) < 0
565
+ self[0], self[2] = self.at(0)+self.at(2), -self.at(2)
566
+ end
567
+ if self.at(3) < 0
568
+ self[1], self[3] = self.at(1)+self.at(3), -self.at(3)
569
+ end
570
+ self
571
+ end
572
+
573
+ # As #union!, but the original caller is not changed.
574
+ def union(rect)
575
+ self.dup.union!(rect)
576
+ end
577
+
578
+ # Expand the caller to also cover the given Rect. The Rect is still a
579
+ # rectangle, so it may also cover areas that neither of the original
580
+ # Rects did, for example areas between the two Rects.
581
+ def union!(rect)
582
+ self.normalize!
583
+ rleft, rtop = self.topleft
584
+ rright, rbottom = self.bottomright
585
+ r2 = Rect.new_from_object(rect).normalize!
586
+
587
+ rleft = [rleft, r2.left].min
588
+ rtop = [rtop, r2.top].min
589
+ rright = [rright, r2.right].max
590
+ rbottom = [rbottom, r2.bottom].max
591
+
592
+ self[0,4] = rleft, rtop, rright - rleft, rbottom - rtop
593
+ return self
594
+ end
595
+
596
+ # As #union_all!, but the original caller is not changed.
597
+ def union_all(array_rects)
598
+ self.dup.union_all!(array_rects)
599
+ end
600
+
601
+ # Expand the caller to cover all of the given Rects. See also #union!
602
+ def union_all!(array_rects)
603
+ array_rects.each do |r|
604
+ self.union!(r)
605
+ end
606
+ return self
607
+ end
608
+
609
+
610
+ end # class Rect
611
+
612
+ end # module Rubygame
@@ -153,12 +153,73 @@ class Rubygame::Screen < Rubygame::Surface
153
153
 
154
154
 
155
155
 
156
+ # call-seq:
157
+ # new( size, opts={} )
158
+ # new( size, depth=0, flags=[] ) # DEPRECATED
159
+ #
156
160
  # Create a new Rubygame window if there is none, or modify the
157
161
  # existing one. You cannot create more than one Screen; the existing
158
162
  # one will be replaced. (This is a limitation of SDL.)
159
163
  #
160
164
  # Returns the resulting Screen.
161
165
  #
166
+ # size:: Screen size to create, [width, height] (in pixels).
167
+ #
168
+ # opts::
169
+ # Hash of options. The possible options are:
170
+ #
171
+ # :depth:: Requested color depth (in bits per pixel). If this
172
+ # is 0 or unspecified, Rubygame automatically
173
+ # chooses the depth based on the system depth.
174
+ # Possible values: 0, 8, 15, 16, 24, 32. Default: 0.
175
+ #
176
+ # :fullscreen:: If true, use fullscreen mode. If a hardware
177
+ # resolution change is not possible (for whatever
178
+ # reason), the next higher resolution will be used
179
+ # and the display window centered on a black
180
+ # background. Default: false.
181
+ #
182
+ # :resizable:: If true, the user will be able to resize the
183
+ # Rubygame window. When the window is resized, a
184
+ # ResizeEvent or Events::WindowResized event is
185
+ # generated. You should then use Screen.open to
186
+ # re-create the display surface at the new size.
187
+ # Default: false.
188
+ #
189
+ # :noframe:: If true, try to create a window with no title bar
190
+ # or frame decoration. This is automatically true
191
+ # when :fullscreen is true. Default: false.
192
+ #
193
+ # :hardware:: If true, try to create a hardware accelerated
194
+ # Surface (using a graphics card), which may be very
195
+ # fast to blit onto other hardware accelerated
196
+ # Surfaces, but somewhat slower to access in other
197
+ # ways. Creates a normal, non-accelerated Surface if
198
+ # hardware Surfaces are not available. Default:
199
+ # false.
200
+ #
201
+ # :doublebuf:: If true, enable hardware double buffering; only
202
+ # valid when :hardware is true. Calling #flip will
203
+ # switch the buffers and update the screen. All
204
+ # drawing will take place on the surface that is not
205
+ # displayed at the moment. If double buffering could
206
+ # not be enabled then #flip will just update the
207
+ # entire screen. Default: false.
208
+ #
209
+ # :opengl:: If true, create an OpenGL rendering context
210
+ # instead of a normal SDL display. You must set
211
+ # proper OpenGL video attributes with GL#set_attrib
212
+ # before calling this method with this flag. You can
213
+ # then use an OpenGL library (e.g. ruby-opengl) to
214
+ # do all OpenGL-related functions. Please note that
215
+ # you can't blit or draw regular SDL Surfaces onto
216
+ # an OpenGL-mode screen; you must use OpenGL
217
+ # functions. Default: false.
218
+ #
219
+ # For backwards compatibility, you can provide the following
220
+ # arguments instead of the ones above. However, this form is
221
+ # DEPRECATED and will be removed in Rubygame 3.0:
222
+ #
162
223
  # size:: requested window size (in pixels), in the form [width,height]
163
224
  # depth:: requested color depth (in bits per pixel). If 0 (default), the
164
225
  # current system color depth.
@@ -204,7 +265,7 @@ class Rubygame::Screen < Rubygame::Surface
204
265
  # frame decoration.
205
266
  # Fullscreen modes automatically have this flag set.
206
267
  #
207
- def initialize( size, depth=0, flags=[Rubygame::SWSURFACE] )
268
+ def initialize( size, *args )
208
269
 
209
270
  # Cheating a bit. First arg can be a SDL::Surface to wrap it.
210
271
  #
@@ -220,7 +281,41 @@ class Rubygame::Screen < Rubygame::Surface
220
281
  return
221
282
  end
222
283
 
284
+ # Support old argument style for backwards compatibility.
285
+ if args.size > 1 or not args[0].is_a? Hash
286
+ _initialize_old( size, *args )
287
+ return
288
+ end
289
+
290
+ args = _parse_args( size, args[0] )
223
291
 
292
+ @struct = SDL.SetVideoMode( args[:width], args[:height],
293
+ args[:depth], args[:flags] )
294
+
295
+ if( @struct.pointer.null? )
296
+ @struct = nil
297
+ raise( Rubygame::SDLError,
298
+ "Couldn't set [%d x %d] %d bpp video mode: %s"%\
299
+ [args[:width], args[:height], args[:depth], SDL.GetError()] )
300
+ end
301
+ end
302
+
303
+
304
+ def _parse_args( size, options ) # :nodoc:
305
+ args = super
306
+
307
+ flags = args[:flags]
308
+
309
+ flags |= SDL::FULLSCREEN if options[:fullscreen]
310
+ flags |= SDL::RESIZABLE if options[:resizable]
311
+ flags |= SDL::NOFRAME if options[:noframe]
312
+ flags |= SDL::DOUBLEBUF if options[:doublebuf]
313
+ flags |= SDL::OPENGL if options[:opengl]
314
+
315
+ args.merge( :flags => flags )
316
+ end
317
+
318
+ def _initialize_old( size, depth=0, flags=[] ) # :nodoc:
224
319
  w,h = size
225
320
  flags = Rubygame.collapse_flags(flags)
226
321
 
@@ -232,7 +327,6 @@ class Rubygame::Screen < Rubygame::Surface
232
327
  "Couldn't set [%d x %d] %d bpp video mode: %s"%\
233
328
  [w, h, depth, SDL.GetError()] )
234
329
  end
235
-
236
330
  end
237
331
 
238
332
 
@@ -73,7 +73,7 @@ class Rubygame::Sound
73
73
  def load( filename )
74
74
  Rubygame.open_audio
75
75
 
76
- sound = SDL::Mixer.LoadWAV( filename )
76
+ sound = SDL::Mixer.LoadWAV( filename.to_s )
77
77
 
78
78
  if( sound.pointer.null? )
79
79
  raise( Rubygame::SDLError, "Could not load Sound file '%s': %s"%
@@ -48,18 +48,53 @@ class Rubygame::Surface
48
48
  protected :struct
49
49
 
50
50
 
51
- # Create and initialize a new Surface object.
51
+ # call-seq:
52
+ # new( size, opts={} )
53
+ # new( size, depth=0, flags=[] ) # DEPRECATED
54
+ #
55
+ # Create and initialize a new Surface.
52
56
  #
53
- # A Surface is a grid of image data which you blit (i.e. copy) onto other
54
- # Surfaces. Since the Rubygame display is also a Surface (see the Screen
55
- # class), Surfaces can be blit to the screen; this is the most common way
56
- # to display images on the screen.
57
+ # A Surface is a grid of image data which you blit (i.e. copy) onto
58
+ # other Surfaces. Since the Screen is also a Surface, Surfaces can
59
+ # be blit to the screen; this is the most common way to display
60
+ # images on the screen.
57
61
  #
58
62
  # This method may raise SDLError if the SDL video subsystem could
59
63
  # not be initialized for some reason.
60
64
  #
61
65
  # This function takes these arguments:
62
- # size:: requested surface size; an array of the form [width, height].
66
+ #
67
+ # size:: Surface size to create, [width, height] (in pixels).
68
+ #
69
+ # opts::
70
+ # Hash of options. The possible options are:
71
+ #
72
+ # :depth:: Requested color depth (in bits per pixel). If this
73
+ # is 0 or unspecified, Rubygame automatically chooses
74
+ # the depth based on the Screen mode or system depth.
75
+ # Possible values: 0, 8, 15, 16, 24, 32. Default: 0.
76
+ #
77
+ # :alpha:: If true, Surfaces with depth 32 will have an alpha
78
+ # channel (per-pixel transparency). Default: true.
79
+ # (Note: Other depths cannot have an alpha channel.)
80
+ #
81
+ # :hardware:: If true, try to create a hardware accelerated
82
+ # Surface (using a graphics card), which may be very
83
+ # fast to blit onto other hardware accelerated
84
+ # Surfaces, but somewhat slower to access in other
85
+ # ways. Creates a normal, non-accelerated Surface if
86
+ # hardware Surfaces are not available. Default: false.
87
+ #
88
+ # :masks:: For advanced users. Set the Surface's color masks
89
+ # manually, as [r,g,b,a]. If this is nil or
90
+ # unspecified, the color masks are calculated
91
+ # automatically.
92
+ #
93
+ # For backwards compatibility, you can provide the following
94
+ # arguments instead of the ones above. However, this form is
95
+ # DEPRECATED and will be removed in Rubygame 3.0:
96
+ #
97
+ # size:: Surface size to create, [width, height] (in pixels).
63
98
  # depth:: requested color depth (in bits per pixel). If depth is 0 (default),
64
99
  # automatically choose a color depth: either the depth of the Screen
65
100
  # mode (if one has been set), or the greatest color depth available
@@ -80,7 +115,7 @@ class Rubygame::Surface
80
115
  # also enable alpha. as needed. For a description
81
116
  # of alpha, see #alpha.
82
117
  #
83
- def initialize( size, depth=0, flags=[] )
118
+ def initialize( size, *args )
84
119
 
85
120
  # Cheating a bit. First arg can be a SDL::Surface to wrap it.
86
121
  #
@@ -94,6 +129,85 @@ class Rubygame::Surface
94
129
  return
95
130
  end
96
131
 
132
+ # Support old argument style for backwards compatibility.
133
+ if args.size > 1 or not args[0].is_a? Hash
134
+ _initialize_old( size, *args )
135
+ return
136
+ end
137
+
138
+ args = _parse_args( size, args[0] )
139
+
140
+ @struct = SDL.CreateRGBSurface( args[:flags],
141
+ args[:width], args[:height],
142
+ args[:depth], *args[:masks] )
143
+ end
144
+
145
+
146
+ private
147
+
148
+
149
+ def _parse_args( size, options )
150
+ unless size.is_a?(Array) and size.size == 2 and
151
+ size.all?{ |i| i.is_a?(Integer) and i > 0 }
152
+ raise( TypeError, "Invalid size: " + size.inspect +
153
+ " (expected [width,height] array of integers >= 0)" )
154
+ end
155
+
156
+ depth = options[:depth] || 0
157
+ unless depth.is_a?(Integer) and depth >= 0
158
+ raise( TypeError, "Invalid depth: " + depth.inspect +
159
+ " (expected integer >= 0)" )
160
+ end
161
+
162
+ alpha = options.has_key?(:alpha) ? options[:alpha] : true
163
+
164
+ masks = options[:masks]
165
+ if masks.nil?
166
+ masks = _make_masks( depth, alpha )
167
+ else
168
+ unless masks.size == 4 and masks.all?{|m| m.is_a?(Integer) and m >= 0}
169
+ raise( TypeError, "Invalid masks: " + masks.inspect +
170
+ " (expected [r,g,b,a] array of integers >= 0)" )
171
+ end
172
+ end
173
+
174
+ flags = 0
175
+ flags |= SDL::HWSURFACE if options[:hardware]
176
+
177
+ { :width => size[0],
178
+ :height => size[1],
179
+ :depth => depth,
180
+ :masks => masks,
181
+ :flags => flags,
182
+ }
183
+ end
184
+
185
+
186
+ # Calculate color masks based on requested depth and (for 32 bit)
187
+ # whether or not to have an alpha channel.
188
+ def _make_masks( depth, alpha ) # :nodoc:
189
+ a = alpha ? 0xff000000 : 0
190
+
191
+ masks = case depth
192
+ when 32; [0xff0000, 0x00ff00, 0x0000ff, a]
193
+ when 24; [0xff0000, 0x00ff00, 0x0000ff, 0]
194
+ when 16; [0x00f800, 0x0007e0, 0x00001f, 0]
195
+ when 15; [0x007c00, 0x0003e0, 0x00001f, 0]
196
+ else [ 0, 0, 0, 0]
197
+ end
198
+
199
+ if FFI::Platform::BYTE_ORDER == FFI::Platform::BIG_ENDIAN
200
+ masks[0,3] = masks[0,3].reverse
201
+ end
202
+
203
+ masks
204
+ end
205
+
206
+
207
+ # Initialize the Surface in the deprecated (pre-2.7) way.
208
+ def _initialize_old( size, depth=0, flags=[] ) # :nodoc:
209
+ Rubygame.deprecated("Old Surface#new arguments style", "3.0")
210
+
97
211
  unless size.kind_of? Array
98
212
  raise TypeError, "Surface size is not an Array: #{size.inspect}"
99
213
  end
@@ -139,6 +253,8 @@ class Rubygame::Surface
139
253
  end
140
254
 
141
255
 
256
+ public
257
+
142
258
 
143
259
  # Return the width (in pixels) of the surface.
144
260
  #
@@ -515,7 +631,7 @@ class Rubygame::Surface
515
631
 
516
632
  if other.nil?
517
633
  begin
518
- other = Rubygame::ScreenFFI.get_surface
634
+ other = Rubygame::Screen.get_surface
519
635
  rescue Rubygame::SDLError
520
636
  raise( Rubygame::SDLError, "Cannot convert Surface with no target " +
521
637
  "given and no Screen made: #{SDL.GetError()}" )
@@ -601,7 +717,7 @@ class Rubygame::Surface
601
717
  # May raise SDLError if a problem occurs.
602
718
  #
603
719
  def savebmp( filename )
604
- result = SDL.SaveBMP( @struct, filename )
720
+ result = SDL.SaveBMP( @struct, filename.to_s )
605
721
  if(result != 0)
606
722
  raise( Rubygame::SDLError, "Couldn't save surface to file %s: %s"%\
607
723
  [filename, SDL.GetError()] )
@@ -75,7 +75,7 @@ class Rubygame::TTF
75
75
  "You must call TTF.setup before opening a font." )
76
76
  end
77
77
 
78
- @struct = SDL::TTF.OpenFont( file, size )
78
+ @struct = SDL::TTF.OpenFont( file.to_s, size )
79
79
 
80
80
  if( @struct.pointer.null? )
81
81
  raise Rubygame::SDLError, "Could not open font: #{SDL.GetError()}"
@@ -27,7 +27,7 @@ Rubygame::GL.set_attrib(Rubygame::GL::BLUE_SIZE, 5)
27
27
  Rubygame::GL.set_attrib(Rubygame::GL::DEPTH_SIZE, 16)
28
28
  Rubygame::GL.set_attrib(Rubygame::GL::DOUBLEBUFFER, 1)
29
29
 
30
- Rubygame::Screen.open([WIDE,HIGH], 16, [Rubygame::OPENGL])
30
+ Rubygame::Screen.open([WIDE,HIGH], :depth => 16, :opengl => true)
31
31
  queue = Rubygame::EventQueue.new()
32
32
  clock = Rubygame::Clock.new { |c| c.target_framerate = 60 }
33
33
 
@@ -31,7 +31,7 @@ Rubygame::GL.set_attrib(Rubygame::GL::BLUE_SIZE, 5)
31
31
  Rubygame::GL.set_attrib(Rubygame::GL::DEPTH_SIZE, 16)
32
32
  Rubygame::GL.set_attrib(Rubygame::GL::DOUBLEBUFFER, 1)
33
33
 
34
- Rubygame::Screen.open([WIDE,HIGH], 16, [Rubygame::OPENGL])
34
+ Rubygame::Screen.open([WIDE,HIGH], :depth => 16, :opengl => true)
35
35
  queue = Rubygame::EventQueue.new()
36
36
  clock = Rubygame::Clock.new { |c| c.target_framerate = 60 }
37
37
 
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubygame
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.2
4
+ prerelease: false
5
+ segments:
6
+ - 2
7
+ - 6
8
+ - 3
9
+ version: 2.6.3
5
10
  platform: ruby
6
11
  authors:
7
12
  - John Croisant
@@ -9,29 +14,37 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2009-11-12 00:00:00 -06:00
17
+ date: 2010-03-31 00:00:00 -05:00
13
18
  default_executable:
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
21
  name: rake
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
20
24
  requirements:
21
25
  - - ">="
22
26
  - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
29
+ - 7
30
+ - 0
23
31
  version: 0.7.0
24
- version:
32
+ type: :runtime
33
+ version_requirements: *id001
25
34
  - !ruby/object:Gem::Dependency
26
35
  name: ruby-sdl-ffi
27
- type: :runtime
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
30
38
  requirements:
31
39
  - - ">="
32
40
  - !ruby/object:Gem::Version
41
+ segments:
42
+ - 0
43
+ - 1
44
+ - 0
33
45
  version: 0.1.0
34
- version:
46
+ type: :runtime
47
+ version_requirements: *id002
35
48
  description:
36
49
  email: jacius@gmail.com
37
50
  executables: []
@@ -74,6 +87,7 @@ files:
74
87
  - lib/rubygame/mediabag.rb
75
88
  - lib/rubygame/color.rb
76
89
  - lib/rubygame/sprite.rb
90
+ - lib/rubygame/old_rect.rb
77
91
  - lib/rubygame/event_triggers.rb
78
92
  - lib/rubygame/music.rb
79
93
  - lib/rubygame/surface.rb
@@ -145,14 +159,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
145
159
  requirements:
146
160
  - - ">="
147
161
  - !ruby/object:Gem::Version
162
+ segments:
163
+ - 1
164
+ - 8
148
165
  version: "1.8"
149
- version:
150
166
  required_rubygems_version: !ruby/object:Gem::Requirement
151
167
  requirements:
152
168
  - - ">="
153
169
  - !ruby/object:Gem::Version
170
+ segments:
171
+ - 0
154
172
  version: "0"
155
- version:
156
173
  requirements:
157
174
  - SDL >= 1.2.7
158
175
  - SDL_gfx >= 2.0.10 (optional)
@@ -160,7 +177,7 @@ requirements:
160
177
  - SDL_mixer >= 1.2.7 (optional)
161
178
  - SDL_ttf >= 2.0.6 (optional)
162
179
  rubyforge_project: rubygame
163
- rubygems_version: 1.3.5
180
+ rubygems_version: 1.3.6
164
181
  signing_key:
165
182
  specification_version: 3
166
183
  summary: Clean and powerful library for game programming