Open Window

Here we go, let’s write a game. Starting with…opening a window on the screen where our game will live.

Code

import arcade

if __name__ == '__main__':
    arcade.open_window(600, 600, 'Drawing Example')
    arcade.run()
  1. Click the green arrow on line 3 and choose Run.
  2. A new window appears. It’s our game!
  3. Close the window.

Analysis

  • We used two functions imported from arcade
  • open_window is a function which takes 3 arguments
  • run is a function that tells Arcade “ready to go”

Exercises

  1. Change the arguments to open_window, putting the string first. What goes wrong?
  2. Use Ctrl-B to navigate to the implementation of open_Window and see why this fails.
  3. Close that tab, put your cursor inside open_window, and hit Ctrl-P. This is a less-disruptive way to expore.
  4. What happens if you open a window too big for the screen?
  5. Instead of importing arcade then doing arcade.open_window, change to the from blahblah import blahblah, blahblah syntax.

Quiz

  1. What is the name of the function which takes arguments?
  2. What is the data type of that function’s third argument?