[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[pygame] Rect() not imported
- To: pygame-users@xxxxxxxx
- Subject: [pygame] Rect() not imported
- From: "Gonzalo Castro" <gonzalo.castro.castilla@xxxxxxxxx>
- Date: Sun, 14 Dec 2008 18:37:16 +0100
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: pygame-users-outgoing@xxxxxxxx
- Delivered-to: pygame-users@xxxxxxxx
- Delivery-date: Sun, 14 Dec 2008 12:37:29 -0500
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:mime-version:content-type:content-transfer-encoding :content-disposition; bh=WEU9lkJ1AF3oqodgPcm4zSYDaCOhycMH8P3iwFED3gs=; b=EET71KdAgs3nI96w8jlUkfuMKGAGtl5h29jR10bGhrdf9Rl694M/EEGvpNe+QQ+LVs 8FcMIXyEMjium/ZBH9MogCiTalN33AivtKEtOOLCH68MMA44oBYUU6B5Nll4s2nq+RIt +dZdwuG271L7YJ4IT3srD6nDyJtbsq54/OHXc=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:mime-version:content-type :content-transfer-encoding:content-disposition; b=nS2q3p58kTB2unBaFadmWJcVoLIRKuO7+0Q1hezuD4sDSk7S4enVaQ0YFyDxfdrZ1M OmIzlj8ENbkt9DTdemplFuEFrXjINXN4FSeTlX+fPIAXAd/Qm6Vi11L8yzDK/GphnNtg zytcIbwlLER27lCj+phLua6q2v8d/SmGuA7W4=
- Reply-to: pygame-users@xxxxxxxx
- Sender: owner-pygame-users@xxxxxxxx
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.