Re: [pygame] get coluor of a sprite

2008-12-27 Thread Gonzalo Castro
Thanks everybody!

Surface.get_at worked fine for me. I'll try the others :)

Thanks.


[pygame] get coluor of a sprite

2008-12-26 Thread Gonzalo Castro
Hello everybody!

What function may I use to get the colour of a sprite? I'm not talking
about filling it with a colour, I'm talking about a function that
returns the colur of the sprite.

Thanks, and have a happy new year! :)


Re: [pygame] pygame.sprite.RenderUpdates() without arguments

2008-12-17 Thread Gonzalo Castro
 This creates a RenderUpdates group named .all

 Player.containers = self.all
 Computer.containers = self.all
 Ball.containers = self.all

 This makes three aliases for .all

So every time you talk about Payer.containers is like talking about self.all...

 Somewhere else in the code, sprites will be added to these containers.

Maybe here?

#The whole Player class
class Player(pygame.sprite.Sprite):

def __init__(self):

pygame.sprite.Sprite.__init__(self, self.containers) HERE??
self.image = pygame.Surface((16, 64))
self.image.fill((255, 255, 255), (2, 0, 12, 64))
self.image.fill((255, 255, 255), (0, 2, 16, 60))
self.rect = self.image.get_rect(midleft = (16, 240))
self._rect = pygame.Rect(self.rect)
print(self._rect)

def update(self):
self._rect = Rect(self.rect)

key = pygame.key.get_pressed()
if key[K_UP]:
self.rect.move_ip(0, -5)
if key[K_DOWN]:
self.rect.move_ip(0, 5)

if self.rect.bottom  480:
self.rect.bottom = 480
if self.rect.top  0:
self.rect.top = 0

 ---
 James Paige

Thank you James


[pygame] pygame.sprite.RenderUpdates() without arguments

2008-12-16 Thread Gonzalo Castro
Hi everybody!

What does  pygame.sprite.RenderUpdates()  with no arguments?

class Game:

def __init__(self, screen):

self.screen = screen

self.all = pygame.sprite.RenderUpdates()
Player.containers = self.all
Computer.containers = self.all
Ball.containers = self.all

In the python help it says you have to give it the group name you want
to update, so if you don't give it arguments?

Another question about this function: Does it render  self.rect of every sprite?

Thanks a lot

PD: sorry about my newbie doubts ;) Starting something is always difficult


[pygame] Rect() not imported

2008-12-14 Thread Gonzalo Castro
Hello everybody! :)

I'm reading some code from pygame's web and I found something that I
don't really understand. I'll really apreciate your help ;)

###
import sys, os
import random

import pygame
from pygame.locals import *

class Player(pygame.sprite.Sprite):

def __init__(self):

pygame.sprite.Sprite.__init__(self, self.containers)
self.image = pygame.Surface((16, 64))
self.image.fill((255, 255, 255), (2, 0, 12, 64))
self.image.fill((255, 255, 255), (0, 2, 16, 60))
self.rect = self.image.get_rect(midleft = (16, 240))
self._rect = pygame.Rect(self.rect) ###HERE IS THE
PROBLEM

def update(self):
self._rect = Rect(self.rect)

key = pygame.key.get_pressed()
if key[K_UP]:
self.rect.move_ip(0, -5)
if key[K_DOWN]:
self.rect.move_ip(0, 5)

if self.rect.bottom  480:
self.rect.bottom = 480
if self.rect.top  0:
self.rect.top = 0


This is all the imports and a class from the game PyPong.pyw. It works
perfectly for me, but I don't _understand_ how the function Rect works
if here, the module pygame is imported with import pygame, not import
* from pygame.

I used python help and I only found help about:
pygame.Rect()
But I still don't understand why does it works. Cloud anyone explain it to me?

Thanks a lot.


Re: [pygame] Rect() not imported

