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#

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"""
 6import arcade
 7
 8# Constants
 9SCREEN_WIDTH = 1000
10SCREEN_HEIGHT = 650
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 and set up the window
22        super().__init__(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE)
23
24        arcade.set_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        self.clear()
34        # Code to draw the screen goes here
35
36
37def main():
38    """Main function"""
39    window = MyGame()
40    window.setup()
41    arcade.run()
42
43
44if __name__ == "__main__":
45    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: