Step 1 - Install and Open a Window

Our first step is to make sure everything is installed, and that we can at least get a window open.

Installation

../../_images/file_structure.png
  • Make sure the Arcade library is installed.

    • Install Arcade with pip install arcade on Windows or pip3 install arcade on Mac/Linux. Or install by using a venv.

    • Here are the longer, official Installation Instructions.

I highly recommend using the free community edition of PyCharm as an editor. If you do, see Install Arcade with PyCharm and a Virtual Environment.

Open a Window

The example below opens up a blank window. Set up a project and get the code below working. (It is also in the zip file as 01_open_window.py.)

Note

This is a fixed-size window. It is possible to have a Resizable Window or a Full Screen Example, but there are more interesting things we can do first. Therefore we’ll stick with a fixed-size window for this tutorial.

01_open_window.py - Open a Window
 1"""
 2Platformer Game
 3"""
 4import arcade
 5
 6# Constants
 7SCREEN_WIDTH = 1000
 8SCREEN_HEIGHT = 650
 9SCREEN_TITLE = "Platformer"
10
11
12class MyGame(arcade.Window):
13    """
14    Main application class.
15    """
16
17    def __init__(self):
18
19        # Call the parent class and set up the window
20        super().__init__(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE)
21
22        arcade.set_background_color(arcade.csscolor.CORNFLOWER_BLUE)
23
24    def setup(self):
25        """ Set up the game here. Call this function to restart the game. """
26        pass
27
28    def on_draw(self):
29        """ Render the screen. """
30
31        arcade.start_render()
32        # Code to draw the screen goes here
33
34
35def main():
36    """ Main method """
37    window = MyGame()
38    window.setup()
39    arcade.run()
40
41
42if __name__ == "__main__":
43    main()

Once you get the code working, figure out how to:

  • Change the screen size

  • Change the title

  • Change the background color

  • Look through the documentation for the Window class to get an idea of everything it can do.