Changing the order might help with procedural images. Then you can make the rect's attributes work for you.
self.rect = pygame.Rect(0,0,50,50)
self.image = pygame.surface.Surface(self.rect.size)
pygame.draw.circle(self.image, pygame.Color(0, 0, 255), self.rect.center, self.rect.width/2)
self.image.set_colorkey(pygame.Color('black'))
self.rect.center = 320,0
Gumm
On Mon, Sep 27, 2010 at 2:40 PM, kevin hayes <kevinosky@xxxxxxxxx> wrote:Hey...thank you! I'm now on someone else's computer, so I can't edit the code, but I trust that you are correct. Thanks again. KevinOn Mon, Sep 27, 2010 at 1:37 PM, Christopher Night <cosmologicon@xxxxxxxxx> wrote:
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.-ChristopherOn Mon, Sep 27, 2010 at 4:32 PM, kevin hayes <kevinosky@xxxxxxxxx> wrote:
Hi,This is my attempt at sending a circle(Sprite) vertically from the top of the screen to the bottom. Can someonetell 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 pygamepygame.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 = 320self.rect.centery = 0def update(self):self.rect.centery += 5if self.rect.top > screen.get_height():self.rect.bottom = 0def main():pygame.display.set_caption("Verticle Circle Sprite")background = "">background.fill((255, 255, 255))screen.blit(background, (0, 0))circle = Circle()allSprites = pygame.sprite.Group(circle)clock = pygame.time.Clock()keepGoing = Truewhile keepGoing:clock.tick(30)for event in pygame.event.get():if event.type == pygame.QUIT:keepGoing == FalseallSprites.clear(screen, background)allSprites.update()allSprites.draw(screen)pygame.display.flip()if __name__ == "__main__":main()pygame.quit()
- Follow-Ups:
- References:
- [pygame] moving a filled circle from top to bottom
- From: kevin hayes
- Re: [pygame] moving a filled circle from top to bottom
- From: Christopher Night
- Re: [pygame] moving a filled circle from top to bottom
- From: kevin hayes
- Re: [pygame] moving a filled circle from top to bottom
- From: B W
- Prev by Author: Re: [pygame] moving a filled circle from top to bottom
- Next by Author: Re: [pygame] moving a filled circle from top to bottom
- Previous by thread: Re: [pygame] moving a filled circle from top to bottom
- Next by thread: Re: [pygame] moving a filled circle from top to bottom
- Index(es):