OtsoSilver

Untitled

Aug 29th, 2021
1,177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.80 KB | None | 0 0
  1. #pgzero
  2.  
  3. WIDTH = 600
  4. HEIGHT = 400
  5.  
  6. TITLE = "Animal clicker"
  7. FPS = 30
  8. # Объекты
  9. animal = Actor("giraffe", (150, 250))
  10. fon = Actor("fon")
  11. bonus1 = Actor('bonus', (450, 100))
  12. bonus2 = Actor('bonus', (450, 200))
  13. # Переменные
  14. count = 0
  15. click = 1
  16. bonus1_price = 15
  17. bonus2_price = 200
  18. def draw():
  19.     fon.draw()
  20.     animal.draw()
  21.     screen.draw.text(count, color = 'white', center = (150,100), fontsize= 96)
  22.     bonus1.draw()
  23.     screen.draw.text("+1$ каждые 2с", center=(450, 80), color="black", fontsize = 20)
  24.     screen.draw.text("цена: " + str(bonus1_price) + "$", center=(450, 110), color="black", fontsize = 20)
  25.     bonus2.draw()
  26.     screen.draw.text("+15$ каждые 2с", center=(450, 180), color="black", fontsize = 20)
  27.     screen.draw.text("цена: " + str(bonus2_price) + "$", center=(450, 210), color="black", fontsize = 20)
  28.  
  29. def for_bonus1():
  30.     global count
  31.     count+=1
  32. def for_bonus2():
  33.     global count
  34.     count+=15    
  35.    
  36. def on_mouse_down(button,pos):
  37.     global count, bonus1_price,bonus2_price
  38.     if button == mouse.LEFT:
  39.         if animal.collidepoint(pos):
  40.             count += click
  41.             animal.y = 200
  42.             animate(animal, tween='bounce_end', duration=0.5, y=250)
  43.         if bonus1.collidepoint(pos):
  44.             if count >= bonus1_price:
  45.                 count -= bonus1_price
  46.                 schedule_interval(for_bonus1, 2)
  47.                 bonus1_price *= 2
  48.         if bonus2.collidepoint(pos):
  49.             if count >= bonus2_price:
  50.                 count -= bonus2_price
  51.                 schedule_interval(for_bonus2, 2)
  52.                 bonus1_price *= 2
  53.            
  54.            
  55.            
  56.            
  57.            
  58.            
  59.            
  60.            
  61.            
  62.            
  63.            
  64.            
Advertisement
Add Comment
Please, Sign In to add comment