By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,345 Members | 1,758 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,345 IT Pros & Developers. It's quick & easy.

livewires: where is the get methods in class Sprite

P: 1
I am reading a book about Python Programming. When I practised the following example:

from livewires import games

SCREEN_WIDTH = 640
SCREEN_HEIGHT = 480
Expand|Select|Wrap|Line Numbers
  1. class Pizza(games.Sprite, games.Mover):
  2.     """ A falling pizza. """
  3.     def __init__(self, screen, x, y, image, dx, dy):
  4.         """ Initialize pizza object. """
  5.         self.init_sprite(screen = screen, x = x, y = y,
  6.                            image = image)
  7.         self.init_mover(dx = dx, dy = dy)
  8.     def moved(self):
  9.         """ Reverse a velocity component if edge of screen reached. """
  10.         dx, dy = self.get_velocity()
  11.         if self.get_right() > SCREEN_WIDTH or self.get_left() < 0:
  12.             self.set_velocity(-dx, dy)
  13.         if self.get_bottom() > SCREEN_HEIGHT or self.get_top() < 0:
  14.             self.set_velocity (dx, -dy)
  15.  
  16. # main
  17. my_screen = games.Screen(SCREEN_WIDTH, SCREEN_HEIGHT)
  18.  
  19. wall_image = games.load_image("1.jpg", transparent = False)
  20. my_screen.set_background(wall_image)
  21.  
  22. pizza_image = games.load_image ("tt1.gif")
  23.  
  24. Pizza(screen = my_screen, x = SCREEN_WIDTH/2, y = SCREEN_HEIGHT/2,
  25.         image = pizza_image, dx = 1, dy =1)
  26.  
  27. my_screen.mainloop()
  28.  


I met some problems. Then I traced down to find out that there are no functions named get_right, get_left, get_top and get_bottom in class Sprite in the file games.py under the directory C:\Python25\Lib\site-packages\livewires.
I do not know whether it is an installation problem or there are no such functions at all. But I really want this script to run smoothly. So I add something in class Sprite:
Expand|Select|Wrap|Line Numbers
  1. def get_right (self):
  2.         return self._x
  3. def get_bottom (self):
  4.         return self._y
But I do not know how to script the get_left() and get_top() functions because python is my first coding language. could somebody help me out of this?

BTW, the version of my python is 2.5, livewires v2.1, pygame v 1.7, and my os is winxp2002 SP2

Thanks
Aug 15 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.