Session 2 Welcome Back!
Arcade Arcade is a library that we will need to import to the top of every program we write from this point on. It helps us draw pictures and build games!
#1: Import Arcade 1 """ 2 This is a sample program to show how to draw using the Python programming 3 language and the Arcade library. 4 """ 5 6 # Import the "arcade" library import arcade 7 The import statement must always be the very first line of code at the top of every program (excluding comments)
#2: Open Window
Did you see that? 1 """ 2 This is a sample program to show how to draw using the Python programming 3 language and the Arcade library. 4 """ 5 6 # Import the "arcade" library import arcade 7 8 9 # Open up a window. 10 # From the "arcade" library, use a function called "open_window" 11 # Set the and dimensions (width and height) 12 # Set the window title to "Drawing Example" arcade . open_window(600, 600, "Drawing Example") 13
#3: Keep Arcade Running 1 """ 2 This is a sample program to show how to draw using the Python 3 programming language and the Arcade library. 4 """ 5 6 # Import the "arcade" library 7 import arcade 8 9 # Open up a window. 10 # From the "arcade" library, use a function called "open_window" 11 # Set the window title to "Drawing Example" 12 # Set the and dimensions (width and height) arcade . open_window(600, 600, "Drawing Example") 13 14 15 # Keep the window up until someone closes it. arcade . run() 16
#4: Render Arcade 1 # Import the "arcade" library import arcade 2 3 4 # Open up a window. 5 arcade . open_window( 600, 600, "Drawing Example") 6 7 # Set the background color 8 arcade . set_background_color(arcade . color . AIR_SUPERIORITY_BL 9 UE) 10 11 # Get ready to draw arcade . start_render() 12 13 14 # (The drawing code will go here.) 15 16 # Finish drawing arcade . finish_render() 17 18 19 # Keep the window up until someone closes it. 20 arcade . run()
Colors Red Value Green Value Blue Value Color 0 0 0 Black 255 255 255 White 127 127 127 Grey 255 0 0 Red 0 255 0 Green 0 0 255 Blue 255 255 0 Yellow
Colors To pick color you have 2 options: 1. Look at the API documentation at http://arcade.academy/arcade.color.html and specify by name, e.g. arcade.color.AQUAMARINE 2. Specify the RGB or RGBA color.
Draw Something!
Position (Coordinates)
Shapes # Left of 5, right of 35 # Top of 590, bottom of 570 #bitter lime color arcade.draw_lrtb_rectangle_filled(5, 35, 590, 570, arcade.color.BITTER_LIME)
Activity 1: drawing_shapes.py Once you’ve run drawing_shapes.py, change around whatever elements of the shapes you want, including: ● What text displays when the window opens ● The background color of the window ● The parameters of each draw function: ○ Width and height of shapes ○ Color of shapes ○ Alpha value of the shapes ○ Angle of the shapes
Activity 2: drawing_picture.py See your course website for instructions, which are under Session 2. Also see “Hints/Notes” for more information. Use your sketches from last session!
Now...what will we draw? Pull out last week’s sketches and use them as a guide!
Don’t forget to add a comment for every piece of the drawing!
Recommend
More recommend