[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] Wraparound with sprites
- To: pygame-users@xxxxxxxx
- Subject: Re: [pygame] Wraparound with sprites
- From: Chuck Arellano <scriptedfun@xxxxxxxxx>
- Date: Wed, 7 Feb 2007 02:01:50 -0800 (PST)
- Delivered-to: archiver@seul.org
- Delivered-to: pygame-users-outgoing@seul.org
- Delivered-to: pygame-users@seul.org
- Delivery-date: Wed, 07 Feb 2007 05:02:11 -0500
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:Date:From:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-ID; b=lcZ5Kuw4eT4LDBX4He2pZoRtMsm/lglhAp0Q7XWMmsaQrE4uwjUogFOSFXLBq9ZA1/xNtetqRYSiat8J2zVrKGDJeQ2A7xHxEBo20toOxsdAGu48SNK4sKZkyW433+CYGm+IS34nO7z8mjq84WX8vvJvTHTmKm5EfD3e5yWSD+M=;
- In-reply-to: <6F122A2A-E090-4DF0-A5E6-B09A82AB065E@cse.unsw.edu.au>
- Reply-to: pygame-users@xxxxxxxx
- Sender: owner-pygame-users@xxxxxxxx
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