python - My program runs well, but why is it giving me an Attribute Error after it exits? -


the game simple pan object catches pizza objects dispensed chef object. when pan object (the user) misses pizza object, , hits floor of screen, "game over" printed (def game_over(self)) , game terminates. after game terminates, ide gives me these error:

traceback (most recent call last):   file "c:\users\compaq\my documents\aptana studio workspace\pythonic things\pizzapanicattempt\pizzapanicattempt3.py", line 125, in <module>     main()   file "c:\users\compaq\my documents\aptana studio workspace\pythonic things\pizzapanicattempt\pizzapanicattempt3.py", line 124, in main     games.screen.mainloop()   file "c:\python27\lib\site-packages\livewires\games.py", line 308, in mainloop     object._tick()    file "c:\python27\lib\site-packages\livewires\games.py", line 506, in _tick     self.update()   file "c:\users\compaq\my documents\aptana studio workspace\pythonic things\pizzapanicattempt\pizzapanicattempt3.py", line 67, in update     self.check_collision()   file "c:\users\compaq\my documents\aptana studio workspace\pythonic things\pizzapanicattempt\pizzapanicattempt3.py", line 72, in check_collision     pizza.handle_caught() attributeerror: 'pan' object has no attribute 'handle_caught' 

the actual code program follows:

''' created on jul 1, 2011  @author: ******** louis ''' #watch me do. livewires import games, color import random  games.init (screen_width = 640, screen_height = 480, fps = 50)  #pizza class class pizza (games.sprite):     pizzaimage = games.load_image ("pizza.bmp", transparent = true)     def __init__(self, x, y = 90, dy = 4):         super (pizza, self).__init__(x = x,                                       y = y,                                      image = pizza.pizzaimage,                                       dy = dy)      def update (self):         if self.bottom>640:             self.game_over()             self.destroy()      def handle_caught (self):         self.destroy()      def game_over (self):         gameovermessage = games.message(value = "game over",                                          size = 90,                                           color = color.red,                                           x = 320,                                           y = 240,                                           lifetime = 250,                                           after_death = games.screen.quit())         games.screen.add(gameovermessage)   #pan/cursorial class        class pan (games.sprite):     panimage = games.load_image ("pan.bmp", transparent = true)     def __init__ (self, x = games.mouse.x, y = games.mouse.y):         super (pan, self).__init__(x = x,                                     y = y,                                     image = pan.panimage)         self.score = 0         self.textbox = games.text (value = self.score,                                     size = 20,                                     color = color.black,                                     x = 550,                                     y = 50)         games.screen.add(self.textbox)       def update (self): #wwwwow there *update* method         self.x = games.mouse.x         self.y = games.mouse.y          if self.left < 0:             self.left = 0         if self.right >640:             self.right = 640         if self.top < 0:             self.top = 0         if self.bottom > 480:             self.bottom = 480          self.check_collision()      def check_collision (self):         pizza in self.overlapping_sprites:             self.textbox.value += 10             pizza.handle_caught()  #the pizza dispenser class! class chef (games.sprite):     chefimage = games.load_image ("chef.bmp", transparent = true)     def __init__(self, y = 55):         super (chef, self).__init__(x = 320,                                      y = y,                                     dx = 2,                                     image = chef.chefimage)         self.timervar = 0      def update (self):         if self.left < 0 or self.right > 640 or random.randrange(50) == 7:             self.dx = -self.dx          self.check_drop()      def check_drop (self):         if self.timervar > 0:             self.timervar = self.timervar - 1         else:             le_pizza = pizza (x = self.x)             games.screen.add(le_pizza)             self.timervar = 100  #main def main():     wallimage = games.load_image ("wall.jpg", transparent = true)     games.screen.background = wallimage      games.screen.add (chef())      games.screen.add (pan())     games.mouse.is_visible = false     games.screen.event_grab = true      games.screen.mainloop()  main()  #main def main():     wallbackground = games.load_image ("wall.jpg", transparent = false)     games.screen.background = wallbackground      games.screen.add(chef())      games.screen.add(pan())     games.mouse.is_visible = false     games.screen.event_grab = true      games.screen.mainloop() main() 

one of self.overlapping_sprites pan, not pizza.

also, have 2 main()s.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -