Guest User

Untitled

a guest
Feb 21st, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. class Weapon
  2. def initialize
  3. @image = Rubygame::Image.load("rocket.png")
  4. @rect = []
  5. @status = []
  6. end
  7. def generate x , y , status
  8. @rect << Rect.new(x,y,*@image.size)
  9. @status << status
  10. end
  11. def movement
  12. @rect.zip(@status).each do |pos,move|
  13. if move == true
  14. pos.centery -= 3
  15. if pos.centery <= 0
  16. pos.pop()
  17. move.pop()
  18. end
  19. else
  20. pos.centery += 3
  21. if pos.centery >= 600
  22. pos.pop()
  23. move.pop()
  24. end
  25. end
  26. end
  27. end
  28. def draw screen
  29. @rect.each do |rect|
  30. @image.blit(screen,[rect.centerx,rect.centery])
  31. end
  32. end
  33. end
Add Comment
Please, Sign In to add comment