SHARE
TWEET

Untitled

a guest Jul 22nd, 2019 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import sys
  2.  
  3. # Import the "pygame" module
  4. ############################
  5.  
  6. # Import the "random" module
  7. ############################
  8.  
  9. screenW = 600
  10.  
  11. # Create a variable "screenH" with the value 400
  12. #############
  13.  
  14. # Create a tuple "white" with three entries of the value 255
  15. #######################
  16.  
  17. pygame.init()
  18. screen = pygame.display.set_mode((screenW, screenH))
  19. screen.fill(white)
  20. pygame.display.set_caption('Target Clicker')
  21.  
  22. def createTarget():
  23.     r = random.randint(0, 255)
  24.    
  25.     # Create a variable "g" (for green) and use
  26.     # random.randint(min, max) to get a random
  27.     # value between 0 and 255
  28.     ##########################
  29.    
  30.     # Same as before, create a variable called "b"
  31.     # (for blue) and use the random module to
  32.     # clamp it between 0 and 255
  33.     ##########################
  34.    
  35.     # Create a tuple called "color" and set it
  36.     # to each of the above variables as an entry
  37.     # in the order that they are made
  38.     #################
  39.  
  40.     # Create a variable "x" and set it to a random
  41.     # value between 0 and the variable "screenW"
  42.     ##############################
  43.    
  44.     # Create a variable "y" and set it to a random
  45.     # value between 0 and the variable "screenW"
  46.     ##############################
  47.    
  48.     # Create a tuple called "position" and set it
  49.     # to each of the above variables in the order
  50.     # they are made
  51.     #################
  52.  
  53.     # Create a variable called "size" and set it
  54.     # to a random value between 10 and 100
  55.     ##############################
  56.  
  57.     pygame.draw.circle(screen, color, position, size)
  58.     pygame.display.update()
  59.  
  60.     # Return the values x, y and size
  61.     # Hint: We will need these outside of the function next week!
  62.     #################
  63.  
  64. # Call the "createTarget" function 
  65. ##############
  66.    
  67. while True:
  68.     for event in pygame.event.get():
  69.         if event.type == pygame.QUIT:
  70.             pygame.quit()
  71.             sys.exit()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top