471,334 Members | 1,433 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,334 software developers and data experts.

livewires: where is the get methods in class Sprite

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

from livewires import games

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)
  16. # main
  17. my_screen = games.Screen(SCREEN_WIDTH, SCREEN_HEIGHT)
  19. wall_image = games.load_image("1.jpg", transparent = False)
  20. my_screen.set_background(wall_image)
  22. pizza_image = games.load_image ("tt1.gif")
  24. Pizza(screen = my_screen, x = SCREEN_WIDTH/2, y = SCREEN_HEIGHT/2,
  25.         image = pizza_image, dx = 1, dy =1)
  27. my_screen.mainloop()

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

Aug 15 '07 #1
0 1282

Post your reply

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

Similar topics

reply views Thread by BJ MacNevin | last post: by
reply views Thread by Blaze Bresko | last post: by
reply views Thread by Blaze Bresko | last post: by
19 posts views Thread by Chocawok | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.