Advertisement
OtsoSilver

Untitled

Sep 11th, 2021
705
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.22 KB | None | 0 0
  1. #pgzero
  2.  
  3. WIDTH = 600
  4. HEIGHT = 400
  5.  
  6. TITLE = "Animal clicker"
  7. FPS = 30
  8.  
  9. # Объекты
  10. animal = Actor("giraffe", (150, 250))
  11. fon = Actor("fon")
  12. bonus_1 = Actor("bonus", (450, 100))
  13. bonus_2 = Actor("bonus", (450, 200))
  14. bonus_3 = Actor("bonus", (450, 300))
  15. play = Actor("play", (300, 100))
  16. cross = Actor("cross", (580, 20))
  17. shop = Actor("shop", (300, 200))
  18. collection = Actor("collection", (300, 300))
  19.  
  20. # Переменные
  21. count = 0
  22. click = 1
  23. mode = 'menu'
  24. price_1 = 15
  25. price_2 = 200
  26. price_3 = 600
  27.  
  28. def draw():
  29.     if mode == 'menu':
  30.         fon.draw()
  31.         play.draw()
  32.         screen.draw.text(count, center=(30, 20), color="white", fontsize = 36)
  33.         shop.draw()
  34.         collection.draw()
  35.    
  36.     elif mode == 'game':    
  37.         fon.draw()
  38.         animal.draw()
  39.         screen.draw.text(count, center=(150, 100), color="white", fontsize = 96)
  40.         bonus_1.draw()
  41.         screen.draw.text("+1$ каждые 2с", center=(450, 80), color="black", fontsize = 20)
  42.         screen.draw.text(price_1, center=(450, 110), color="black", fontsize = 20)
  43.         bonus_2.draw()
  44.         screen.draw.text("+15$ каждые 2с", center=(450, 180), color="black", fontsize = 20)
  45.         screen.draw.text(price_2, center=(450, 210), color="black", fontsize = 20)
  46.         bonus_3.draw()
  47.         screen.draw.text("+50$ каждые 2с", center=(450, 280), color="black", fontsize = 20)
  48.         screen.draw.text(price_3, center=(450, 310), color="black", fontsize = 20)
  49.         cross.draw()
  50.  
  51. def for_bonus_1():
  52.     global count
  53.     count += 1
  54.  
  55. def for_bonus_2():
  56.     global count
  57.     count += 15
  58.  
  59. def for_bonus_3():
  60.     global count
  61.     count += 50
  62.  
  63. def on_mouse_down(button, pos):
  64.     global count
  65.     global mode
  66.     global price_1, price_2, price_3
  67.     if button == mouse.LEFT and mode == 'game':
  68.         # Клик по объекту animal
  69.         if animal.collidepoint(pos):
  70.             count += click
  71.             animal.y = 200
  72.             animate(animal, tween='bounce_end', duration=0.5, y=250)
  73.         # Клик по кнопке bonus_1  
  74.         elif bonus_1.collidepoint(pos):
  75.             bonus_1.y = 105
  76.             animate(bonus_1, tween='bounce_end', duration=0.5, y=100)
  77.             if count >= price_1:
  78.                 schedule_interval(for_bonus_1, 2)
  79.                 count -= price_1
  80.                 price_1 *= 2
  81.         # Клик по кнопке bonus_2  
  82.         elif bonus_2.collidepoint(pos):
  83.             bonus_2.y = 205
  84.             animate(bonus_2, tween='bounce_end', duration=0.5, y=200)
  85.             if count >= price_2:
  86.                 schedule_interval(for_bonus_2, 2)
  87.                 count -= price_2
  88.                 price_2 *= 2
  89.         # Клик по кнопке bonus_3
  90.         elif bonus_3.collidepoint(pos):
  91.             bonus_3.y = 305
  92.             animate(bonus_3, tween='bounce_end', duration=0.5, y=300)
  93.             if count >= price_3:
  94.                 schedule_interval(for_bonus_3, 2)
  95.                 count -= price_3
  96.                 price_3 *= 2
  97.         elif cross.collidepoint(pos):
  98.             mode = 'menu'
  99.    
  100.     # Режим меню
  101.     elif mode == 'menu' and button == mouse.LEFT:
  102.         if play.collidepoint(pos):
  103.             mode = 'game'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement