Guest User

Untitled

a guest
Feb 21st, 2018
281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. #Copyright (C) 2006 by Han Dao
  2. # This program is free software; you can redistribute it and/or modify
  3. # it under the terms of the GNU General Public License as published by
  4. # the Free Software Foundation; either version 2 of the License, or
  5. # (at your option) any later version.
  6.  
  7. # This program is distributed in the hope that it will be useful,
  8. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. # GNU General Public License for more details.
  11. #
  12. # You should have received a copy of the GNU General Public License
  13. # along with this program; if not, write to the Free Software
  14. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  15.  
  16. #This is the game SpaceAceFighter
  17. #You can contact the author at wikipediankiba@gmail.com
  18. class CollideDetector
  19. def initialize weapon , fighter , enemy
  20. @weapon = weapon
  21. @fighter = fighter
  22. @enemy = enemy
  23. end
  24. def detect
  25. weapon = @weapon.return
  26. fighter = @fighter.return
  27. weapon.each do |rect|
  28. if rect.collide_rect?(fighter)
  29. return false
  30. end
  31. end
  32. enemy(weapon)
  33. end
  34. def enemy weapon
  35. collide = 0
  36. enemy = @enemy.return(true)
  37. weapon.zip(enemy).each do |rect,enemy|
  38. if rect.collide_rect?(enemy)
  39. pop(collide)
  40. end
  41. collide += 1
  42. end
  43. end
  44. def pop collide
  45. @enemy.pop(collide)
  46. end
  47. end
Add Comment
Please, Sign In to add comment