codythecoder
codythecoder

Reputation: 452

Making a surface fullscreen in pygame

I have a display surface

screen = pygame.display.set_mode((640, 480), pygame.RESIZABLE)

which I then want to make fullscreen which I do by

screen = pygame.display.set_mode((0, 0), pygame.FULLSCREEN)

Which causes the screen to go to fullscreen. However, the surface does not take up the full computer screen, having black spaces on either side, and the mouse will only move within the surface area. How can I get the surface to take up the full area of my computer screen? I'm using python 3.3 with pygame 1.9.2a0.

Upvotes: 2

Views: 5110

Answers (2)

Michael Maloney
Michael Maloney

Reputation: 11

screen = pygame.display.set_mode((0, 0), pygame.FULLSCREEN

This is the only line of script you need to use for what you want. Using the following line of script you add parameters to the fullscreen code above and limits how far the game can expand.

screen = pygame.display.set_mode((640, 480), pygame.RESIZABLE)

So by deleting that your game should expand to the full size of your screen without a problem. This is an example of the code I am using.

# Set the height and width of the screen
screen_width = 1350
screen_height =620
screen = pygame.display.set_mode((0, 0), pygame.FULLSCREEN)

If I were to put the re-sizable code in conjunction with what I have now, it will use the screen_width and screen_height for how big the game is full-screen. I tested this to make sure. Hope I was able to help you.

Upvotes: 1

Perturbed Python
Perturbed Python

Reputation: 52

I think I see the problem.

Yes, pygame will make the game fullscreen, but the dimensions you chose limits game interaction area, and making those black thingies.

I suggest making the dimensions a bit bigger.

Upvotes: 3

Related Questions