Guest User

Untitled

a guest
Feb 29th, 2020
13,920
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. #:kivy 1.11.1
  2.  
  3. # Тут нарисуем наш шарик, называем этот объект точно также как и класс в коде
  4. <PongBall>:
  5. size: 50, 50
  6.  
  7. canvas:
  8. Ellipse:
  9. pos: self.pos
  10. size: self.size
  11.  
  12. # Тут нарисуем панельку игрока, называем этот объект точно также как и класс в коде
  13. <PongPaddle>:
  14. size: 25, 200
  15. canvas:
  16. Rectangle:
  17. pos: self.pos
  18. size: self.size
  19.  
  20. # А это игровое поле =)
  21. <PongGame>:
  22. ## тут привязываем шарик к свойству ball
  23. ball: pong_ball
  24. player1: player_left
  25. player2: player_right
  26.  
  27. canvas:
  28. Rectangle:
  29. ## Бордюр посередине
  30. pos: self.center_x - 5, 0
  31. size: 10, self.height
  32.  
  33. Label:
  34. ## Очки игрока слева
  35. font_size: 70
  36. center_x: root.width / 4
  37. top: root.top - 50
  38. text: str(root.player1.score)
  39.  
  40. Label:
  41. ## Очки игрока справа
  42. font_size: 70
  43. center_x: root.width * 3 / 4
  44. top: root.top - 50
  45. text: str(root.player2.score)
  46.  
  47. ## а тут создаем экземпляр нашего шарика в игровом поле
  48. PongBall:
  49. id: pong_ball
  50. center: self.parent.center
  51.  
  52. ## создаем игрока 1
  53. PongPaddle:
  54. id: player_left
  55. x: root.x
  56. center_y: root.center_y
  57.  
  58. ## создаем игрока 2
  59. PongPaddle:
  60. id: player_right
  61. x: root.width - self.width
  62. center_y: root.center_y
Add Comment
Please, Sign In to add comment