Advertisement
OtsoSilver

Untitled

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