By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,187 Members | 1,070 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,187 IT Pros & Developers. It's quick & easy.

PyGame and Rotozoom (Sorry if OT)

P: n/a
I'm not sure if this is off-topic, since it doesn't deal with Python
itself, but here goes:

I'm messing around with writing a simple "game" where the player (a
crudely drawn smiley face) moves by rotating and moving back or forward
(think Resident Evil, but from an always-above view). After much
hacking, I have it working where left and right rotate the player sprite
and up always moves the sprite whichever direction it's facing, while
down is reverse. I'm using pygame.transform.RotoZoom().

My problem is that it doesn't rotate smoothly. When it rotates, the
corners of the image (just a plain white background) look like they're
hitting some barrier and making it move around. Think of an empty box
turned diagonally (so that it looks like a diamond, with its open end
facing you), and a cube in that box being turned while it's resting in
the bottom corner. I want it to rotate smoothly around its center, it's
it's not doing that.

I'm guessing that it has something to do with me not setting up a Rect
right, but I'm not sure. Maybe this is a limitation of Rotozoom/Rotate?

Any advice would be greatly appreciated. And yes, I'm a rank PyGame newbie.

Thanks,

J. W. McCall
Jul 19 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
J. W. McCall wrote:
I'm not sure if this is off-topic, since it doesn't deal with Python
itself, but here goes:

I'm messing around with writing a simple "game" where the player (a
crudely drawn smiley face) moves by rotating and moving back or forward
(think Resident Evil, but from an always-above view). After much
hacking, I have it working where left and right rotate the player sprite
and up always moves the sprite whichever direction it's facing, while
down is reverse. I'm using pygame.transform.RotoZoom().

My problem is that it doesn't rotate smoothly. When it rotates, the
corners of the image (just a plain white background) look like they're
hitting some barrier and making it move around. Think of an empty box
turned diagonally (so that it looks like a diamond, with its open end
facing you), and a cube in that box being turned while it's resting in
the bottom corner. I want it to rotate smoothly around its center, it's
it's not doing that.

I'm guessing that it has something to do with me not setting up a Rect
right, but I'm not sure. Maybe this is a limitation of Rotozoom/Rotate?

Any advice would be greatly appreciated. And yes, I'm a rank PyGame
newbie.


I'm not sure - haven't actually used rotozoom, but from the docs it
returns a surface containing the rotated images. The problem with that
is that a rotated surface wont fit in to the same area, so what you get
back will be bigger than the original. If you want to draw it at the
same position, move the rotated surface so that the centre point is the
same as the original unrotated image.

Creating a new sprite each time is probably quite inefficient. You might
want to look at OpenGL, which is excellent for 2D and 3D games.
HTH,

Will McGugan
--
http://www.willmcgugan.com
"".join( [ {'*':'@','^':'.'}.get(c,None) or chr(97+(ord(c)-84)%26) for c
in "jvyy*jvyyzpthtna^pbz" ] )
Jul 19 '05 #2

P: n/a
On 2005-05-20, J. W. McCall <jm*****@houston.rr.com> wrote:
I'm not sure if this is off-topic, since it doesn't deal with Python
itself, but here goes:

I'm messing around with writing a simple "game" where the player (a
crudely drawn smiley face) moves by rotating and moving back or forward
(think Resident Evil, but from an always-above view). After much
hacking, I have it working where left and right rotate the player sprite
and up always moves the sprite whichever direction it's facing, while
down is reverse. I'm using pygame.transform.RotoZoom().

My problem is that it doesn't rotate smoothly. When it rotates, the
corners of the image (just a plain white background) look like they're
hitting some barrier and making it move around. Think of an empty box
turned diagonally (so that it looks like a diamond, with its open end
facing you), and a cube in that box being turned while it's resting in
the bottom corner. I want it to rotate smoothly around its center, it's
it's not doing that.

I'm guessing that it has something to do with me not setting up a Rect
right, but I'm not sure. Maybe this is a limitation of Rotozoom/Rotate?

Any advice would be greatly appreciated. And yes, I'm a rank PyGame newbie.


You might want to try pygsear:
http://www.nongnu.org/pygsear/

It has a RotatedImage class which takes care of rotating
things for you. See the examples roti.py and wings.py
for some use of rotated image sprites.
Jul 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.