Permalink
Browse files

fix collide_rect to work with arrays

  • Loading branch information...
1 parent e77a3a7 commit 886ce36d651b2932fced9feb739ea88092550826 @shawn42 committed Jul 1, 2014
Showing with 3 additions and 4 deletions.
  1. +3 −4 lib/gamebox/lib/rect.rb
View
@@ -498,10 +498,9 @@ def collide_point?(x,y)
# True if the caller and the given Rect overlap (or touch) at all.
def collide_rect?(rect)
- nself = self #.normalize
- rect = Rect.new_from_object(rect)#.normalize!
- return ((nself.l >= rect.l && nself.l <= rect.r) or (rect.l >= nself.l && rect.l <= nself.r)) &&
- ((nself.t >= rect.t && nself.t <= rect.b) or (rect.t >= nself.t && rect.t <= nself.b))
+ rect = Rect.new_from_object(rect)
+ ((l >= rect.l && l <= rect.r) or (rect.l >= l && rect.l <= r)) &&
+ ((t >= rect.t && t <= rect.b) or (rect.t >= t && rect.t <= b))
end
# True if the given Rect is totally within the caller. Borders may

0 comments on commit 886ce36

Please sign in to comment.