Advertisement
OtsoSilver

Untitled

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