Python pygame 模块,NOFRAME 实例源码

我们从Python开源项目中,提取了以下9个代码示例,用于说明如何使用pygame.NOFRAME

项目:openag_brain    作者:OpenAgInitiative    | 项目源码 | 文件源码
def __init__(self):
        self.air_temp = None
        self.humidity = None
        self.co2 = None
        self.o2 = None
        self.water_temp = None
        self.ph = None
        self.ec = None
        self.desired_temp = 25
        self.desired_hum = 50
        self.cmd_temp = 0
        self.cmd_hum = 0
        self.white = [255,255,255]
        self.black = [0,0,0]
        self.event_queue = None

        rospy.loginfo("Initializing touchscreen")
        pygame.init()
        # pygame.mouse.set_visible(False)
        self.screen = pygame.display.set_mode((WIDTH,HEIGHT),pygame.NOFRAME)
项目:n1mm_view    作者:n1kdo    | 项目源码 | 文件源码
def init_display():
    """
    set up the pygame display, full screen
    """

    # Check which frame buffer drivers are available
    # Start with fbcon since directfb hangs with composite output
    drivers = ['fbcon', 'directfb', 'svgalib', 'directx', 'windib']
    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:
            #  logging.warn('Driver: %s failed.' % driver)
            continue
        found = True
        logging.debug('using %s driver', driver)
        break

    if not found:
        raise Exception('No suitable video driver found!')

    size = (pygame.display.Info().current_w, pygame.display.Info().current_h)
    pygame.mouse.set_visible(0)
    if driver != 'directx':  # debugging hack runs in a window on Windows
        screen = pygame.display.set_mode(size, pygame.FULLSCREEN)
    else:
        logging.info('running in windowed mode')
        # set window origin for windowed usage
        os.putenv('SDL_VIDEO_WINDOW_POS', '0,0')
        # size = (size[0]-10, size[1] - 30)
        screen = pygame.display.set_mode(size, pygame.NOFRAME)

    logging.debug('display size: %d x %d', size[0], size[1])
    # Clear the screen to start
    screen.fill(BLACK)
    return screen, size
项目:pygame-event-calendar-and-pianobar    作者:scottpcrawford    | 项目源码 | 文件源码
def main():
    pg.init()
    pg.mouse.set_visible(False) # hide the pointer
    #screen = pg.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT), pg.FULLSCREEN) # windows
    screen = pg.display.set_mode((1920, 1080), pg.NOFRAME) # linux
    game = Game(screen)
    game.create_sprites()
    game.update_calendar()
    game.update_weather()
    game.change_state()
    game.run()
    exit(0)
项目:PyGame-Learning-Environment    作者:ntasfi    | 项目源码 | 文件源码
def __init__(self, width=288, height=512, pipe_gap=100):

        actions = {
            "up": K_w
        }

        fps = 30

        base.PyGameWrapper.__init__(self, width, height, actions=actions)

        self.scale = 30.0 / fps

        self.allowed_fps = 30  # restrict the fps

        self.pipe_gap = pipe_gap
        self.pipe_color = "red"
        self.images = {}

        # so we can preload images
        pygame.display.set_mode((1, 1), pygame.NOFRAME)

        self._dir_ = os.path.dirname(os.path.abspath(__file__))
        self._asset_dir = os.path.join(self._dir_, "assets/")
        self._load_images()

        self.pipe_offsets = [0, self.width * 0.5, self.width]
        self.init_pos = (
            int(self.width * 0.2),
            int(self.height / 2)
        )

        self.pipe_min = int(self.pipe_gap / 4)
        self.pipe_max = int(self.height * 0.79 * 0.6 - self.pipe_gap / 2)

        self.backdrop = None
        self.player = None
        self.pipe_group = None
