import codesters import math stage = codesters.Environment() colors = ["red", "orangered", "orange", "gold", "yellow", "green", "blue", "cyan", "violet", "purple", "black", ] # colors = ["red", "orange", "yellow", "green", "cyan", "blue", "violet", "purple", "black", ] sizes = [5, 15, 25] stage_size = 500 square_size = stage_size/len(colors) x = -stage_size/2 + square_size/2 square_y = stage_size/2 - square_size/2 circ_y = -240 color_ind = 0 size = 10 for color in colors: square = codesters.Square(x, square_y, square_size, color) square.fill() x = x + square_size x = -stage_size/2 + 15 for size in sizes: size_circ = codesters.Circle(x, circ_y - size/10, size, "black") size_circ.fill() circ_y = circ_y + size + 10 def click(): global color_ind global size_ind x = stage.click_x() y = stage.click_y() if y >= stage_size/2 - square_size: color_ind = (x + 250) / square_size elif y <= -190 and x <= -220: size_ind = (y + 250) / 20 else: color = colors[color_ind] size = sizes[size_ind] circle = codesters.Circle(x, y, size, color) circle.fill() stage.event_click(click)
  • Run Code
  • Show Console
  • Codesters How To (opens in a new tab)