Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.04 KB | None | 0 0
  1.  
  2.  
  3. from livewires import games,color
  4. import random
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11. class Bucket(games.Sprite):
  12.  
  13. def update(self):
  14. self.x = games.mouse.x
  15. self.y = games.mouse.y
  16. self.check_collide()
  17.  
  18. def check_collide(self):
  19. for myPizza in self.overlapping_sprites:
  20. myPizza.handle_collide()
  21.  
  22.  
  23. class Pizza(games.Sprite):
  24.  
  25.  
  26. def update(self):
  27. self.angle+=15
  28. self.y+=2
  29. if(self.y > games.screen.height):
  30. self.y = 100
  31. self.x = random.randint(10,games.screen.width-10)
  32. self.flag = True
  33. def handle_collide(self):
  34. self.y = 100
  35. self.x = random.randint(10,games.screen.width-10)
  36.  
  37.  
  38. class Chef(games.Sprite):
  39. def update(self):
  40. self.y=55
  41. self.x = random.randint(10,games.screen.width-10)
  42.  
  43. #if myPizza.flag == True:
  44. #self.x = random.randint(10,games.screen.width-10)
  45. # myPizza.flag = False
  46. # myPizza.flag = False
  47. def handle_collide(self):
  48. self.y = 55
  49. #self.x = random.randint(10,games.screen.width-10)
  50.  
  51.  
  52.  
  53. def main():
  54.  
  55.  
  56.  
  57. games.init(screen_width = 640,screen_height = 480,fps = 50)
  58.  
  59.  
  60. wall = games.load_image("wall.jpg")
  61. games.screen.background = wall
  62.  
  63. bucket = games.load_image("bucket.bmp")
  64. myBucket = Bucket(image = bucket,x = games.mouse.x,y = games.mouse.y)
  65. games.screen.add(myBucket)
  66.  
  67.  
  68. pizzaX = random.randint(1,games.screen.width)
  69. pizzaY = random.randint(1,games.screen.height)
  70.  
  71. pizza = games.load_image("pizza.bmp")
  72. myPizza = Pizza(image = pizza,x = pizzaX,y = pizzaY)
  73. games.screen.add(myPizza)
  74.  
  75.  
  76. chef = games.load_image("chef.bmp")
  77. myChef = Chef(image = chef,x = 100,y = 55)
  78. games.screen.add(myChef)
  79.  
  80.  
  81. score = games.Text(value = 0,size = 60,color = color.black, x = 550,y = 30)
  82.  
  83. games.screen.add(score)
  84.  
  85.  
  86. games.mouse.is_visible = False
  87.  
  88. games.screen.event_grab = True
  89.  
  90. games.screen.mainloop()
  91.  
  92.  
  93. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement