OtsoSilver

Untitled

Aug 29th, 2021
1,281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.11 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. play = Actor('play', (300, 100))
  14. # Переменные
  15. count = 0
  16. click = 1
  17. bonus1_price = 15
  18. bonus2_price = 200
  19. mode = 'menu'
  20. def draw():
  21.     fon.draw()
  22.     if mode == 'game':
  23.         animal.draw()
  24.         screen.draw.text(count, color = 'white', center = (150,100), fontsize= 96)
  25.         bonus1.draw()
  26.         screen.draw.text("+1$ каждые 2с", center=(450, 80), color="black", fontsize = 20)
  27.         screen.draw.text("цена: " + str(bonus1_price) + "$", center=(450, 110), color="black", fontsize = 20)
  28.         bonus2.draw()
  29.         screen.draw.text("+15$ каждые 2с", center=(450, 180), color="black", fontsize = 20)
  30.         screen.draw.text("цена: " + str(bonus2_price) + "$", center=(450, 210), color="black", fontsize = 20)
  31.     elif mode == 'menu':
  32.         screen.draw.text(count, color = 'white', center = (20,20), fontsize=20)
  33.  
  34.         play.draw()
  35.        
  36. def for_bonus1():
  37.     global count
  38.     count+=1
  39. def for_bonus2():
  40.     global count
  41.     count+=15    
  42.    
  43. def on_mouse_down(button,pos):
  44.     global count, bonus1_price,bonus2_price, mode
  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 bonus1.collidepoint(pos):
  51.             if count >= bonus1_price:
  52.                 count -= bonus1_price
  53.                 schedule_interval(for_bonus1, 2)
  54.                 bonus1_price *= 2
  55.         if bonus2.collidepoint(pos):
  56.             if count >= bonus2_price:
  57.                 count -= bonus2_price
  58.                 schedule_interval(for_bonus2, 2)
  59.                 bonus2_price *= 2
  60.         if play.collidepoint(pos):
  61.             mode = 'game'
  62.            
  63.            
  64.            
  65.            
  66.            
  67.            
  68.            
  69.            
  70.            
  71.            
  72.            
  73.            
Advertisement
Add Comment
Please, Sign In to add comment