1 Replies - 672 Views - Last Post: 01 October 2013 - 03:13 AM Rate Topic: -----

#1 Jovito  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 18-September 13

Why pygame.draw.circle doesn't work in this code?

Posted 29 September 2013 - 10:34 PM

I have a ball object that waits one second in the middle of the screen before moving. This is the update method:

def update(self, dt):
    now = pygame.time.get_ticks() / 1000
    if now - self._spawn_time >= BALL_WAIT_TIME: 
        self.rect = self.calcnewpos(dt)
        self.handle_collision()
    else:
        step = 255 / FPS
        value = int(self._frame * step)
        rgb = (value, value, value)
        self._draw_ball(rgb)
        self._frame += 1


That one second happens below the else clause. My goal is to have the ball image go from black (8, 8, 8) to white (255, 255, 255) in that time but as it is _draw_ball doesn't do anything.

def _draw_ball(self, rgb):
    pygame.draw.circle(self.image, rgb, self.rect.center, BALL_RADIUS)


The funny things is, it works the first time when it's called in __init__. I've tried taking lines out of update and testing this code on its own in another module but can't figure out what's the problem. Why is pygame.draw.circle not drawing the the circles in the colors passed by the update method?

Is This A Good Question/Topic? 0
  • +

Replies To: Why pygame.draw.circle doesn't work in this code?

#2 Mekire  Icon User is offline

  • D.I.C Head

Reputation: 118
  • View blog
  • Posts: 216
  • Joined: 11-January 13

Re: Why pygame.draw.circle doesn't work in this code?

Posted 01 October 2013 - 03:13 AM

Would you mind posting your entire program (or at least a working example)? The code where you actually blit this image to the display surface and update it is not shown here.

-Mek
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1