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))
- bonus_3 = Actor("bonus", (450, 300))
- play = Actor("play", (300, 100))
- cross = Actor("cross", (580, 20))
- shop = Actor("shop", (300, 200))
- collection = Actor("collection", (300, 300))
- crocodile = Actor('crocodile', (120, 200))
- hippo = Actor('hippo', (300, 200))
- animals = []
- # Переменные
- count = +99999
- click = 1
- mode = 'menu'
- price_1 = 15
- price_2 = 200
- price_3 = 600
- def draw():
- if mode == 'menu':
- fon.draw()
- play.draw()
- screen.draw.text(count, center=(30, 20), color="white", fontsize = 36)
- shop.draw()
- collection.draw()
- elif mode == 'game':
- 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(price_1, 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(price_2, center=(450, 210), color="black", fontsize = 20)
- bonus_3.draw()
- screen.draw.text("+50$ каждые 2с", center=(450, 280), color="black", fontsize = 20)
- screen.draw.text(price_3, center=(450, 310), color="black", fontsize = 20)
- cross.draw()
- elif mode == 'shop':
- fon.draw()
- cross.draw()
- screen.draw.text(count, center=(30, 20), color="white", fontsize = 36)
- crocodile.draw()
- screen.draw.text("500$", center=(120, 300), color="white", fontsize = 36)
- hippo.draw()
- screen.draw.text("2500$", center=(300, 300), color="white", fontsize = 36)
- elif mode == 'collection':
- fon.draw()
- cross.draw()
- screen.draw.text(count, center=(30, 20), color="white", fontsize = 36)
- screen.draw.text("+2$", center=(120, 300), color="white", fontsize = 36)
- screen.draw.text("+4$", center=(300, 300), color="white", fontsize = 36)
- for anim in animals:
- anim.draw()
- def for_bonus_1():
- global count
- count += 1
- def for_bonus_2():
- global count
- count += 15
- def for_bonus_3():
- global count
- count += 50
- def on_mouse_down(button, pos):
- global count, click, animals
- global mode
- global price_1, price_2, price_3
- if button == mouse.LEFT and mode == 'game':
- # Клик по объекту 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):
- bonus_1.y = 105
- animate(bonus_1, tween='bounce_end', duration=0.5, y=100)
- if count >= price_1:
- schedule_interval(for_bonus_1, 2)
- count -= price_1
- price_1 *= 2
- # Клик по кнопке bonus_2
- elif bonus_2.collidepoint(pos):
- bonus_2.y = 205
- animate(bonus_2, tween='bounce_end', duration=0.5, y=200)
- if count >= price_2:
- schedule_interval(for_bonus_2, 2)
- count -= price_2
- price_2 *= 2
- # Клик по кнопке bonus_3
- elif bonus_3.collidepoint(pos):
- bonus_3.y = 305
- animate(bonus_3, tween='bounce_end', duration=0.5, y=300)
- if count >= price_3:
- schedule_interval(for_bonus_3, 2)
- count -= price_3
- price_3 *= 2
- elif cross.collidepoint(pos):
- mode = 'menu'
- # Режим меню
- elif mode == 'menu' and button == mouse.LEFT:
- if play.collidepoint(pos):
- mode = 'game'
- if shop.collidepoint(pos):
- mode = 'shop'
- if collection.collidepoint(pos):
- mode = 'collection'
- elif mode == 'shop' and button == mouse.LEFT:
- if cross.collidepoint(pos):
- mode = 'menu'
- elif crocodile.collidepoint(pos):
- if crocodile in animals:
- animal.image = 'crocodile'
- elif count >= 500:
- crocodile.y = 205
- animate(crocodile, tween='bounce_end', duration=0.5, y=200)
- count -= 500
- animal.image = 'crocodile'
- click = 2
- animals.append(crocodile)
- elif hippo.collidepoint(pos):
- if hippo in animals:
- animal.image = 'hippo'
- elif count >= 2500:
- hippo.y = 205
- animate(hippo, tween='bounce_end', duration=0.5, y=200)
- count -= 2500
- animal.image = 'hippo'
- click = 4
- animals.append(hippo)
- elif mode == 'collection' and button == mouse.LEFT:
- if cross.collidepoint(pos):
- mode = 'menu'
- elif crocodile.collidepoint(pos):
- if crocodile in animals:
- animal.image = 'crocodile'
- elif hippo.collidepoint(pos):
- if hippo in animals:
- animal.image = 'hippo'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement