# Functions: Drawing with functions¶

This example shows how to define functions that draw objects. Such as draw_tree(x, y) and draw_bird(x, y).

"""
Example "Arcade" library code.

This example shows how to use functions to draw a scene.
It does not assume that the programmer knows how to use classes yet.

A video walk-through of this code is available at:
https://vimeo.com/167296062
"""

# Library imports

# Constants - variables that do not change
SCREEN_WIDTH = 600
SCREEN_HEIGHT = 600

def draw_background():
"""
This function draws the background. Specifically, the sky and ground.
"""
# Draw the sky in the top two-thirds
SCREEN_WIDTH,
SCREEN_HEIGHT,
SCREEN_HEIGHT * (1 / 3),

# Draw the ground in the bottom third
SCREEN_WIDTH,
SCREEN_HEIGHT / 3,
0,

def draw_bird(x, y):
"""
Draw a bird using a couple arcs.
"""
arcade.draw_arc_outline(x, y, 20, 20, arcade.color.BLACK, 0, 90)
arcade.draw_arc_outline(x + 40, y, 20, 20, arcade.color.BLACK, 90, 180)

def draw_pine_tree(x, y):
"""
This function draws a pine tree at the specified location.
"""
# Draw the triangle on top of the trunk
arcade.draw_triangle_filled(x + 40, y,
x, y - 100,
x + 80, y - 100,

# Draw the trunk
arcade.draw_lrtb_rectangle_filled(x + 30, x + 50, y - 100, y - 140,

def main():
"""
This is the main program.
"""

# Open the window
arcade.open_window("Drawing With Functions", SCREEN_WIDTH, SCREEN_HEIGHT)

# Start the render process. This must be done before any drawing commands.

# Call our drawing functions.
draw_background()
draw_pine_tree(50, 250)
draw_pine_tree(350, 320)
draw_bird(70, 500)
draw_bird(470, 550)

# Finish the render.
# Nothing will be drawn without this.
# Must happen after all draw commands