OtsoSilver

Untitled

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