Advertisement
OtsoSilver

Untitled

Sep 5th, 2021
1,011
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 5.86 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.  
  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.    
  63.     elif mode == 'collection':
  64.         fon.draw()
  65.         screen.draw.text(count, center=(30, 20), color="white", fontsize = 36)
  66.         cross.draw()
  67.         screen.draw.text('+2$', center=(120, 300), color="white", fontsize = 36)
  68.         screen.draw.text('+4$', center=(300, 300), color="white", fontsize = 36)
  69.         for anim in animals:
  70.             anim.draw()
  71.  
  72.  
  73.  
  74. def for_bonus_1():
  75.     global count
  76.     count += 1
  77.  
  78. def for_bonus_2():
  79.     global count
  80.     count += 15
  81.  
  82. def for_bonus_3():
  83.     global count
  84.     count += 50
  85.  
  86. def on_mouse_down(button, pos):
  87.     global count
  88.     global mode
  89.     global price_1, price_2, price_3, click, animals
  90.     if button == mouse.LEFT and mode == 'game':
  91.         # Клик по объекту animal
  92.         if animal.collidepoint(pos):
  93.             count += click
  94.             animal.y = 200
  95.             animate(animal, tween='bounce_end', duration=0.5, y=250)
  96.         # Клик по кнопке bonus_1  
  97.         elif bonus_1.collidepoint(pos):
  98.             bonus_1.y = 105
  99.             animate(bonus_1, tween='bounce_end', duration=0.5, y=100)
  100.             if count >= price_1:
  101.                 schedule_interval(for_bonus_1, 2)
  102.                 count -= price_1
  103.                 price_1 *= 2
  104.         # Клик по кнопке bonus_2  
  105.         elif bonus_2.collidepoint(pos):
  106.             bonus_2.y = 205
  107.             animate(bonus_2, tween='bounce_end', duration=0.5, y=200)
  108.             if count >= price_2:
  109.                 schedule_interval(for_bonus_2, 2)
  110.                 count -= price_2
  111.                 price_2 *= 2
  112.         # Клик по кнопке bonus_3
  113.         elif bonus_3.collidepoint(pos):
  114.             bonus_3.y = 305
  115.             animate(bonus_3, tween='bounce_end', duration=0.5, y=300)
  116.             if count >= price_3:
  117.                 schedule_interval(for_bonus_3, 2)
  118.                 count -= price_3
  119.                 price_3 *= 2
  120.         elif cross.collidepoint(pos):
  121.             mode = 'menu'
  122.    
  123.     # Режим меню
  124.     elif mode == 'menu' and button == mouse.LEFT:
  125.         if play.collidepoint(pos):
  126.             mode = 'game'
  127.         if shop.collidepoint(pos):
  128.             mode = 'shop'
  129.         if collection.collidepoint(pos):
  130.             mode = 'collection'
  131.            
  132.            
  133.     elif mode == 'shop' and button == mouse.LEFT:
  134.         if cross.collidepoint(pos):
  135.             mode = 'menu'
  136.         if crocodile.collidepoint(pos):
  137.             if crocodile in animals:
  138.                 animal.image = 'crocodile'
  139.             else:
  140.                 crocodile.y = 205
  141.                 animate(crocodile, tween='bounce_end', duration=0.5, y=200)
  142.                 if count >= 500:
  143.                     count -= 500
  144.                     animal.image = 'crocodile'
  145.                     click = 2
  146.                     animals.append(crocodile)
  147.         if hippo.collidepoint(pos):
  148.             if hippo in animals:
  149.                 animal.image = 'hippo'
  150.             else:
  151.                 hippo.y = 205
  152.                 animate(hippo, tween='bounce_end', duration=0.5, y=200)
  153.                 if count >= 2500:
  154.                     count -= 2500
  155.                     animal.image = 'hippo'
  156.                     click = 4
  157.                     animals.append(hippo)
  158.     elif mode == 'collection' and button == mouse.LEFT:
  159.         if cross.collidepoint(pos):
  160.             mode = 'menu'
  161.         if crocodile.collidepoint(pos):
  162.             if crocodile in animals:
  163.                 crocodile.y = 205
  164.                 animate(crocodile, tween='bounce_end', duration=0.5, y=200)
  165.                 animal.image = 'crocodile'
  166.         if hippo.collidepoint(pos):
  167.             if hippo in animals:
  168.                 hippo.y = 205
  169.                 animate(hippo, tween='bounce_end', duration=0.5, y=200)
  170.                 animal.image = 'hippo'
  171.        
  172.        
  173.        
  174.        
  175.        
  176.        
  177.        
  178.        
  179.        
  180.        
  181.        
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement