Python pygame.NOFRAME Examples
The following are 10
code examples of pygame.NOFRAME().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
pygame
, or try the search function
.
Example #1
Source File: splashlib.py From omnitool with MIT License | 5 votes |
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()
Example #2
Source File: keyboard.py From football with Apache License 2.0 | 5 votes |
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)
Example #3
Source File: gui.py From openag_brain_box with GNU General Public License v3.0 | 4 votes |
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()
Example #4
Source File: __init__.py From PyGame-Learning-Environment with MIT License | 4 votes |
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
Example #5
Source File: __init__.py From mlclass with MIT License | 4 votes |
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
Example #6
Source File: splash.py From bluesky with GNU General Public License v3.0 | 4 votes |
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
Example #7
Source File: video_looper.py From pi_video_looper with GNU General Public License v2.0 | 3 votes |
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()
Example #8
Source File: ple.py From PyGame-Learning-Environment with MIT License | 3 votes |
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))
Example #9
Source File: ple.py From mlclass with MIT License | 3 votes |
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))
Example #10
Source File: ple.py From humanRL_prior_games with MIT License | 3 votes |
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))