472,952 Members | 2,209 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

livewires: where is the get methods in class Sprite

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
0 1355

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

Similar topics

0
by: BJ MacNevin | last post by:
If anyone is familiar with the Livewires package... I can't get the graphics windows to behave. When I run the test() then everything seems to be working fine. But when I try to use it this...
4
by: Nathan Pinno | last post by:
Hey all, Is there a way to create a button in either pygame or livewires, that is able to be clicked and when clicked sends a command to restart the program? Thanks, Nathan Pinno -- For...
0
by: Blaze Bresko | last post by:
hey, I am using python 2.4 and py2exe v 0.6. I have made a program using pygame/livewires. I have the newest version of both but i dont know what version they are (im on a different computer...
0
by: Blaze Bresko | last post by:
hey, I am using python 2.4 and py2exe v 0.6. I have made a program using pygame/livewires. I have the newest version of both but i dont know what version they are (im on a different computer...
19
by: Chocawok | last post by:
Some of the classes in my app are graphical. To encapsulate the graphical side of things I had created a class called "sprite" which holds a bit map and knows how to draw itself etc. The...
0
MetalMartian
by: MetalMartian | last post by:
Hey guys just wondering what the best way would be to move a sprite through a maze where the width of the sprite is the same as the width of the tunnel it's moving through. Pretty much the same as...
4
by: Saile | last post by:
I'm creating an array inside the constructor of my class. Looks like: class SPR_ANIM { public: int index; SPR_ANIM::SPR_ANIM(int num); void Draw(); }; SPR_ANIM::SPR_ANIM(int...
12
by: bgold | last post by:
Hey. I have a base class (SPRITE), and using this base class I have derived a large number of derived classes (PERSON, BULLET, MISSILE, etc.). Now, at a certain point in my program, I have a pair...
18
HaLo2FrEeEk
by: HaLo2FrEeEk | last post by:
I like to go through the Windows files in a resource editor, just to see what's there. I notice a lot of sprite images that are actually animations. For example, a file 32x256 has 8 tiles each...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...

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.