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

Re: [pygame] pygame.transform.rotate and tick



azazel wrote:
> 1)When I use this function I obtain a strange effect, the rect expand its size and
> the image get an inusual rotation. How can I get a more realistic rotation? 
> Can I avoid the low-left movement?

obviously rotating a square image will require a larger square area than
the original. it is easy to pin the "center" of the rotation by using the
Rect objects. the code looks something like this..

    oldcenter = positionrect.center
    newimage = pygame.transform.rotate(origimage, x)
    positionrect = newimage.get_rect()
    positionrect.center = oldcenter


> 2)What's the best function to use to regulate the game speed? With SDLs I have
> always used a delay function, in pygame I have noticed the pygame.Clock.ticks()
> function, What should I use?

there are two main ways to regulate speed. one is to simple cap the
framerate. this is very easy, but the game will run too slow on slower
computers. you'll need to pick a reasonable minimum machine for your game
to run at and probably cap the speed at whatever speed it plays there. the
other way is a little more advanced, and involves animating objects given a
certain amount of time. for the most part this means your game will run at
the same speed on any computer, it will just have a higher FPS than with
slower machines.

for now you should probably just cap the framerate. you've got the right
idea. use the Clock.tick() function, and you can pass it a maximum speed.
the tick() will then wait until the correct amount of time has passed
before returning.



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