Setting up the Display
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. So here on line 19, you’re going to define two constants for the screen width and its height.
So, you’re creating a new object called
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.
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.
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
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. 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!
Become a Member to join the conversation.