项目:pyweather    作者:rbischoff    | 项目源码 | 文件源码
def __init__(self, drivers=DEFAULT_DRIVERS, size=DEFAULT_SIZE, screen_type=DEFAULT_SCREEN, borders=(5, 5),
                 border_width=3, line_color=(255, 255, 255), font='freesans', font_color=(255, 255, 255),
                 icons=ICON_DICTIONARY):
        """DisplayDriver class is the class that build the base display for use in the weather
        app.  Argument descriptions: drivers is a tuple of strings with available SDL_VIDEODRIVER
        environmental varaibles; size is a tuple of two integers describing the x, y size of the
        screen; screen_type is a string value that corresponds to the pygame constants for
        dispay.set_mode
        """

        formats = {'no_frame': pygame.NOFRAME, 'full_screen': pygame.FULLSCREEN, 'double_buff': pygame.DOUBLEBUF,
                   'hw_surface': pygame.HWSURFACE, 'open_GL': pygame.OPENGL, 'resizable': pygame.RESIZABLE}

        self._system_data = SystemData()
        self._display_instance = None
        self._drivers = drivers
        self._size = size
        self._borders = borders
        self._border_width = border_width
        self._line_color = line_color
        self._font = font
        self._font_color = font_color
        self._format = formats[screen_type]
        self._icons = icons
        self._base_dir = os.getcwd() + ICON_BASE_DIR
        self._scale_icons = True
        self._xmax = self._size[0] - self._borders[0]
        self._ymax = self._size[1] - self._borders[1]
        self._av = 1
        self._av_time = 1
        self._screen = None
        self._blits = []
项目:Projects    作者:it2school    | 项目源码 | 文件源码
def todo_test_set_mode(self):

        # __doc__ (as of 2008-08-02) for pygame.display.set_mode:

          # pygame.display.set_mode(resolution=(0,0), flags=0, depth=0): return Surface
          # initialize a window or screen for display
          # 
          # This function will create a display Surface. The arguments passed in
          # are requests for a display type. The actual created display will be
          # the best possible match supported by the system.
          # 
          # The resolution argument is a pair of numbers representing the width
          # and height. The flags argument is a collection of additional
          # options.  The depth argument represents the number of bits to use
          # for color.
          # 
          # The Surface that gets returned can be drawn to like a regular
          # Surface but changes will eventually be seen on the monitor.
          # 
          # If no resolution is passed or is set to (0, 0) and pygame uses SDL
          # version 1.2.10 or above, the created Surface will have the same size
          # as the current screen resolution. If only the width or height are
          # set to 0, the Surface will have the same width or height as the
          # screen resolution. Using a SDL version prior to 1.2.10 will raise an
          # exception.
          # 
          # It is usually best to not pass the depth argument. It will default
          # to the best and fastest color depth for the system. If your game
          # requires a specific color format you can control the depth with this
          # argument. Pygame will emulate an unavailable color depth which can
          # be slow.
          # 
          # When requesting fullscreen display modes, sometimes an exact match
          # for the requested resolution cannot be made. In these situations
          # pygame will select the closest compatable match. The returned
          # surface will still always match the requested resolution.
          # 
          # The flags argument controls which type of display you want. There
          # are several to choose from, and you can even combine multiple types
          # using the bitwise or operator, (the pipe "|" character). If you pass
          # 0 or no flags argument it will default to a software driven window.
          # Here are the display flags you will want to choose from:
          # 
          #    pygame.FULLSCREEN    create a fullscreen display
          #    pygame.DOUBLEBUF     recommended for HWSURFACE or OPENGL
          #    pygame.HWSURFACE     hardware accelerated, only in FULLSCREEN
          #    pygame.OPENGL        create an opengl renderable display
          #    pygame.RESIZABLE     display window should be sizeable
          #    pygame.NOFRAME       display window will have no border or controls

        self.fail()
项目:AIFun    作者:Plottel    | 项目源码 | 文件源码
def todo_test_set_mode(self):

        # __doc__ (as of 2008-08-02) for pygame.display.set_mode:

          # pygame.display.set_mode(resolution=(0,0), flags=0, depth=0): return Surface
          # initialize a window or screen for display
          # 
          # This function will create a display Surface. The arguments passed in
          # are requests for a display type. The actual created display will be
          # the best possible match supported by the system.
          # 
          # The resolution argument is a pair of numbers representing the width
          # and height. The flags argument is a collection of additional
          # options.  The depth argument represents the number of bits to use
          # for color.
          # 
          # The Surface that gets returned can be drawn to like a regular
          # Surface but changes will eventually be seen on the monitor.
          # 
          # If no resolution is passed or is set to (0, 0) and pygame uses SDL
          # version 1.2.10 or above, the created Surface will have the same size
          # as the current screen resolution. If only the width or height are
          # set to 0, the Surface will have the same width or height as the
          # screen resolution. Using a SDL version prior to 1.2.10 will raise an
          # exception.
          # 
          # It is usually best to not pass the depth argument. It will default
          # to the best and fastest color depth for the system. If your game
          # requires a specific color format you can control the depth with this
          # argument. Pygame will emulate an unavailable color depth which can
          # be slow.
          # 
          # When requesting fullscreen display modes, sometimes an exact match
          # for the requested resolution cannot be made. In these situations
          # pygame will select the closest compatable match. The returned
          # surface will still always match the requested resolution.
          # 
          # The flags argument controls which type of display you want. There
          # are several to choose from, and you can even combine multiple types
          # using the bitwise or operator, (the pipe "|" character). If you pass
          # 0 or no flags argument it will default to a software driven window.
          # Here are the display flags you will want to choose from:
          # 
          #    pygame.FULLSCREEN    create a fullscreen display
          #    pygame.DOUBLEBUF     recommended for HWSURFACE or OPENGL
          #    pygame.HWSURFACE     hardware accelerated, only in FULLSCREEN
          #    pygame.OPENGL        create an opengl renderable display
          #    pygame.RESIZABLE     display window should be sizeable
          #    pygame.NOFRAME       display window will have no border or controls

        self.fail()
