Advertisement
OtsoSilver

Untitled

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