OtsoSilver

Untitled

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