Re: [pygame] moving a filled circle from top to bottom

2010-09-29 Thread kevin hayes
Thanks for your reply!

On Wed, Sep 29, 2010 at 9:49 PM, B W  wrote:

> Hi, Kevin.
>
> You already created the example. :) Just replace the few lines in your
> __init__ method.
>
> Note that this is not a "better" way of doing it. It's just an approach
> that I find easier to work with when computing your graphics, i.e.
> "procedural" graphics.
>
> When you load your graphics from an image file, you get a surface sized to
> fit the image and can get your rect from it. In contrast, when computing
> your own graphics it might help to create your dimensions first (the rect)
> and use the rect in plotting your graphics primitives.
>
> Hope that explanation helps.
>
> Gumm
>
> On Wed, Sep 29, 2010 at 8:43 PM, kevin hayes  wrote:
>
>> Hey...my apologies for taking so long to get back to you, I was staying at
>> a friend's house for a couple of days. I honestly don't understand your
>> email. Maybe you could give me a small example...if you wish.
>>
>>
>> On Mon, Sep 27, 2010 at 9:00 PM, B W  wrote:
>>
>>> 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
>>>
>>
>


Re: [pygame] moving a filled circle from top to bottom

2010-09-29 Thread B W
Hi, Kevin.

You already created the example. :) Just replace the few lines in your
__init__ method.

Note that this is not a "better" way of doing it. It's just an approach that
I find easier to work with when computing your graphics, i.e. "procedural"
graphics.

When you load your graphics from an image file, you get a surface sized to
fit the image and can get your rect from it. In contrast, when computing
your own graphics it might help to create your dimensions first (the rect)
and use the rect in plotting your graphics primitives.

Hope that explanation helps.

Gumm

On Wed, Sep 29, 2010 at 8:43 PM, kevin hayes  wrote:

> Hey...my apologies for taking so long to get back to you, I was staying at
> a friend's house for a couple of days. I honestly don't understand your
> email. Maybe you could give me a small example...if you wish.
>
>
> On Mon, Sep 27, 2010 at 9:00 PM, B W  wrote:
>
>> 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
>>
>


Re: [pygame] moving a filled circle from top to bottom

2010-09-29 Thread kevin hayes
Hey...my apologies for taking so long to get back to you, I was staying at a
friend's house for a couple of days. I honestly don't understand your email.
Maybe you could give me a small example...if you wish.

On Mon, Sep 27, 2010 at 9:00 PM, B W  wrote:

> 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  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. Kevin
>>
>>
>> On Mon, Sep 27, 2010 at 1:37 PM, Christopher Night <
>> cosmologi...@gmail.com> 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.
>>>
>>> -Christopher
>>>
>>>
>>> On Mon, Sep 27, 2010 at 4:32 PM, kevin hayes 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()


>>>
>>
>


Re: [pygame] moving a filled circle from top to bottom

2010-09-27 Thread B W
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  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. Kevin
>
>
> On Mon, Sep 27, 2010 at 1:37 PM, Christopher Night  > 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.
>>
>> -Christopher
>>
>>
>> On Mon, Sep 27, 2010 at 4:32 PM, kevin hayes  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()
>>>
>>>
>>
>


Re: [pygame] moving a filled circle from top to bottom

2010-09-27 Thread kevin hayes
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. Kevin

On Mon, Sep 27, 2010 at 1:37 PM, Christopher Night
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.
>
> -Christopher
>
>
> On Mon, Sep 27, 2010 at 4:32 PM, kevin hayes  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()
>>
>>
>


Re: [pygame] moving a filled circle from top to bottom

2010-09-27 Thread Christopher Night
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  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()
>
>