OtsoSilver

Untitled

Sep 26th, 2021
884
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.     elif mode == 'shop':
  51.         fon.draw()
  52.  
  53.  
  54.  
  55. def for_bonus_1():
  56.     global count
  57.     count += 1
  58.  
  59. def for_bonus_2():
  60.     global count
  61.     count += 15
  62.  
  63. def for_bonus_3():
  64.     global count
  65.     count += 50
  66.  
  67. def on_mouse_down(button, pos):
  68.     global count
  69.     global mode
  70.     global price_1, price_2, price_3
  71.     if button == mouse.LEFT and mode == 'game':
  72.         # Клик по объекту animal
  73.         if animal.collidepoint(pos):
  74.             count += click
  75.             animal.y = 200
  76.             animate(animal, tween='bounce_end', duration=0.5, y=250)
  77.         # Клик по кнопке bonus_1  
  78.         elif bonus_1.collidepoint(pos):
  79.             bonus_1.y = 105
  80.             animate(bonus_1, tween='bounce_end', duration=0.5, y=100)
  81.             if count >= price_1:
  82.                 schedule_interval(for_bonus_1, 2)
  83.                 count -= price_1
  84.                 price_1 *= 2
  85.         # Клик по кнопке bonus_2  
  86.         elif bonus_2.collidepoint(pos):
  87.             bonus_2.y = 205
  88.             animate(bonus_2, tween='bounce_end', duration=0.5, y=200)
  89.             if count >= price_2:
  90.                 schedule_interval(for_bonus_2, 2)
  91.                 count -= price_2
  92.                 price_2 *= 2
  93.         # Клик по кнопке bonus_3
  94.         elif bonus_3.collidepoint(pos):
  95.             bonus_3.y = 305
  96.             animate(bonus_3, tween='bounce_end', duration=0.5, y=300)
  97.             if count >= price_3:
  98.                 schedule_interval(for_bonus_3, 2)
  99.                 count -= price_3
  100.                 price_3 *= 2
  101.         elif cross.collidepoint(pos):
  102.             mode = 'menu'
  103.    
  104.     # Режим меню
  105.     elif mode == 'menu' and button == mouse.LEFT:
  106.         if play.collidepoint(pos):
  107.             mode = 'game'
RAW Paste Data