Skip to content

Commit

Permalink
[Patch 1758611] Daniel Neis Araújo's Sprite#undraw patch.
Browse files Browse the repository at this point in the history
  • Loading branch information
jacius committed Jul 29, 2007
1 parent e7a949a commit 7f708e2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
7 changes: 6 additions & 1 deletion CREDITS
Expand Up @@ -35,6 +35,11 @@
Date:: received 2007-03-04; applied 2007-04-13 (r235).

- <b>Johan Berntsson</b>
Email:: johan@microheaven.com
Email:: johan at microheaven.com
Contribution:: Patch to add Mixer::Music class (music playback).
Date:: 2007-04-27 (r304).

- <b>Daniel Neis Araujo</b> / danielneis
Email:: danielneis at gmail.com
Contribution:: Patch to add Sprite#undraw (based on UpdateGroup#undraw).
Date:: 2007-07-29 (r460).
16 changes: 14 additions & 2 deletions lib/rubygame/sprite.rb
Expand Up @@ -197,6 +197,19 @@ def remove(*groups)
}
end


# call-seq: undraw(surface, background) -> Rect
#
# 'Erase' the sprite from +surface+ by drawing over it with part of
# +background+. For best results, +background+ should be the same size
# as +surface+.
#
# Returns a Rect representing the area of +surface+ which was affected.
#
def undraw(dest, background)
background.blit(dest, @rect, @rect)
end

# This method is meant to be overwritten by Sprite-based classes to
# define meaningful behavior. It can take any number of arguments you
# want, be called however often you want, and do whatever you want.
Expand Down Expand Up @@ -369,8 +382,7 @@ def draw(dest)
# over).
def undraw(dest,background)
self.each { |sprite|
background.blit(dest,sprite.rect,sprite.rect)
@dirty_rects.push(sprite.rect.dup)
@dirty_rects.push( sprite.undraw(dest, background) )
}
end
end # module UpdateGroup
Expand Down

0 comments on commit 7f708e2

Please sign in to comment.