2008-12-14 Thread Gonzalo Castro
2008/12/14 Ian Mallett geometr...@gmail.com:
 It's the pygame.locals line:

 import pygame
 pygame.Rect(0,0,5,6)
 rect(0, 0, 5, 6)
 Rect(0,0,5,6)

 Traceback (most recent call last):
   File pyshell#2, line 1, in module
 Rect(0,0,5,6)
 NameError: name 'Rect' is not defined
 from pygame.locals import *
 pygame.Rect(0,0,5,6)
 rect(0, 0, 5, 6)
 Rect(0,0,5,6)
 rect(0, 0, 5, 6)


Lots of thanks Ian

 Ian



[pygame] groups

2008-10-10 Thread Gonzalo Castro
HI! I'm practising with groups and I have problems. ;)
I have 2 clases, ball and killer... they are more or less the same,
and 3 objects: a 2 of class ball and the other of class killer. I
grouped both of 2 objects balls into a group called my_balls. I define
it like this:

global my_balls= pygame.sprite.Group(ball, second)

and at  some point of the game I do:

print(myballs.has())

And this prints None. What Am I missing?

Thank you a lot. :)


Re: [pygame] groups

2008-10-10 Thread Gonzalo Castro
Hi!

 group.has() is a membership test that takes at least one sprite as an
 argument. It tests if a one or more sprites are in a group. It it not for
 testing if any sprites are in a group. This is not documented, yet, but to
 check if a group is empty or not get its boolean value. An empty group
 evaluates to False.


Lots of thanks! I didn't understand properly the documentation ;)

So there isn't any function that tells you what sprites are in it?

Thanks again :)


Re: [pygame] groups

2008-10-10 Thread Gonzalo Castro
Hi again!
 group.sprites() returns a list of sprites in the group. or:

 for sprite in group:
   # do something with sprite.

Thanks a lot. :)

I read the documentation and I understand pretty well :)


Re: [pygame] functions

2008-08-19 Thread Gonzalo Castro
2008/8/11 Jake b [EMAIL PROTECTED]:
 Here's a tutorial to get you started with sprites and spritegroups.
 http://kai.vm.bytemark.co.uk/~piman/writing/sprite-tutorial.shtml

Thanks a lot... I couldn't reply before, because I went on holyday...

 --
 Jake



[pygame] functions

2008-08-09 Thread Gonzalo Castro
Hello everybody!
I'm starting with pygame... It's being difficoult... it's the first
time I program with objects ;)

So... could you help me with this functions? I couldn't find the
answer in the online help of python (yes, importing pygame previously)

#Some of code from class Player ;)

class Player(pygame.sprite.Sprite):

def __init__(self):

pygame.sprite.Sprite.__init__(self, self.containers) #self.
containers??? what does that?
self.image = pygame.Surface((16, 64))
self.image.fill((255, 255, 255), (2, 0, 12, 64))
self.image.fill((255, 255, 255), (0, 2, 16, 60))
self.rect = self.image.get_rect(midleft = (10, 240))
#image.get_rect??? and you asign a value to midleft?
self._rect = Rect(self.rect)
   #function Rect? convert to rect type maybe??

#End of code

Sorry about my english, I'm spaniard and I still have to improve it.

Thanks a lot :)

PD: this class it's taken from PyMike's pong game


[pygame] Re:

2008-07-21 Thread Gonzalo Castro
2008/7/21 David Goldsmith [EMAIL PROTECTED]:
 help
 Yes, I also need it!! ;)


[pygame] unsubscribe [OT]

2008-06-22 Thread Gonzalo Castro
Sorry, but how can I unsubscribe from the list? I went to the pygame's
web and I couldn't see it. Thanks.


Re: [pygame] unsubscribe [OT]

2008-06-22 Thread Gonzalo Castro
2008/6/22 Brian Fisher [EMAIL PROTECTED]:
 Unsubscribes are done with an email to the list management address.

 There is a mailto link for it on this page:
 http://www.pygame.org/wiki/info

 you get to this page from the Help (irc, lists) link from the main page at
 http://pygame.org

This is what it says there: To get on or off the mailing list, send
an email message to [EMAIL PROTECTED] with a simple command in the
body.
What command whould I send?

 I'm curious, why are you unsubscribing?

Because I have to learn Python before pygame ;) I subscribed because I
wanted to take a look to pygame and it's community.

Thanks. :)