项目:LovelySpace    作者:lmb753    | 项目源码 | 文件源码
def __init__(self):
        self.parameters = Parameters("Config/default.ini")
        if isfile("Config/config.ini") :
            self.parameters.Load("Config/config.ini")

        # screen mode
        screenMode = self.parameters["screenMode"]
        if(screenMode == Screen_mode.Fullscreen) :
            args = pygame.HWSURFACE | pygame.FULLSCREEN | pygame.DOUBLEBUF
        elif(screenMode == Screen_mode.Borderless) :
            os.environ['SDL_VIDEO_WINDOW_POS'] = '0,0'
            args = pygame.NOFRAME
        else:
            args = 0
            os.environ["SDL_VIDEO_CENTERED"] = "1"

        # window icon
        self.icon = pygame.image.load("Assets/icon.png")
        self.icon = pygame.transform.scale(self.icon, (32, 32))
        pygame.display.set_icon(self.icon)

        # window parameters
        self.width = self.parameters["windowWidth"]
        self.height = self.parameters["windowHeight"]

        # some managers and important things
        self.screen = pygame.display.set_mode((self.width, self.height), args)
        pygame.display.set_caption("Lovely Space")
        self.clock = pygame.time.Clock()
        self.input = input.Input(self)
        self.audio = audio.Audio()
        self.size = size.Size(self.width, self.height, 1920, 1080)

        # a random font
        self.fpsFont = pygame.font.SysFont("Arial", 25)

        # drunk shit
        self.iniPosition = pygame.math.Vector2(0, 200)
        self.drunkY = 1
        self.drunkX = 1

        # pause things
        self.pause = None
        self.isPaused = False

        self.mode = titlescreen.TitleScreen(self)
        #self.mode = game.Game(self)
项目:PyGame-Learning-Environment    作者:ntasfi    | 项目源码 | 文件源码
def __init__(self,
                 game, fps=30, frame_skip=1, num_steps=1,
                 reward_values={}, force_fps=True, display_screen=False,
                 add_noop_action=True, state_preprocessor=None, rng=24):

        self.game = game
        self.fps = fps
        self.frame_skip = frame_skip
        self.NOOP = None
        self.num_steps = num_steps
        self.force_fps = force_fps
        self.display_screen = display_screen
        self.add_noop_action = add_noop_action

        self.last_action = []
        self.action = []
        self.previous_score = 0
        self.frame_count = 0

        # update the scores of games with values we pick
        if reward_values:
            self.game.adjustRewards(reward_values)


        if isinstance(self.game, PyGameWrapper):
            if isinstance(rng, np.random.RandomState):
                self.rng = rng
            else:
                self.rng = np.random.RandomState(rng)

            # some pygame games preload the images
            # to speed resetting and inits up.
            pygame.display.set_mode((1, 1), pygame.NOFRAME)
        else:
            # in order to use doom, install following https://github.com/openai/doom-py
            from .games.base.doomwrapper import DoomWrapper
            if isinstance(self.game, DoomWrapper):
                self.rng = rng

        self.game.setRNG(self.rng)
        self.init()

        self.state_preprocessor = state_preprocessor
        self.state_dim = None

        if self.state_preprocessor is not None:
            self.state_dim = self.game.getGameState()

            if self.state_dim is None:
                raise ValueError(
                    "Asked to return non-visual state on game that does not support it!")
            else:
                self.state_dim = self.state_preprocessor(self.state_dim).shape

        if game.allowed_fps is not None and self.fps != game.allowed_fps:
            raise ValueError("Game requires %dfps, was given %d." %
                             (game.allowed_fps, game.allowed_fps))