[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Wraparound with sprites



Hello. You might be interested in how I implemented it
for my game Herder. The source may be downloaded from
the page below:

http://www.donationcoder.com/Forums/bb/index.php?topic=6894.msg48198#msg48198

The way it's implemented in this program is actually
quite simple:

        if self.fpx <= -16:
            self.fpx = self.fpx + 830
        if self.fpx >= 815:
            self.fpx = self.fpx - 830
        if self.fpy <= -16:
            self.fpy = self.fpy + 630
        if self.fpy >= 615:
            self.fpy = self.fpy - 630

Here, fpx and fpy refer to the x and y coordinates of
the center of a 32 x 32 sprite. All I'm checking for
is if the sprite has gone out of bounds in the "830 x
630" extended screen it's in, and if that happens,
just wrap around.

I hope this helps :)

Chuck Arellano - Game Programming Video Tutorials for Beginners at http://www.scriptedfun.com/


 
____________________________________________________________________________________
Cheap talk?
Check out Yahoo! Messenger's low PC-to-Phone call rates.
http://voice.yahoo.com