Skip to content

Commit

Permalink
Fixed minor logic mistake in Surface.new.
Browse files Browse the repository at this point in the history
  • Loading branch information
jacius committed Feb 9, 2011
1 parent 18ae0e6 commit 4413df6
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/rubygame/surface.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,7 @@ def initialize( size, *args )
@opacity ||= @struct.format.alpha / 255.0
end
else
# Support old argument style for backwards compatibility.
if args.size > 1 or not args[0].is_a? Hash
_initialize_old( size, *args )
@opacity ||= @struct.format.alpha / 255.0
else
if args.empty? or args[0].is_a? Hash
args = _parse_args( size, args[0] )
@struct = SDL.CreateRGBSurface( args[:flags],
args[:width], args[:height],
Expand All @@ -147,6 +143,10 @@ def initialize( size, *args )
else
@opacity ||= @struct.format.alpha / 255.0
end
else
# Support old argument style for backwards compatibility.
_initialize_old( size, *args )
@opacity ||= @struct.format.alpha / 255.0
end
end

Expand Down Expand Up @@ -179,6 +179,8 @@ def clone


def _parse_args( size, options )
options ||= {}

unless size.is_a?(Array) and size.size == 2 and
size.all?{ |i| i.is_a?(Integer) and i > 0 }
raise( TypeError, "Invalid size: " + size.inspect +
Expand Down

0 comments on commit 4413df6

Please sign in to comment.