Join us and get access to thousands of tutorials and a community of expert Pythonistas.
This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.
Setting up the Display
00:00
In this lesson, you’ll take the next step of setting up the display. You need something to draw on, and you’re going to create this canvas, called a screen.
00:09 So here on line 19, you’re going to define two constants for the screen width and its height.
00:19
800 pixels for the width, 600 pixels for the height. We’ve got to create the screen object.
00:31 Note that it’s determined by the constants that you just created.
00:39
So, you’re creating a new object called screen using pygame.display—and you might remember this from the previous lesson—.set_mode() is the method you call, and inside of it you’re going to give it a tuple.
00:53
You might remember that from the previous example also. In this case, you’re going to use the two constants that you created—SCREEN_WIDTH will be the first one, and then SCREEN_HEIGHT will be the second one.
01:05
So, the width and the height. If you were to save right now and then come down in here to the terminal—and inside that environment that I have, I can type python and sky_dodge—you will probably see a very, very fast blinking of a window of 800 by 600, and then it’ll be gone, but let me have you try it out.
01:28 Because there’s not much else that’s happening here, it’s just setting up the screen. Yep. There it went. Ha, hopefully the screen capture caught it. But that’s it!
01:39
You did it. You’ve set up your screen. The next lesson is a dive into the game loop and how to set it up.
Become a Member to join the conversation.