about sprite.image, Surface.copy(): i almost getting the point, and i hope not being abusing if i'd ask for a small and simple working snippet (small as 1kb-like or less) could show us this - thanks! :-)
----- On Mon, Jul 28, 2008 at 1:11 AM, Paulo Silva <[EMAIL PROTECTED]> wrote: > thanks! :-) > > > On Mon, Jul 28, 2008 at 1:06 AM, René Dudfield <[EMAIL PROTECTED]> wrote: >> make sprite.image use the same surface. >> >> Surfaces are not copied by default. You need to use the >> Surface.copy() method to create a new one. >> >> So just assigning the same surface will work for sharing one picture >> with lots of sprites. >> >> >> On Mon, Jul 28, 2008 at 9:33 AM, Paulo Silva <[EMAIL PROTECTED]> wrote: >>> you welcome! :-) - btw, i'm still trying to to on Pygame what i were >>> doing on sdlBasic up to now >>> (http://nitrofurano.linuxkafe.com/sdlbasic), stuff like how to get >>> lots of sprites from just one picture, etc. >>> >>> ------ >>> >>> On Mon, Jul 28, 2008 at 12:19 AM, Percival Kelley >>> <[EMAIL PROTECTED]> wrote: >>>> Awesome. Thank you. That did the trick. >>>> >>>> On Sun, Jul 27, 2008 at 1:10 PM, Paulo Silva <[EMAIL PROTECTED]> wrote: >>>>> >>>>> well, for now i were enjoying these ones >>>>> http://www.cs.iupui.edu/~aharris/pygame/ch04/ >>>>> >>>>> -------- >>>>> >>>>> On Sun, Jul 27, 2008 at 11:38 PM, <[EMAIL PROTECTED]> wrote: >>>>> > So I've read piman's tutorial and checked out a few others. I'm still >>>>> > confused. I don't really understand the process of moving a sprite >>>>> > around. I would like to use RenderUpdates and such, but I'm lost. >>>>> > >>>>> > I basically have a simple script that moves a ship around a background >>>>> > (the background is an image.) >>>>> > >>>>> > To create the sprite I'm using: >>>>> > >>>>> > class Units(pygame.sprite.Sprite): >>>>> > >>>>> > def __init__(self, img, loc1 = 250, loc2 = 250): >>>>> > pygame.sprite.Sprite.__init__(self) #start up sprites >>>>> > >>>>> > #locs >>>>> > self.loc1 = loc1 >>>>> > self.loc2 = loc2 >>>>> > >>>>> > #create sprite >>>>> > self.image, self.rect = load_image(img) >>>>> > self.rect.center = [self.loc1, self.loc2] >>>>> > >>>>> > I create the ship like this: >>>>> > self.ship = Units('bship.png') >>>>> > self.screen.blit(self.ship.image, self.ship.rect) >>>>> > >>>>> > To redraw the ship when it moves I'm using this: >>>>> > >>>>> > self.ship.loc1 = n1 #n1 and n2 are setup earlier in the code that >>>>> > looks for key presses and sets the pixel difference >>>>> > self.ship.loc2 = n2 >>>>> > self.ship.rect.center = [self.ship.loc1, self.ship.loc2] >>>>> > print self.ship.rect.center >>>>> > self.screen.blit(self.bg, (0,0)) >>>>> > self.screen.blit(self.ship.image, self.ship.rect.center) >>>>> > pygame.display.flip() >>>>> > >>>>> > I'm really pretty confused at this point. I know I'm just doing >>>>> > something stupid, but I haven't managed to get any other code working >>>>> > to redraw the ship properly when it's moved. I don't have the code >>>>> > from when I was doing it wrong, but basically, can someone point me in >>>>> > the right direction to changing this over to just redraw the >>>>> > appropriate areas? >>>>> > >>>>> > Thanks, and sorry this was rambling. >>>>> > >>>> >>>> >>> >> >
