Ejemplo n.º 1
0
def setup_graphics(width=pygalaxy_util.WIDTH,
                   height=pygalaxy_util.HEIGHT,
                   fullscreen=pygalaxy_util.DEFAULT_FULLSCREEN):
    """
    Set up and open a window for graphics drawing.

    This function must be called before any graphics can be drawn.
    Pygame only allows one window open at a time.  If this function
    is called more than once, it will resize the existing window.

    Keyword arguments:
    width -- width of window in pixels
    height -- height of window in pixels
    fullscreen -- if True will turn on fullscreen mode

    """
    global screen
    pygalaxy_util.WIDTH = width
    pygalaxy_util.HEIGHT = height
    if fullscreen:
        pygame.display.set_mode((width, height), pygame.FULLSCREEN)
        # give some time for graphics card to resync with monitor
        # This helps when debugging beginners code
        pygalaxy_util.wait(1.5)
    else:
        pygame.display.set_mode((width, height))
    screen = pygame.display.get_surface()
    pygame.mouse.set_visible(False)
Ejemplo n.º 2
0
def setup_graphics(width=pygalaxy_util.WIDTH, height=pygalaxy_util.HEIGHT, fullscreen=pygalaxy_util.DEFAULT_FULLSCREEN):
    """
    Set up and open a window for graphics drawing.

    This function must be called before any graphics can be drawn.
    Pygame only allows one window open at a time.  If this function
    is called more than once, it will resize the existing window.

    Keyword arguments:
    width -- width of window in pixels
    height -- height of window in pixels
    fullscreen -- if True will turn on fullscreen mode

    """
    global screen
    pygalaxy_util.WIDTH = width
    pygalaxy_util.HEIGHT = height
    if fullscreen:
        pygame.display.set_mode((width, height), pygame.FULLSCREEN)
        # give some time for graphics card to resync with monitor
        # This helps when debugging beginners code
        pygalaxy_util.wait(1.5)
    else:
        pygame.display.set_mode((width, height))
    screen = pygame.display.get_surface()
    pygame.mouse.set_visible(False)
Ejemplo n.º 3
0
def switch_to_fullscreen():
    """
    Switch display to fullscreen.

    Anything on the display is erased and must be redrawn.
    Fullscreen mode may make graphics operations slower or faster
    than windowed mode.

    """
    global screen
    pygame.display.set_mode((pygame_util.WIDTH, pygalaxy_util.HEIGHT), pygame.FULLSCREEN)
    screen = pygame.display.get_surface()
    # Pause for a second to let hardware display new mode
    # This wait means that switch_to_fullscreen() returns to user code
    # at approximately the same time the hardware is ready to display graphics.
    # Helps with beginners code that exits too quickly
    pygalaxy_util.wait(1.5)
Ejemplo n.º 4
0
def switch_to_fullscreen():
    """
    Switch display to fullscreen.

    Anything on the display is erased and must be redrawn.
    Fullscreen mode may make graphics operations slower or faster
    than windowed mode.

    """
    global screen
    pygame.display.set_mode((pygame_util.WIDTH, pygalaxy_util.HEIGHT),
                            pygame.FULLSCREEN)
    screen = pygame.display.get_surface()
    # Pause for a second to let hardware display new mode
    # This wait means that switch_to_fullscreen() returns to user code
    # at approximately the same time the hardware is ready to display graphics.
    # Helps with beginners code that exits too quickly
    pygalaxy_util.wait(1.5)