[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

R: [pygame] Someone could help me??



I read the tutorial, but I want u to help me whit my simple code
"directly"...I mean that I need someone who orders my little work...It's
hard for me to understand something written...I prefer the
examples...but the chip example is too different from mine...

I can't understand how I can use the Groups, how can I tell to my
script:
"Update only THIS sprites, not all"...

You can replace the script file with the one here attached...it's only
something to "fill the hole"...

Put it into the script directory...

I'm waiting for your help... :)

-----Messaggio originale-----
Da: owner-pygame-users@seul.org [mailto:owner-pygame-users@seul.org] Per
conto di Pete Shinners
Inviato: venerd́ 18 ottobre 2002 18.30
A: pygame-users@seul.org
Oggetto: Re: [pygame] Someone could help me??

Gabriele Farina wrote:
> Hi, someone could help me with my project??
> 
> I got many problems, so I attach the script to this message. I want
only
> one kind of help now:
> Can you ask me how can I move my sprites on the background?? I need
the
> code according with my script.

your game wouldn't work for me as you attached it. it seems to be
missing
some scripts in "modulo1/scripts" (i didn't get any).

no problem though, i looked through the code a little. since you are
using
pygame's Sprite stuff it should be fairly easy to get the objects
moving. i
notice all your sprite objects have a method like this,

    def set_pos(self,bg,pos):
        bg.blit(self.img,pos)

this is probably not what you want. when using the sprite classes, you
can
also use some advanced sprite Group classes. a Group is a container of
many
sprites, but can also do things like drawing them. it is best to let
these
Groups draw and erase all the sprites as they move.

there is a fairly good tutorial for the sprite stuff, but i'm guessing
you've already seen it. probably hard when it's in the wrong language
for
you :] look at something like the "chimp" example to see how it sets up
2
simple sprites and draws them.

sprite intro: http://pygame.org/docs/tut/SpriteIntro.html

i noticed the chimp example "cheats" a little by just redrawing
everything
each frame. a little simple but it doesn't work as well in a real game.
i
suppose then "aliens" is the better example of using the sprite module.
there is a sprite.RenderUpdates() instance named "all" which has all the
sprites added to it. at the beginning of the game loop it calls
   all.clear(screen, background)
   all.update()
this erases all the previously drawn sprites from the screen. the
update()
call goes through each sprite and calls its update() method. (your
sprites
seem to all have a good update() method already). then to draw we call
   dirty = all.draw(screen)
   pygame.display.update(dirty)
dirty here is a list of all updated rectangle areas on the screen.

hopefully this helps, sorry if it's hard to understand


____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org

start.script