Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from random import randint
- from pgzhelper import *
- WIDTH = 800
- HEIGHT = 600
- game_over = False
- bird = Actor("bird-up")
- bird.images = ['bird-up','bird-down']
- bird.fps = 5
- bird.pos = randint(800, 1600), randint(10, 200)
- balloon = Actor("balloon")
- balloon.pos = 400, 300
- house = Actor("house")
- house.pos = randint(800, 1600), 460
- tree = Actor("tree")
- tree.pos = randint(800, 1600), 450
- up = True
- score = 0
- def draw():
- global game_over
- if game_over == False:
- screen.clear()
- screen.blit("background", (0, 0))
- balloon.draw()
- bird.draw()
- house.draw()
- tree.draw()
- screen.draw.text("Score: "+ str(score), (700,5), color="black")
- def on_mouse_down():
- global up
- up = True
- balloon.y = balloon.y - 50
- def on_mouse_up():
- global up
- up = False
- def update():
- global game_over, up, score
- bird.animate()
- if game_over == False:
- if up == False:
- balloon.y = balloon.y + 1
- if bird.x > 0:
- bird.x += -4
- else:
- bird.x = randint(800,1600)
- bird.y = randint (10,200)
- score = score+1
- if house.x > 0:
- house.x = house.x - 2
- else:
- house.x = randint(800, 1600)
- score = score+1
- if balloon.collidepoint (bird.x, bird.y) or balloon.collidepoint(house.x, house.y):
- game_over = True
- if balloon.top < 0 or balloon.bottom > 560:
- game_over = True
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement