Advertisement
OtsoSilver

Untitled

Sep 11th, 2021
686
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 5.27 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. crocodile = Actor('crocodile', (120, 200))
  20. hippo = Actor('hippo', (300, 200))
  21. animals = []
  22. # Переменные
  23. count = +99999
  24. click = 1
  25. mode = 'menu'
  26. price_1 = 15
  27. price_2 = 200
  28. price_3 = 600
  29.  
  30. def draw():
  31.     if mode == 'menu':
  32.         fon.draw()
  33.         play.draw()
  34.         screen.draw.text(count, center=(30, 20), color="white", fontsize = 36)
  35.         shop.draw()
  36.         collection.draw()
  37.    
  38.     elif mode == 'game':    
  39.         fon.draw()
  40.         animal.draw()
  41.         screen.draw.text(count, center=(150, 100), color="white", fontsize = 96)
  42.         bonus_1.draw()
  43.         screen.draw.text("+1$ каждые 2с", center=(450, 80), color="black", fontsize = 20)
  44.         screen.draw.text(price_1, center=(450, 110), color="black", fontsize = 20)
  45.         bonus_2.draw()
  46.         screen.draw.text("+15$ каждые 2с", center=(450, 180), color="black", fontsize = 20)
  47.         screen.draw.text(price_2, center=(450, 210), color="black", fontsize = 20)
  48.         bonus_3.draw()
  49.         screen.draw.text("+50$ каждые 2с", center=(450, 280), color="black", fontsize = 20)
  50.         screen.draw.text(price_3, center=(450, 310), color="black", fontsize = 20)
  51.         cross.draw()
  52.    
  53.     elif mode == 'shop':
  54.         fon.draw()
  55.         cross.draw()
  56.         screen.draw.text(count, center=(30, 20), color="white", fontsize = 36)
  57.         crocodile.draw()
  58.         screen.draw.text("500$", center=(120, 300), color="white", fontsize = 36)
  59.         hippo.draw()
  60.         screen.draw.text("2500$", center=(300, 300), color="white", fontsize = 36)
  61.    
  62.     elif mode == 'collection':
  63.         fon.draw()
  64.         cross.draw()
  65.         screen.draw.text(count, center=(30, 20), color="white", fontsize = 36)
  66.         screen.draw.text("+2$", center=(120, 300), color="white", fontsize = 36)
  67.         screen.draw.text("+4$", center=(300, 300), color="white", fontsize = 36)
  68.         for anim in animals:
  69.             anim.draw()
  70.  
  71.        
  72.  
  73.  
  74.  
  75. def for_bonus_1():
  76.     global count
  77.     count += 1
  78.  
  79. def for_bonus_2():
  80.     global count
  81.     count += 15
  82.  
  83. def for_bonus_3():
  84.     global count
  85.     count += 50
  86.  
  87. def on_mouse_down(button, pos):
  88.     global count, click, animals
  89.     global mode
  90.     global price_1, price_2, price_3
  91.     if button == mouse.LEFT and mode == 'game':
  92.         # Клик по объекту animal
  93.         if animal.collidepoint(pos):
  94.             count += click
  95.             animal.y = 200
  96.             animate(animal, tween='bounce_end', duration=0.5, y=250)
  97.         # Клик по кнопке bonus_1  
  98.         elif bonus_1.collidepoint(pos):
  99.             bonus_1.y = 105
  100.             animate(bonus_1, tween='bounce_end', duration=0.5, y=100)
  101.             if count >= price_1:
  102.                 schedule_interval(for_bonus_1, 2)
  103.                 count -= price_1
  104.                 price_1 *= 2
  105.         # Клик по кнопке bonus_2  
  106.         elif bonus_2.collidepoint(pos):
  107.             bonus_2.y = 205
  108.             animate(bonus_2, tween='bounce_end', duration=0.5, y=200)
  109.             if count >= price_2:
  110.                 schedule_interval(for_bonus_2, 2)
  111.                 count -= price_2
  112.                 price_2 *= 2
  113.         # Клик по кнопке bonus_3
  114.         elif bonus_3.collidepoint(pos):
  115.             bonus_3.y = 305
  116.             animate(bonus_3, tween='bounce_end', duration=0.5, y=300)
  117.             if count >= price_3:
  118.                 schedule_interval(for_bonus_3, 2)
  119.                 count -= price_3
  120.                 price_3 *= 2
  121.         elif cross.collidepoint(pos):
  122.             mode = 'menu'
  123.    
  124.     # Режим меню
  125.     elif mode == 'menu' and button == mouse.LEFT:
  126.         if play.collidepoint(pos):
  127.             mode = 'game'
  128.         if shop.collidepoint(pos):
  129.             mode = 'shop'
  130.         if collection.collidepoint(pos):
  131.             mode = 'collection'
  132.     elif mode == 'shop' and button == mouse.LEFT:
  133.         if cross.collidepoint(pos):
  134.             mode = 'menu'
  135.         elif crocodile.collidepoint(pos):
  136.             if crocodile in animals:
  137.                 animal.image = 'crocodile'
  138.             elif count >= 500:
  139.                 crocodile.y = 205
  140.                 animate(crocodile, tween='bounce_end', duration=0.5, y=200)
  141.                 count -= 500
  142.                 animal.image = 'crocodile'
  143.                 click = 2
  144.                 animals.append(crocodile)
  145.         elif hippo.collidepoint(pos):
  146.             if hippo in animals:
  147.                 animal.image = 'hippo'
  148.             elif count >= 2500:
  149.                 hippo.y = 205
  150.                 animate(hippo, tween='bounce_end', duration=0.5, y=200)
  151.                 count -= 2500
  152.                 animal.image = 'hippo'
  153.                 click = 4
  154.                 animals.append(hippo)
  155.     elif mode == 'collection' and button == mouse.LEFT:
  156.         if cross.collidepoint(pos):
  157.             mode = 'menu'
  158.            
  159.            
  160.            
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement