本文整理汇总了Python中pygame.HWSURFACE属性的典型用法代码示例。如果您正苦于以下问题:Python pygame.HWSURFACE属性的具体用法?Python pygame.HWSURFACE怎么用?Python pygame.HWSURFACE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类pygame
的用法示例。
在下文中一共展示了pygame.HWSURFACE属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _init_renderer
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import HWSURFACE [as 别名]
def _init_renderer(self):
"""Initialize the birdeye view renderer.
"""
pygame.init()
self.display = pygame.display.set_mode(
(self.display_size * 3, self.display_size),
pygame.HWSURFACE | pygame.DOUBLEBUF)
pixels_per_meter = self.display_size / self.obs_range
pixels_ahead_vehicle = (self.obs_range/2 - self.d_behind) * pixels_per_meter
birdeye_params = {
'screen_size': [self.display_size, self.display_size],
'pixels_per_meter': pixels_per_meter,
'pixels_ahead_vehicle': pixels_ahead_vehicle
}
self.birdeye_render = BirdeyeRender(self.world, birdeye_params)
示例2: on_init
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import HWSURFACE [as 别名]
def on_init(self):
pygame.init()
self._display_surf = pygame.display.set_mode(
(self.window_width, self.window_height), pygame.HWSURFACE)
pygame.display.set_caption('The Hearing Snake')
self.game = Game(self.window_width, self.window_height)
img = pygame.image.load('pygame_images/bg.jpg')
img = pygame.transform.scale(img, (self.window_width, self.window_height))
self._bg_image = img.convert()
self.on_load_metadata()
self._running = True
return True
示例3: todo_test_flip
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import HWSURFACE [as 别名]
def todo_test_flip(self):
# __doc__ (as of 2008-08-02) for pygame.display.flip:
# pygame.display.flip(): return None
# update the full display Surface to the screen
#
# This will update the contents of the entire display. If your display
# mode is using the flags pygame.HWSURFACE and pygame.DOUBLEBUF, this
# will wait for a vertical retrace and swap the surfaces. If you are
# using a different type of display mode, it will simply update the
# entire contents of the surface.
#
# When using an pygame.OPENGL display mode this will perform a gl buffer swap.
self.fail()
示例4: __init__
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import HWSURFACE [as 别名]
def __init__(self):
pygame.init()
# pygame.mixer.init()
flags = pygame.DOUBLEBUF | pygame.HWSURFACE # | pygame.FULLSCREEN
self.screen = pygame.display.set_mode((WIDTH, HEIGHT), flags)
pygame.display.set_caption(TITLE)
self.clock = pygame.time.Clock()
self.OFFSET = OFFSET
self.load_data()
示例5: game_loop
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import HWSURFACE [as 别名]
def game_loop(args):
try:
# Init Pygame
pygame.init()
display = pygame.display.set_mode(
(args.width, args.height),
pygame.HWSURFACE | pygame.DOUBLEBUF)
pygame.display.set_caption(args.description)
font = pygame.font.Font(pygame.font.get_default_font(), 20)
text_surface = font.render('Rendering map...', True, COLOR_WHITE)
display.blit(text_surface, text_surface.get_rect(center=(args.width / 2, args.height / 2)))
pygame.display.flip()
# Init modules
input_module = ModuleInput(MODULE_INPUT)
hud_module = ModuleHUD(MODULE_HUD, args.width, args.height)
world_module = ModuleWorld(MODULE_WORLD, args, timeout=2.0)
# Register Modules
module_manager.register_module(world_module)
module_manager.register_module(hud_module)
module_manager.register_module(input_module)
module_manager.start_modules()
clock = pygame.time.Clock()
while True:
clock.tick_busy_loop(60)
module_manager.tick(clock)
module_manager.render(display)
pygame.display.flip()
except KeyboardInterrupt:
print('\nCancelled by user. Bye!')
finally:
if world_module is not None:
world_module.destroy()
示例6: game_loop
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import HWSURFACE [as 别名]
def game_loop(args):
pygame.init()
pygame.font.init()
world = None
try:
client = carla.Client(args.host, args.port)
client.set_timeout(2.0)
display = pygame.display.set_mode(
(args.width, args.height),
pygame.HWSURFACE | pygame.DOUBLEBUF)
hud = HUD(args.width, args.height)
world = WorldSR(client.get_world(), hud, args)
controller = KeyboardControl(world, args.autopilot)
clock = pygame.time.Clock()
while True:
clock.tick_busy_loop(60)
if controller.parse_events(client, world, clock):
return
if not world.tick(clock):
return
world.render(display)
pygame.display.flip()
finally:
if (world and world.recording_enabled):
client.stop_recorder()
if world is not None:
world.destroy()
pygame.quit()
# ==============================================================================
# -- main() --------------------------------------------------------------------
# ==============================================================================
示例7: __init__
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import HWSURFACE [as 别名]
def __init__(self, parent):
self.quit = False
self._parent = parent
self._width = 800
self._height = 600
self._throttle_delta = 0.05
self._steering_delta = 0.01
self._surface = None
pygame.init()
pygame.font.init()
self._clock = pygame.time.Clock()
self._display = pygame.display.set_mode((self._width, self._height), pygame.HWSURFACE | pygame.DOUBLEBUF)
pygame.display.set_caption("Human Agent")
示例8: run_task
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import HWSURFACE [as 别名]
def run_task(self, sample):
try:
pygame.init()
pygame.font.init()
self.hud = HUD(*self.display_dim)
self.display = pygame.display.set_mode(
self.display_dim,
pygame.HWSURFACE | pygame.DOUBLEBUF
)
# print("[carla_task] Setting up world.")
if self.client.get_world().get_map().name == self.world_map:
self.world = World(self.client.get_world(), self.hud,
cam_transform=self.cam_transform)
else:
self.world = World(self.client.load_world(self.world_map),
self.hud, cam_transform=self.cam_transform)
# print("[carla_task] World setup complete.")
self.use_sample(sample)
self.world.restart()
self.timestep = 0
while self.timestep < self.n_sim_steps:
self.step_world()
self.timestep += 1
traj = self.trajectory_definition()
finally:
self.world.destroy()
pygame.quit()
return traj
示例9: get_display
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import HWSURFACE [as 别名]
def get_display(window_size, mode=pygame.HWSURFACE | pygame.DOUBLEBUF):
"""Returns a display used to render images and text.
:param window_size: a tuple (width: int, height: int)
:param mode: pygame rendering mode. Default: pygame.HWSURFACE | pygame.DOUBLEBUF
:return: a pygame.display instance.
"""
return pygame.display.set_mode(window_size, mode)
示例10: __init__
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import HWSURFACE [as 别名]
def __init__(self, ai_settings: Settings, stats: GameStats, **kwargs: game_items_types):
"""Initialize with default items unless specified in kwargs."""
# Default initializations for game items.
# Initialize screen.
flags = pygame.HWSURFACE | pygame.DOUBLEBUF # | pygame.FULLSCREEN
self.screen = pygame.display.set_mode((ai_settings.screen_width, ai_settings.screen_height), flags)
pygame.display.set_caption("Alien Invasion Game")
# Initialize ship.
self.ship = Ship(ai_settings, self.screen)
# Initialize aliens group.
self.aliens = Group()
# Initialize bullets group.
self.bullets = Group()
# Initialize buttons.
self.play_button = Button(self.screen, "Play!")
# TODO implement Restart and Cancel buttons.
# self.restart_button = Button(self.screen, "Restart")
# self.cancel_button = Button(self.screen, "Cancel", (255, 0, 0, 80))
# self.set_button_pos()
# Initialize scorecard.
self.sb = Scorecard(ai_settings, stats, self.screen)
# Set the game items for those default values are given.
for game_item in kwargs:
if game_item in self.acceptable_game_items:
self.__setattr__(game_item, kwargs[game_item])
示例11: loader
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import HWSURFACE [as 别名]
def loader(self):
pygame.init()
self.surface = pygame.display.set_mode((self.Width, self.Height), pygame.HWSURFACE)
self._running = True
self._image_surf = pygame.image.load("snake.png").convert()
self._Frog_surf = pygame.image.load("frog-main.png").convert()
示例12: game_loop
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import HWSURFACE [as 别名]
def game_loop(args):
pygame.init()
pygame.font.init()
world = None
try:
client = carla.Client(args.host, args.port)
client.set_timeout(2.0)
display = pygame.display.set_mode(
(args.width, args.height),
pygame.HWSURFACE | pygame.DOUBLEBUF)
hud = HUD(args.width, args.height)
world = World(client.get_world(), hud)
controller = KeyboardControl(world, args.autopilot)
clock = pygame.time.Clock()
while True:
clock.tick_busy_loop(60)
if controller.parse_events(world, clock):
return
world.tick(clock)
world.render(display)
pygame.display.flip()
finally:
if world is not None:
world.destroy()
pygame.quit()
# ==============================================================================
# -- main() --------------------------------------------------------------------
# ==============================================================================
示例13: multi_view_render
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import HWSURFACE [as 别名]
def multi_view_render(images, unit_dimension, actor_configs):
"""Render images based on pygame > 1.9.4
Args:
images (dict):
unit_dimension (list): window size, e.g., [84, 84]
actor_configs (dict): configs of actors
Returns:
N/A.
"""
global i
pygame.init()
surface_seq = ()
poses, window_dim = get_surface_poses(
len(images), unit_dimension, images.keys())
# Get all surfaces.
for actor_id, im in images.items():
if not actor_configs[actor_id]["render"]:
continue
surface = pygame.surfarray.make_surface(im.swapaxes(0, 1) * 128 + 128)
surface_seq += ((surface, (poses[actor_id][1], poses[actor_id][0])), )
display = pygame.display.set_mode((window_dim[0], window_dim[1]),
pygame.HWSURFACE | pygame.DOUBLEBUF)
display.blits(blit_sequence=surface_seq, doreturn=1)
pygame.display.flip()
# save to disk
# pygame.image.save(display,
# "/mnt/DATADRIVE1/pygame_surfs/" + str(i) + ".jpeg")
i += 1
示例14: main
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import HWSURFACE [as 别名]
def main():
pg.init()
screen = pg.display.set_mode((1920,1200), pg.FULLSCREEN|pg.DOUBLEBUF|pg.HWSURFACE)
lock = image.DellImage("lock_https.gif")
packet = cnc_packet.build_upload_packet(cnc_packet.build_image_blob(lock, 50, 50))
display_packet(packet, screen)
while True:
x, y = pg.mouse.get_pos()
packet = cnc_packet.build_cursor_packet(x, y)
display_packet(packet, screen)
示例15: __init__
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import HWSURFACE [as 别名]
def __init__(self):
pygame.init()
# Used to manage how fast the screen updates
self._clock = pygame.time.Clock()
# Loop until the user clicks the close button.
self._done = False
# Used to manage how fast the screen updates
self._clock = pygame.time.Clock()
# Kinect runtime object, we want only color and body frames
self._kinect = PyKinectRuntime.PyKinectRuntime(PyKinectV2.FrameSourceTypes_Infrared)
# back buffer surface for getting Kinect infrared frames, 8bit grey, width and height equal to the Kinect color frame size
self._frame_surface = pygame.Surface((self._kinect.infrared_frame_desc.Width, self._kinect.infrared_frame_desc.Height), 0, 24)
# here we will store skeleton data
self._bodies = None
# Set the width and height of the screen [width, height]
self._infoObject = pygame.display.Info()
self._screen = pygame.display.set_mode((self._kinect.infrared_frame_desc.Width, self._kinect.infrared_frame_desc.Height),
pygame.HWSURFACE|pygame.DOUBLEBUF|pygame.RESIZABLE, 32)
pygame.display.set_caption("Kinect for Windows v2 Infrared")