Randomly Colored Circle Drawing Function

  • Share this:

Code introduction


This function draws a random colored circle at a random position on the pygame screen.


Technology Stack : pygame

Code Type : Drawing function

Code Difficulty : Intermediate


                
                    
def draw_random_circle(screen, x, y, color, radius=50):
    # Draw a random colored circle on the screen at a given position
    import random
    import pygame

    # Set up the colors
    red = (random.randint(0, 255), random.randint(0, 255), random.randint(0, 255))
    color = red

    # Draw the circle
    pygame.draw.circle(screen, color, (x, y), radius)                
              
Tags: