当前位置: 首页>>代码示例>>Python>>正文


Python pygame.NOFRAME属性代码示例

本文整理汇总了Python中pygame.NOFRAME属性的典型用法代码示例。如果您正苦于以下问题:Python pygame.NOFRAME属性的具体用法?Python pygame.NOFRAME怎么用?Python pygame.NOFRAME使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在pygame的用法示例。


在下文中一共展示了pygame.NOFRAME属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: splash

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import NOFRAME [as 别名]
def splash(size, name, path="splash.png"):
    environ['SDL_VIDEO_WINDOW_POS'] = "center"
    display.set_caption(name)
    wininfo = display.Info()
    screensize = (wininfo.current_w, wininfo.current_h)
    desktop = ImageGrab.grab()
    screen = display.set_mode(size, NOFRAME, 32)
    background = image.load(path).convert_alpha()
    w, h = size
    w //= 2
    h //= 2
    desktop = desktop.crop((screensize[0] // 2 - w, screensize[1] // 2 - h,
                            screensize[0] // 2 + w, screensize[1] // 2 + h))
    string = desktop.tostring()
    desktop = image.fromstring(string, size, desktop.mode)
    desktop.blit(background, (0, 0))
    screen.blit(desktop, (0, 0))
    display.update() 
开发者ID:Berserker66,项目名称:omnitool,代码行数:20,代码来源:splashlib.py

示例2: take_action

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import NOFRAME [as 别名]
def take_action(self, observations):
    assert len(observations) == 1, 'Keyboard does not support multiple player control'
    if not self._init_done:
      self._init_done = True
      pygame.display.set_mode((1, 1), pygame.NOFRAME)
    active_buttons = {}
    for event in event_queue.get('keyboard'):
      if event.type == pygame.KEYDOWN:
        actions = KEY_TO_ACTIONS.get(event.key, [])
        for a in actions:
          active_buttons[a] = 1
    keys = pygame.key.get_pressed()
    left = keys[pygame.K_LEFT]
    right = keys[pygame.K_RIGHT]
    top = keys[pygame.K_UP]
    bottom = keys[pygame.K_DOWN]
    for key, actions in KEY_TO_ACTIONS.items():
      if keys[key]:
        for a in actions:
          active_buttons[a] = 1
    return self.get_env_action(left, right, top, bottom, active_buttons) 
开发者ID:google-research,项目名称:football,代码行数:23,代码来源:keyboard.py

示例3: __init__

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import NOFRAME [as 别名]
def __init__(self):
        try:
            pygame.init()
            pygame.camera.init()
            pygame.mouse.set_visible(False)
            self.screen = pygame.display.set_mode((800,480),pygame.NOFRAME)
            self.cam_list = pygame.camera.list_cameras()
            self.webcam = pygame.camera.Camera(self.cam_list[0],(32,24))
            self.webcam.start()
            logger.info('Initialized pygame display')
        except:
            logger.warning('Unable to initialize pygame display')
        try:
            self.shared = memcache.Client(['127.0.0.1:11211'], debug=0)
            logger.info('Initialized memcache client')
        except:
            logger.warning('Unable to initialize memcache client')

        self.canny = False
        self.ph = '6.5'
        self.ec = '3.2'
        self.water_temp = '20.1'
        self.air_temp = '21.1'
        self.humidity = '38'
        self.co2 = '410'
        self.o2 = '17.1'
        # self.figure = matplotlib.pyplot.figure()
        # self.plot = self.figure.add_subplot(111)
        # self.runSeabornEx() 
开发者ID:OpenAgricultureFoundation,项目名称:openag_brain_box,代码行数:31,代码来源:gui.py

示例4: __init__

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import NOFRAME [as 别名]
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 
开发者ID:ntasfi,项目名称:PyGame-Learning-Environment,代码行数:39,代码来源:__init__.py

示例5: show

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import NOFRAME [as 别名]
def show():
    # Show splash screen
    pg.init()
    imgpath = "data/graphics/splash.gif"
    splashimg = pg.image.load(imgpath)
    splashwin = pg.display.set_mode(splashimg.get_size(),pg.NOFRAME)
    splashwin.blit(splashimg,(0,0))
    pg.display.flip()
    return 
开发者ID:TUDelft-CNS-ATM,项目名称:bluesky,代码行数:11,代码来源:splash.py

示例6: __init__

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import NOFRAME [as 别名]
def __init__(self, config_path):
        """Create an instance of the main video looper application class. Must
        pass path to a valid video looper ini configuration file.
        """
        # Load the configuration.
        self._config = configparser.ConfigParser()
        if len(self._config.read(config_path)) == 0:
            raise RuntimeError('Failed to find configuration file at {0}, is the application properly installed?'.format(config_path))
        self._console_output = self._config.getboolean('video_looper', 'console_output')
        # Load other configuration values.
        self._osd = self._config.getboolean('video_looper', 'osd')
        self._is_random = self._config.getboolean('video_looper', 'is_random')
        self._keyboard_control = self._config.getboolean('video_looper', 'keyboard_control')
        # Get seconds for countdown from config
        self._countdown_time = self._config.getint('video_looper', 'countdown_time')
        # Get seconds for waittime bewteen files from config
        self._wait_time = self._config.getint('video_looper', 'wait_time')
        # Parse string of 3 comma separated values like "255, 255, 255" into
        # list of ints for colors.
        self._bgcolor = list(map(int, self._config.get('video_looper', 'bgcolor')
                                             .translate(str.maketrans('','', ','))
                                             .split()))
        self._fgcolor = list(map(int, self._config.get('video_looper', 'fgcolor')
                                             .translate(str.maketrans('','', ','))
                                             .split()))
        # Initialize pygame and display a blank screen.
        pygame.display.init()
        pygame.font.init()
        pygame.mouse.set_visible(False)
        self._screen = pygame.display.set_mode((0,0), pygame.FULLSCREEN | pygame.NOFRAME)
        self._size = (pygame.display.Info().current_w, pygame.display.Info().current_h)
        self._bgimage = self._load_bgimage()
        self._blank_screen()
        # Load configured video player and file reader modules.
        self._player = self._load_player()
        self._reader = self._load_file_reader()
        # Load ALSA hardware configuration.
        self._alsa_hw_device = parse_hw_device(self._config.get('alsa', 'hw_device'))
        self._alsa_hw_vol_control = self._config.get('alsa', 'hw_vol_control')
        self._alsa_hw_vol_file = self._config.get('alsa', 'hw_vol_file')
        # default ALSA hardware volume (volume will not be changed)
        self._alsa_hw_vol = None
        # Load sound volume file name value
        self._sound_vol_file = self._config.get('omxplayer', 'sound_vol_file')
        # default value to 0 millibels (omxplayer)
        self._sound_vol = 0
        # Set other static internal state.
        self._extensions = '|'.join(self._player.supported_extensions())
        self._small_font = pygame.font.Font(None, 50)
        self._big_font   = pygame.font.Font(None, 250)
        self._running    = True
        self._playbackStopped = False
        #used for not waiting the first time
        self._firstStart = True

        # start keyboard handler thread:
        # Event handling for key press, if keyboard control is enabled
        if self._keyboard_control:
            self._keyboard_thread = threading.Thread(target=self._handle_keyboard_shortcuts, daemon=True)
            self._keyboard_thread.start() 
开发者ID:adafruit,项目名称:pi_video_looper,代码行数:62,代码来源:video_looper.py

示例7: __init__

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import NOFRAME [as 别名]
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)) 
开发者ID:ntasfi,项目名称:PyGame-Learning-Environment,代码行数:59,代码来源:ple.py


注:本文中的pygame.NOFRAME属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。