Python Forum
pygame full screen help - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Game Development (https://python-forum.io/forum-11.html)
+--- Thread: pygame full screen help (/thread-28441.html)



pygame full screen help - corsasri - Jul-19-2020

Hi after a bit of help with a bit of code, trying to a game a game to be full in fullscreen. But at the moment its tiny and in the middle of the screen. I`m using a composite set at 720.480.
the code is not mine so this is why i need help figuring it out.
import os, pygame


#Define display class
class pyscope :
    
    screen = None
    pySurface = None
    
    def __init__(self):
        
        "Initializes a new pygame screen using the framebuffer"
        # Based on "Python GUI in Linux frame buffer"
        # http://www.karoltomala.com/blog/?p=679
        disp_no = os.getenv("DISPLAY")
        
        # Check which frame buffer drivers are available
        # Start with fbcon since directfb hangs with composite output
        drivers = ['fbcon', 'directfb', 'svgalib']
        found = False
        for driver in drivers:
            # Make sure that SDL_VIDEODRIVER is set
            if not os.getenv('SDL_VIDEODRIVER'):
                os.putenv('SDL_VIDEODRIVER', driver)
            try:
                pygame.display.init()
            except pygame.error:
                print('Driver: {0} failed.'.format(driver))
                continue
            found = True
            break
    
        if not found:
            raise Exception('No suitable video driver found!')
        size = (pygame.display.Info().current_w, pygame.display.Info().current_h)
        flags = pygame.DOUBLEBUF | pygame.HWSURFACE | pygame.FULLSCREEN
        self.screen = pygame.display.set_mode(size, flags)
        surface = pygame.Surface((320,240),pygame.FULLSCREEN)
        pygame.display.set_mode((320,240),pygame.FULLSCREEN)
        self.pySurface = surface.convert()
        # Initialise font support
        pygame.font.init()
 
    def __del__(self):
        "Destructor to make sure pygame shuts down, etc."



RE: pygame full screen help - nilamo - Jul-24-2020

I'm not sure what the issue is, but I'd suggest simplifying the code a bit. For example, there's no reason to call pygame.display.set_mode() more than once.

For me, this simple example creates a full screen surface. Sometimes, less is more :)
>>> import pygame as pg
pygame 1.9.6
Hello from the pygame community. https://www.pygame.org/contribute.html
>>> pg.init()
(6, 0)
>>> pg.display.set_mode([100, 100], pg.FULLSCREEN)
<Surface(100x100x32 SW)>
>>> pg.quit()



RE: pygame full screen help - reginarodriguez - Mar-20-2024

have you solveduno onlineyour problem?