Hello I'm back and need more help what I was planning to do was to have little circles randomly places on my screen. How would I go about doing that? Sorry if this is a stupid question still a beginner.
Randomly generated circles in pygame.
pygame.draw.circle? Give it a randomized pos and radius, and boom.
Ah, Ok sorry didn't know it was so simple.
pygame.draw.circle? Give it a randomized pos and radius, and boom.
Ah, Ok sorry didn't know it was so simple.
Can you show me some code?
It would probably be a good exercise for you to figure out. Use what FLeBlanc gave you as well as http://docs.python.org/2/library/random.html#random.randint.
Hmmm, I have this code:
pygame.draw.circle(screen, WHITE, random.randint(0,1600), radius)
And get this error:
pygame.draw.circle(screen, WHITE, random.randint(0,1600), radius)
TypeError: must be 2-item sequence, not int
pygame.draw.circle() wants both an x and a y coordinate.
random.randint(0, 1600) gives you 1 integer (which in this case translates to 1 coordinate).
You need to generate 2 coordinates, and feed them into the draw function.
I don't know the syntax of pygame more than what a minute of googling tells me, but at a guess something like:
pygame.draw.circle(screen, WHITE, (random.randint(0, 1600), random.randint(0, 1600)), radius)
Hello to all my stalkers.
pygame.draw.circle() wants both an x and a y coordinate.
random.randint(0, 1600) gives you 1 integer (which in this case translates to 1 coordinate).
You need to generate 2 coordinates, and feed them into the draw function.
I don't know the syntax of pygame more than what a minute of googling tells me, but at a guess something like:
pygame.draw.circle(screen, WHITE, (random.randint(0, 1600), random.randint(0, 1600)), radius)
I think it worked, but how do I make it appear over another shape?
The pygame draw function returns a Rect, so blit the Rect onto the screen Surface after the other shape has been blitted.