[Pygame] toggle fullscreen mid game

[Pygame] toggle fullscreen mid game

Postby metulburr » Sun May 18, 2014 5:15 pm

I have been trying to get options where you can change the resolution or fullscreen options mid game in an options state. However when i toggle it, sometimes it works, but a lot of times it does not. I end up normally getting stuck in fullscreen not able to window it. What confuses me is that it sometimes does work though.

Currently instead of a state button or something changing fullscreen, i currently have a key press event of F12 toggling fullscreen on and off.
Code: Select all
    def toggle_fullscreen(self):
        if not self.fullscreen:
            self.screen = pg.display.set_mode(self.screensize, pg.FULLSCREEN)
        else:
            self.screen = pg.display.set_mode(self.screensize)
        self.fullscreen = not self.fullscreen
        self.screen_rect = self.screen.get_rect()


the repo
https://github.com/metulburr/FloodIt

control class
https://github.com/metulburr/FloodIt/bl ... control.py

tested on ubuntu 14.04
New Users, Read This
OS Ubuntu 14.04, Arch Linux, Gentoo, Windows 7/8
https://github.com/metulburr
steam
User avatar
metulburr
 
Posts: 1499
Joined: Thu Feb 07, 2013 4:47 pm
Location: Elmira, NY

Re: [Pygame] toggle fullscreen mid game

Postby metulburr » Sun May 18, 2014 5:53 pm

figured it out. I forgot:
Code: Select all
        pg.display.quit()
        pg.display.init()


before setting the new display.
New Users, Read This
OS Ubuntu 14.04, Arch Linux, Gentoo, Windows 7/8
https://github.com/metulburr
steam
User avatar
metulburr
 
Posts: 1499
Joined: Thu Feb 07, 2013 4:47 pm
Location: Elmira, NY


Return to Game Development

Who is online

Users browsing this forum: No registered users and 2 guests