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.

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
 4python -m arcade.examples.platform_tutorial.01_open_window
 5"""
 6from __future__ import annotations
 7
 8import arcade
 9
10# Constants
11SCREEN_WIDTH = 1000
12SCREEN_HEIGHT = 650
13SCREEN_TITLE = "Platformer"
14
15
16class MyGame(arcade.Window):
17    """
18    Main application class.
19    """
20
21    def __init__(self):
22
23        # Call the parent class and set up the window
24        super().__init__(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE)
25
26        self.background_color = arcade.csscolor.CORNFLOWER_BLUE
27
28    def setup(self):
29        """Set up the game here. Call this function to restart the game."""
30        pass
31
32    def on_draw(self):
33        """Render the screen."""
34
35        self.clear()
36        # Code to draw the screen goes here
37
38
39def main():
40    """Main function"""
41    window = MyGame()
42    window.setup()
43    arcade.run()
44
45
46if __name__ == "__main__":
47    main()

You should end up with a window like this:

../../_images/step_01.png

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