Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def on_draw(delta_time):
arcade.start_render()
# Appear in first column
arcade.draw_circle_filled(100, 100, 50, arcade.color.YELLOW)
# Appear in second column
arcade.draw_small_filled_circle(300, 100, arcade.color.YELLOW)
arcade.draw_medium_filled_circle(300, 300, arcade.color.YELLOW)
arcade.draw_large_filled_circle(300, 500, arcade.color.YELLOW)
# Appear in third column
arcade.draw_standard_circle(500, 100,
arcade.color.YELLOW, "LARGE", "filled")
arcade.draw_standard_circle(500, 300,
arcade.color.YELLOW, "m", "filled")
arcade.draw_standard_circle(500, 500,
arcade.color.YELLOW, "small", "filled")
# Appear in fourth column
arcade.draw_circle_outline(700, 300, 50, arcade.color.YELLOW)
# Draw 2nd level door
arcade.draw_rectangle_outline(190, 310, 30, 60, arcade.color.BONE, 5)
# --- Draw the tractor ---
# Back wheel
arcade.draw_circle_filled(490, 110, 50, arcade.color.BLACK)
arcade.draw_circle_filled(490, 110, 45, arcade.color.BLACK_OLIVE)
arcade.draw_circle_filled(490, 110, 35, arcade.color.OLD_LACE)
arcade.draw_circle_filled(490, 110, 10, arcade.color.RED)
# Front wheel
arcade.draw_circle_filled(650, 90, 30, arcade.color.BLACK)
arcade.draw_circle_filled(650, 90, 25, arcade.color.BLACK_OLIVE)
arcade.draw_circle_filled(650, 90, 18, arcade.color.OLD_LACE)
arcade.draw_circle_filled(650, 90, 5, arcade.color.RED)
# --- Finish drawing ---
arcade.finish_render()
# Keep the window up until someone closes it.
arcade.run()
def draw(self):
""" Draw the balls with the instance variables we have. """
arcade.draw_circle_filled(self.position_x, self.position_y, self.radius, self.color)
def draw_snow_person(x, y):
""" Draw a snow person """
# Draw a point at x, y for reference
arcade.draw_point(x, y, arcade.color.RED, 5)
# Snow
arcade.draw_circle_filled(x, 60 + y, 60, arcade.color.WHITE)
arcade.draw_circle_filled(x, 140 + y, 50, arcade.color.WHITE)
arcade.draw_circle_filled(x, 200 + y, 40, arcade.color.WHITE)
# Eyes
arcade.draw_circle_filled(x - 15, 210 + y, 5, arcade.color.BLACK)
arcade.draw_circle_filled(x + 15, 210 + y, 5, arcade.color.BLACK)
def draw_snow_person(x, y):
""" Draw a snow person """
# Draw a point at x, y for reference
arcade.draw_point(x, y, arcade.color.RED, 5)
# Snow
arcade.draw_circle_filled(x, 60 + y, 60, arcade.color.WHITE)
arcade.draw_circle_filled(x, 140 + y, 50, arcade.color.WHITE)
arcade.draw_circle_filled(x, 200 + y, 40, arcade.color.WHITE)
# Eyes
arcade.draw_circle_filled(x - 15, 210 + y, 5, arcade.color.BLACK)
arcade.draw_circle_filled(x + 15, 210 + y, 5, arcade.color.BLACK)
def draw_snow_person(x, y):
""" Draw a snow person """
# Draw a point at x, y for reference
arcade.draw_point(x, y, arcade.color.RED, 5)
# Snow
arcade.draw_circle_filled(x, 60 + y, 60, arcade.color.WHITE)
arcade.draw_circle_filled(x, 140 + y, 50, arcade.color.WHITE)
arcade.draw_circle_filled(x, 200 + y, 40, arcade.color.WHITE)
# Eyes
arcade.draw_circle_filled(x - 15, 210 + y, 5, arcade.color.BLACK)
arcade.draw_circle_filled(x + 15, 210 + y, 5, arcade.color.BLACK)
def draw_snow_person():
""" Draw a snow person """
# Snow
arcade.draw_circle_filled(300, 200, 60, arcade.color.WHITE)
arcade.draw_circle_filled(300, 280, 50, arcade.color.WHITE)
arcade.draw_circle_filled(300, 340, 40, arcade.color.WHITE)
# Eyes
arcade.draw_circle_filled(285, 350, 5, arcade.color.BLACK)
arcade.draw_circle_filled(315, 350, 5, arcade.color.BLACK)
def main():
arcade.open_window(SCREEN_WIDTH, SCREEN_HEIGHT, "Drawing with Functions")
arcade.set_background_color(arcade.color.DARK_BLUE)
arcade.start_render()
draw_grass()
# Draw a snow person
# Snow
arcade.draw_circle_filled(300, 200, 60, arcade.color.WHITE)
arcade.draw_circle_filled(300, 280, 50, arcade.color.WHITE)
arcade.draw_circle_filled(300, 340, 40, arcade.color.WHITE)
# Eyes
arcade.draw_circle_filled(285, 350, 5, arcade.color.BLACK)
arcade.draw_circle_filled(315, 350, 5, arcade.color.BLACK)
# Finish and run
arcade.finish_render()
arcade.run()
def draw_snow_person(x, y):
""" Draw a snow person """
# Draw a point at x, y for reference
arcade.draw_point(x, y, arcade.color.RED, 5)
# Snow
arcade.draw_circle_filled(300 + x, 200 + y, 60, arcade.color.WHITE)
arcade.draw_circle_filled(300 + x, 280 + y, 50, arcade.color.WHITE)
arcade.draw_circle_filled(300 + x, 340 + y, 40, arcade.color.WHITE)
# Eyes
arcade.draw_circle_filled(285 + x, 350 + y, 5, arcade.color.BLACK)
arcade.draw_circle_filled(315 + x, 350 + y, 5, arcade.color.BLACK)
def draw(_delta_time):
"""
Use this function to draw everything to the screen.
"""
# Start the render. This must happen before any drawing
# commands. We do NOT need an stop render command.
arcade.start_render()
# Draw our rectangle
arcade.draw_circle_filled(draw.x, draw.y, CIRCLE_RADIUS,
arcade.color.BLACK)
# Modify rectangles position based on the delta
# vector. (Delta means change. You can also think
# of this as our speed and direction.)
draw.x += draw.delta_x
draw.y += draw.delta_y
draw.delta_y -= GRAVITY_CONSTANT
# Figure out if we hit the left or right edge and need to reverse.
if draw.x < CIRCLE_RADIUS and draw.delta_x < 0:
draw.delta_x *= -BOUNCINESS
elif draw.x > SCREEN_WIDTH - CIRCLE_RADIUS and draw.delta_x > 0:
draw.delta_x *= -BOUNCINESS