Advertisement
OtsoSilver

Untitled

Sep 11th, 2021
718
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.42 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_3 = Actor("bonus" , (450 , 300))
  15. play = Actor("play" , (300 , 75))
  16. cross = Actor("cross" , (580 , 20 ))
  17. shop = Actor("shop" , (300 , 175))
  18. collection = Actor("collection" , (300 , 275))
  19. price_bonus_1 = 15
  20. price_bonus_2 = 200
  21. price_bonus_3 = 600
  22. bonus_1_val = 1
  23. bonus_2_val = 15
  24. bonus_3_val = 50
  25. # Переменные
  26. count = 0
  27. click = 1
  28. mode = "menu"
  29. def draw():
  30.     global mode
  31.     if mode == "menu":
  32.         fon.draw()
  33.         play.draw()
  34.         shop.draw()
  35.         collection.draw()
  36.     if mode == "game":
  37.         fon.draw()
  38.         animal.draw()
  39.         screen.draw.text(count, center=(150,100), color = "white", fontsize = 96)
  40.         bonus_1.draw()
  41.         bonus_2.draw()
  42.         bonus_3.draw()
  43.         screen.draw.text("+"+str(bonus_1_val) + "$ каждые 2с", center=(450,80), color = "black", fontsize = 20)
  44.         screen.draw.text("цена"+str(price_bonus_1)+"$", center=(450,110), color = "black", fontsize = 20)
  45.         screen.draw.text("+"+str(bonus_2_val) + "$ каждые 2с", center=(450,180), color = "black", fontsize = 20)
  46.         screen.draw.text("цена"+str(price_bonus_2)+"$", center=(450,210), color = "black", fontsize = 20)
  47.         screen.draw.text("+"+str(bonus_3_val) + "$ каждые 2с", center=(450,280), color = "black", fontsize = 20)
  48.         screen.draw.text("цена"+str(price_bonus_3)+"$", center=(450,310), color = "black", fontsize = 20)
  49.         cross.draw()
  50. def for_bonus_1():
  51.     global count
  52.     count+= 1
  53. def for_bonus_2():
  54.     global count
  55.     count += 15
  56. def for_bonus_3():
  57.     global count
  58.     count += 50
  59. def on_mouse_down(button, pos):
  60.     global count , click , price_bonus_1 , price_bonus_2 , bonus_1_val , bonus_2_val , mode , price_bonus_3 , bonus_3_val
  61.     if button == mouse.LEFT and mode == "menu":
  62.         if play.collidepoint(pos):
  63.             mode = "game"
  64.     if button == mouse.LEFT:
  65.         if animal.collidepoint(pos):
  66.             count += click
  67.             animal.y = 200
  68.             animate(animal, tween='bounce_end', duration=0.5, y=250)
  69.         if bonus_1.collidepoint(pos):
  70.             if count>= price_bonus_1:
  71.                 count-= price_bonus_1
  72.                 schedule_interval(for_bonus_1 , 2)
  73.                 price_bonus_1 += 15
  74.                 bonus_1_val += bonus_1_val
  75.                 bonus_1.y -= 5
  76.                 animate(bonus_1 , tween = "linear" , duration = 0.1 , y = 100)
  77.         if bonus_2.collidepoint(pos):
  78.             if count>= price_bonus_2:
  79.                 count-= price_bonus_2
  80.                 schedule_interval(for_bonus_2 , 2)
  81.                 price_bonus_2 += 200
  82.                 bonus_2_val += bonus_2_val
  83.                 bonus_2.y -= 5
  84.                 animate(bonus_2 , tween = "linear" , duration = 0.1 , y = 200)
  85.         if bonus_3.collidepoint(pos):
  86.             if count>= price_bonus_3:
  87.                 count-= price_bonus_3
  88.                 schedule_interval(for_bonus_3 , 2)
  89.                 price_bonus_3 += 600
  90.                 bonus_3_val += bonus_3_val
  91.                 bonus_3.y -= 5
  92.                 animate(bonus_3 , tween = "linear" , duration = 0.1 , y = 300)
  93.         if cross.collidepoint(pos):
  94.             if mode == "game":
  95.                 mode = "menu"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement