OtsoSilver

Untitled

Sep 4th, 2021
1,415
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.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. play = Actor('play', (300, 100))
  15. # Переменные
  16. count = 0
  17. click = 1
  18. mode = 'menu'
  19. price_bonus_1 = 15
  20. price_bonus_2 = 200
  21. bonus_1_val = 1
  22. bonus_2_val = 15
  23. def draw():
  24.     fon.draw()
  25.     if mode == 'game':
  26.         animal.draw()
  27.         screen.draw.text(count,color='white', center = (150,100), fontsize=96)
  28.         bonus_1.draw()
  29.         screen.draw.text("+"+str(bonus_1_val)+"$ каждые 2с", center=(450, 80), color="black", fontsize = 20)
  30.         screen.draw.text("цена: "+str(price_bonus_1)+"$", center=(450, 110), color="black",
  31.                                                                                 fontsize = 20)
  32.         bonus_2.draw()
  33.         screen.draw.text("+"+str(bonus_2_val)+"$ каждые 2с", center=(450, 180), color="black", fontsize = 20)
  34.         screen.draw.text("цена: "+str(price_bonus_2)+"$", center=(450, 210), color="black",                                                                      fontsize = 20)
  35.     if mode == 'menu':  
  36.         play.draw()
  37.         screen.draw.text(count,color='white', center = (20,20), fontsize=24)
  38.  
  39.  
  40. def for_bonus_1():
  41.    
  42.     global count
  43.     count+=bonus_1_val
  44.    
  45. def for_bonus_2():
  46.     global count
  47.     count+=bonus_2_val
  48.    
  49. def on_mouse_down(button, pos):
  50.     global count, price_bonus_1,price_bonus_2, bonus_2_val,bonus_1_val
  51.    
  52.     if button == mouse.LEFT:
  53.         if animal.collidepoint(pos):
  54.             count+=click
  55.             animal.y = 200
  56.             animate(animal, tween='bounce_end', duration=0.5, y=250)
  57.         if bonus_1.collidepoint(pos):
  58.             if count >= price_bonus_1:
  59.                 count -= price_bonus_1
  60.                 schedule_interval(for_bonus_1, 2)
  61.                 price_bonus_1 *=4
  62.                 bonus_1_val *=2
  63.         if bonus_2.collidepoint(pos):
  64.             if count >= price_bonus_2:
  65.                 count -= price_bonus_2
  66.                 schedule_interval(for_bonus_2, 2)
  67.                 price_bonus_2 *=4
  68.                 bonus_2_val *=2
  69.                
  70.            
  71.            
  72.            
Advertisement
Add Comment
Please, Sign In to add comment