0
\$\begingroup\$

I'm creating a 2D game where the player shoots cannonballs. To give the impression of movement, I want the cannonball to increase its size until half of the path, and then decrease it until it reaches the target (just like rampart game cannonballs).

Right now, I'm doing this in every draw, but the call doesn't increases:

self.CannonImg = pygame.transform.smoothscale(self.CannonImg, (10 + int(auxDistance / 10), 10 + int(auxDistance / 10)))

This is how the image shows up:

Preview

It doesn't scale smoothly, and the image is cut on the edges (over time, it starts to look a little bit transparent).

Is there any easy way to do it?

Also, I'm using images like the following. Though I've been reading, and found some people using sprites. What should I do?

self.CannonImg = pygame.image.load('Imagens/CannonBall.png')
self.surface.blit(self.CannonImg, self.Position)

Thanks!

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

Most like :http://www.pygame.org/docs/ref/transform.html#pygame.transform.scale

If pygame use cpu rescale , you should make set of sprites offline (or make it on level load)

If you can use OpenGL directly, thats trivial task (just quard with texture) - video card will make it for you.

\$\endgroup\$
3
  • \$\begingroup\$ @Alexey Shestacov how can I set em offline? \$\endgroup\$
    – Cafn
    Jan 2, 2015 at 23:20
  • \$\begingroup\$ use any image editor, save set of scaled images, and load then \$\endgroup\$ Jan 3, 2015 at 7:29
  • \$\begingroup\$ Got it working! Several images make it smoother! Thanks ;) \$\endgroup\$
    – Cafn
    Jan 3, 2015 at 20:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .