[Tutor] Pizza panic game

Dave Angel d at davea.name
Sun Feb 5 12:58:02 CET 2012

(You forgot to do a Reply-all, and thus your message(s) came only to me. 
  I'm forwarding it, but with my response as well)

On 02/05/2012 05:35 AM, myles broomes wrote:
> I apologise, this is what the code actually looks like:
> Spikey ball class:
> class Spikey_ball(games.Sprite):
>      """A hazardous spikey ball that falls to the ground."""
>      image = games.load_image("Spikey_ball.png")
>      speed = 0.5
>      def __init__(self, x, y = 90):
>          """Initialise the spikey ball object."""
>          super(Spikey_ball, self).__init__(image = Spikey_ball.image,
>                                                         x = x, y = y,
>                                                         dy = Spikey_ball.speed)
>      def update(self):
>              """Check if botton edge has reached the screen."""
>              if self.bottom>  games.screen.height:
>                     self.destroy()
>       def handle_caught(self):
>              """Destroy if caught and end game."""
>              if self.bottom>  Pan.top:
>                  Pizza.end_game()
>                  self.destroy()
> Sorry for the confusion and thanks in advance. 		 	   		

Sometimes I see this type of symptom when somebody mixes tabs and 
spaces, a definite no-no.  This message looks like you use pure spaces 
for indentation, which is the style I prefer.  Anyway, handle_caught() 
is still indented one more column than update(), so it gets an 
IndentationError exception:

IndentationError: unindent does not match any outer indentation level

If you have any doubt, follow Alan's advice, to see just what the 
attributes of pizza are at that point.

Or add a print in top-level code to see what the attributes of 
Spikey_ball class are.

If all this is indeed a cut&paste error, and the indentation is correct, 
then I'd look to see what the type of the pizza is when it fails. 
Perhaps it's not really Spikey_Ball.



More information about the Tutor mailing list