Advertisement
humpda

Balloon_Bust

Mar 2nd, 2022
1,489
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.50 KB | None | 0 0
  1. from random import randint
  2. from pgzhelper import *
  3.  
  4.  
  5. WIDTH = 800
  6. HEIGHT = 600
  7. game_over = False
  8.  
  9. bird = Actor("bird-up")
  10. bird.images = ['bird-up','bird-down']
  11. bird.fps = 5
  12. bird.pos = randint(800, 1600), randint(10, 200)
  13. balloon = Actor("balloon")
  14. balloon.pos = 400, 300
  15. house = Actor("house")
  16. house.pos = randint(800, 1600), 460
  17. tree = Actor("tree")
  18. tree.pos = randint(800, 1600), 450
  19. up = True
  20. score = 0
  21.  
  22.  
  23. def draw():
  24.     global game_over
  25.     if game_over == False:
  26.         screen.clear()
  27.         screen.blit("background", (0, 0))
  28.         balloon.draw()
  29.         bird.draw()
  30.         house.draw()
  31.         tree.draw()
  32.         screen.draw.text("Score: "+ str(score), (700,5), color="black")
  33.  
  34. def on_mouse_down():
  35.     global up
  36.     up = True
  37.     balloon.y = balloon.y - 50
  38.    
  39. def on_mouse_up():
  40.     global up
  41.     up = False
  42.  
  43. def update():
  44.     global game_over, up, score
  45.     bird.animate()
  46.     if game_over == False:
  47.         if up == False:
  48.             balloon.y = balloon.y + 1
  49.            
  50.     if bird.x > 0:
  51.         bird.x += -4
  52.     else:
  53.         bird.x = randint(800,1600)
  54.         bird.y = randint (10,200)
  55.         score = score+1
  56.    
  57.     if house.x > 0:
  58.         house.x = house.x - 2
  59.     else:
  60.         house.x = randint(800, 1600)
  61.         score = score+1
  62.        
  63.     if balloon.collidepoint (bird.x, bird.y) or balloon.collidepoint(house.x, house.y):
  64.         game_over = True
  65.        
  66.     if balloon.top < 0 or balloon.bottom > 560:
  67.         game_over = True
  68.        
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement