Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- # Import the "pygame" module
- ############################
- # Import the "random" module
- ############################
- screenW = 600
- # Create a variable "screenH" with the value 400
- #############
- # Create a tuple "white" with three entries of the value 255
- #######################
- pygame.init()
- screen = pygame.display.set_mode((screenW, screenH))
- screen.fill(white)
- pygame.display.set_caption('Target Clicker')
- def createTarget():
- r = random.randint(0, 255)
- # Create a variable "g" (for green) and use
- # random.randint(min, max) to get a random
- # value between 0 and 255
- ##########################
- # Same as before, create a variable called "b"
- # (for blue) and use the random module to
- # clamp it between 0 and 255
- ##########################
- # Create a tuple called "color" and set it
- # to each of the above variables as an entry
- # in the order that they are made
- #################
- # Create a variable "x" and set it to a random
- # value between 0 and the variable "screenW"
- ##############################
- # Create a variable "y" and set it to a random
- # value between 0 and the variable "screenW"
- ##############################
- # Create a tuple called "position" and set it
- # to each of the above variables in the order
- # they are made
- #################
- # Create a variable called "size" and set it
- # to a random value between 10 and 100
- ##############################
- pygame.draw.circle(screen, color, position, size)
- pygame.display.update()
- # Return the values x, y and size
- # Hint: We will need these outside of the function next week!
- #################
- # Call the "createTarget" function
- ##############
- while True:
- for event in pygame.event.get():
- if event.type == pygame.QUIT:
- pygame.quit()
- sys.exit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement