Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pgzero
- WIDTH = 600
- HEIGHT = 400
- TITLE = "Animal clicker"
- FPS = 30
- # Объекты
- animal = Actor("giraffe", (150, 250))
- fon = Actor("fon")
- bonus_1 = Actor("bonus", (450, 100))
- bonus_2 = Actor("bonus", (450, 200))
- price_b1 = 15
- price_b2 = 200
- # Переменные
- count = 0
- click = 1
- def draw():
- fon.draw()
- animal.draw()
- screen.draw.text(count, center=(150, 100), color="white", fontsize = 96)
- bonus_1.draw()
- screen.draw.text("+1$ каждые 2с", center=(450, 80), color="black", fontsize = 20)
- screen.draw.text("цена: "+str(price_b1)+"$", center=(450, 110), color="black", fontsize = 20)
- bonus_2.draw()
- screen.draw.text("+15$ каждые 2с", center=(450, 180), color="black", fontsize = 20)
- screen.draw.text("цена: "+str(price_b2)+"$", center=(450, 210), color="black", fontsize = 20)
- def for_bonus_1():
- global count
- count += 1
- def for_bonus_2():
- global count
- count += 15
- def on_mouse_down(button, pos):
- global count,price_b1,price_b2
- if button == mouse.LEFT:
- # Клик по объекту animal
- if animal.collidepoint(pos):
- count += click
- animal.y = 200
- animate(animal, tween='bounce_end', duration=0.5, y=250)
- # Клик по кнопке bonus_1
- elif bonus_1.collidepoint(pos):
- if count >= price_b1:
- schedule_interval(for_bonus_1, 2)
- count -= price_b1
- price_b1 *=2
- bonus_1.y = 105
- animate(bonus_1, tween='bounce_end', duration=0.5, y=100)
- # Клик по кнопке bonus_2
- elif bonus_2.collidepoint(pos):
- if count >= price_b2:
- schedule_interval(for_bonus_2, 2)
- count -= price_b2
- price_b2 *=2
- bonus_2.y = 205
- animate(bonus_2, tween='bounce_end', duration=0.5, y=200)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement