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#

  • Make sure Python is installed. Download Python here if you don’t already have it.

  • Make sure the Arcade library is installed.

    • You should first setup a virtual environment (venv) and activate it.

    • Install Arcade with pip install arcade.

    • Here are the longer, official Installation.

Open a Window#

The example below opens up a blank window. Set up a project and get the code below working.

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
 4python -m arcade.examples.platform_tutorial.01_open_window
 5"""
 6import arcade
 7
 8# Constants
 9SCREEN_WIDTH = 800
10SCREEN_HEIGHT = 600
11SCREEN_TITLE = "Platformer"
12
13
14class MyGame(arcade.Window):
15    """
16    Main application class.
17    """
18
19    def __init__(self):
20
21        # Call the parent class to set up the window
22        super().__init__(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE)
23
24        self.background_color = arcade.csscolor.CORNFLOWER_BLUE
25
26    def setup(self):
27        """Set up the game here. Call this function to restart the game."""
28        pass
29
30    def on_draw(self):
31        """Render the screen."""
32
33        # The clear method should always be called at the start of on_draw.
34        # It clears the whole screen to whatever the background color is
35        # set to. This ensures that you have a clean slate for drawing each
36        # frame of the game.
37        self.clear()
38
39        # Code to draw other things will go here
40
41
42def main():
43    """Main function"""
44    window = MyGame()
45    window.setup()
46    arcade.run()
47
48
49if __name__ == "__main__":
50    main()

You should end up with a window like this:

../../_images/step_01.png

Once you get the code working, try figuring out how to adjust the code so you can:

  • Change the screen size(or even make the Window resizable or fullscreen)

  • Change the title

  • Change the background color

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

Run This Chapter#

python -m arcade.examples.platform_tutorial.01_open_window