0

http://www.upload.ee/image/2186995/snowman.jpg

I am supposed to draw snowman as shown in the picture.

kast = pygame.Rect(100, 50, 150, 150)
pygame.draw.rect(ekraan, [0, 255, 0], kast, 0)

pygame.draw.circle(ekraan, [100, 100, 100], kast.center, 50, 0)

Here was example. I want to define kast as circle to draw another circle on top but I can't figure out!

import pygame,sys
pygame.init()
ekraan = pygame.display.set_mode([640, 480])
ekraan.fill([255,255,255]) #valge

pygame.draw.circle(ekraan, [255, 0, 0], [50, 50], 25, 0)

kast = pygame.Rect(100, 50, 150, 150)


pygame.draw.rect(ekraan, [0, 255, 0], kast, 0)


pygame.draw.circle(ekraan, [100, 100, 100], kast.center, 50, 0)


pygame.draw.line(ekraan, [0, 0, 225], kast.midleft,ekraan.get_bounding_rect().center,  3)




pygame.display.flip()

while True:#pidevalt kestev tsükkel
for i in pygame.event.get():
    if i.type == pygame.QUIT:
        sys.exit()#paneb mängu kinni
  • Is this code part of a larger program? – Simeon Visser Mar 22 '12 at 19:38
  • wouldn't really say so but I can copy whole code – Armido Maamägi Mar 22 '12 at 20:11
  • Ok, so you do have a rendering loop and this is just some of the rendering code right? In that case, what do you see with your code and what did you want to see? – Simeon Visser Mar 22 '12 at 20:13
  • This is example which was used for teaching us about connecting images.So task is to makes snowman I would like to make 1st "ball" and 2nd "ball" as variable to be able to use them.(variable.midtop) but I don't know how to define circle. – Armido Maamägi Mar 22 '12 at 20:18
  • @ArmidoMaamägi I'm having some trouble understanding your question. What do you mean by "I want to define kast as circle to draw another circle on top"? – Mizipzor Mar 23 '12 at 10:25

1 Answers1

0

If your question is asking how to draw a circle and then access its Rect properties, then

pygame.draw.circle(ekraan, [255, 0, 0], [50, 50], 25, 0)

kast = pygame.Rect(100, 50, 150, 150)

could be changed to:

kast = pygame.draw.circle(ekraan, [255, 0, 0], [50, 50], 25, 0)

This is because in addition to drawing the circle on a surface, draw.circle will return the rectangle outlining the circle.

As stated in the pygame documentation here: http://pygame.org/docs/ref/draw.html#pygame.draw.circle

Da-Jin
  • 221
  • 5
  • 16