473,413 Members | 1,764 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,413 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 1392

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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.