It's extremely minor. Change the center of your circle from (320, 0) to (25,
25). The coordinates are with respect to self.image, not to screen.

-Christopher

On Mon, Sep 27, 2010 at 4:32 PM, kevin hayes <kevino...@gmail.com> wrote:

> Hi,
>         This is my attempt at sending a circle(Sprite) vertically from the
> top of the screen to the bottom.  Can someone
> tell me how to change the code so it works?  Currently it is just creating
> a white screen. Thanks in advance. Kevin
>
> """Attempt at moving a circle(Sprite) from top(of screen) to bottom"""
>
> import pygame
> pygame.init()
>
> screen = pygame.display.set_mode((640, 480))
>
> class Circle(pygame.sprite.Sprite):
>     def __init__(self):
>         pygame.sprite.Sprite.__init__(self)
>         self.image = pygame.Surface((50, 50))
>         self.image.fill((255, 255, 255))
>      #fill with white to hide square???
>         pygame.draw.circle(self.image, (0, 0, 255), (320, 0), 25)
>         self.rect = self.image.get_rect()
>         self.rect.centerx = 320
>         self.rect.centery = 0
>
>     def update(self):
>         self.rect.centery += 5
>         if self.rect.top > screen.get_height():
>             self.rect.bottom = 0
>
>
> def main():
>     pygame.display.set_caption("Verticle Circle Sprite")
>
>     background = pygame.Surface(screen.get_size())
>     background.fill((255, 255, 255))
>     screen.blit(background, (0, 0))
>
>     circle = Circle()
>     allSprites = pygame.sprite.Group(circle)
>
>     clock = pygame.time.Clock()
>     keepGoing = True
>     while keepGoing:
>         clock.tick(30)
>         for event in pygame.event.get():
>             if event.type == pygame.QUIT:
>                 keepGoing == False
>
>         allSprites.clear(screen, background)
>         allSprites.update()
>         allSprites.draw(screen)
>
>         pygame.display.flip()
>
> if __name__ == "__main__":
>     main()
>
> pygame.quit()
>
>

Reply via email to