[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[pygame] Why Won't My Pizza Fall?



Hey There Everyone,
 
I'm following an example in a book and I can't find the error that's preventing this program from running.  It's just an example of how to get a sprite moving.  The images are all in the right folder.  I can run the program and get a stationary sprite to appear.  The trouble seems to come up when I add "dx" and "dy"  Here's the code.
 
 
from livewires import games
 
SCREEN_WIDTH = 640
SCREEN_HEIGHT = 480
 
class Pizza(games.Sprite):
    """A falling pizza."""
    def __init__(self, screen, x, y, image, dx, dy):
        """Initialize pizza object."""
        self.init_sprite(screen = screen, x = x, y = y, image = image,
                             dx = dx, dy = dy)
 
#main
my_screen = games.Screen(SCREEN_WIDTH, SCREEN_HEIGHT)
wall_image = games.load_image("skywall.png", transparent = False)
my_screen.set_background(wall_image)
pizza_image = games.load_image("pizza.png")
Pizza(screen = my_screen, x = SCREEN_WIDTH/2, y = SCREEN_HEIGHT/2,
          image = pizza_image, dx = 0, dy = 1)
 
my_screen.mainloop()
 
___________
 
 
Here's the error message:

 
Traceback (most recent call last):
  File "C:/Python25/Chapter 11/movingsprite.py", line 25, in <module>
    image = pizza_image, dx = 0, dy =1)
  File "C:/Python25/Chapter 11/movingsprite.py", line 15, in __init__
    dx = dx, dy = dy)
TypeError: init_sprite() got an unexpected keyword argument 'dx'
 
 
Thanks in advance for any help you can give me.  :-)


Looking for last minute shopping deals? Find them fast with Yahoo! Search.