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


Python pygame.RESIZABLE属性代码示例

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


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

示例1: fullscreen_toggle

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import RESIZABLE [as 别名]
def fullscreen_toggle(self, info):
        """toggle between fullscreen and windowed version with CTRL + F
        current activity will be reset"""
        self.redraw_needed = [True, True, True]
        if self.config.fullscreen is True:
            self.config.fullscreen = False
            self.size = self.wn_size[:]
            self.screen = pygame.display.set_mode(self.size, pygame.RESIZABLE)
            self.fs_rescale(info)
        else:
            self.config.fullscreen = True
            self.size = self.fs_size[:]
            self.screen = pygame.display.set_mode(self.size, pygame.FULLSCREEN)
            self.fs_rescale(info)

            pygame.display.flip() 
开发者ID:imiolek-ireneusz,项目名称:eduActiv8,代码行数:18,代码来源:eduactiv8.py

示例2: sizing

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import RESIZABLE [as 别名]
def sizing(self, size):
        """
        Set various asplect of the app related to the screen size of
        the display and/or window.
        """

        self.log.debug(f"Framebuffer Size: {size[0]} x {size[1]}")

        if self.config["fullscreen"]:
            self.screen = pygame.display.set_mode(size, pygame.FULLSCREEN)
            self.xmax = pygame.display.Info().current_w #  - 35 Why not use full screen in "fullescreen"?
            self.ymax = pygame.display.Info().current_h #  - 5 Why not use full screen in "fullescreen"?
        else:
            self.screen = pygame.display.set_mode(size, pygame.RESIZABLE)
            pygame.display.set_caption('PiWeatherRock')
            self.xmax = pygame.display.get_surface().get_width() - 35
            self.ymax = pygame.display.get_surface().get_height() - 5

        if self.xmax <= 1024:
            self.icon_size = '64'
        else:
            self.icon_size = '256' 
开发者ID:genebean,项目名称:PiWeatherRock,代码行数:24,代码来源:weather.py

示例3: __init__

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import RESIZABLE [as 别名]
def __init__(self,_parent,_root):
        BuilderPanel.__init__(self, _parent, _root)
        self.config(bg="pink")
        #Create Pygame Panel
        os.environ['SDL_WINDOWID'] = str(self.winfo_id())
        if sys.platform == "win32":
            os.environ['SDL_VIDEODRIVER'] = 'windib'
        else:
            os.environ['SDL_VIDEODRIVER'] = 'x11'
        
        pygame.display.init()
        pygame.mixer.init()
        _root.update()
        
        self.screen = pygame.display.set_mode((self.winfo_width(), self.winfo_height()),pygame.RESIZABLE)
        self.center = (0,0)
        self.scale = 1.0
        
        self.gameLoop() 
开发者ID:digiholic,项目名称:universalSmashSystem,代码行数:21,代码来源:builderWindow.py

示例4: __init__

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import RESIZABLE [as 别名]
def __init__(self, width, height):
        self.width = width
        self.height = height
        self.screen = pygame.display.set_mode((width, height), pygame.RESIZABLE)
        pygame.display.set_caption('Wireframe Display')
        self.background = (255,255,255)

        self.wireframes = {}
        self.displayEdges = True
        self.label_color = (0,0,0)
        self.color_increment = 50
        self.color_cap = 220 - self.color_increment
        
        self.start = 0
        self.end = 0
        
        self.error_text = '' 
开发者ID:VanHulleOne,项目名称:SciSlice,代码行数:19,代码来源:RUN_ME.py

示例5: __init__

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import RESIZABLE [as 别名]
def __init__(self):
        if not os.path.exists(Tank_IMAGE_POSITION):
            os.makedirs(Tank_IMAGE_POSITION)
        pygame.init()
        pygame.font.init()
        self.display = pygame.display
        self.window = self.display.set_mode([SCREEN_WIDTH, SCREEN_HEIGHT], pygame.RESIZABLE, 32)
        self.display.set_caption('坦克世界')
        self.my_tank = MyTank(MY_BIRTH_LEFT, MY_BIRTH_TOP, self.window)
        self.creat_enemy_number = 10
        self.my_tank_lift = 3
        self.creat_enemy(self.creat_enemy_number)
        self.creat_walls()
        self.font = pygame.font.SysFont('kai_ti', 18)
        self.number = 1 
开发者ID:jtyoui,项目名称:Jtyoui,代码行数:17,代码来源:tank.py

示例6: get_event

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import RESIZABLE [as 别名]
def get_event(self):
        global SCREEN_WIDTH, SCREEN_HEIGHT
        event_list = pygame.event.get()
        for event in event_list:
            if event.type == pygame.VIDEORESIZE:
                SCREEN_WIDTH, SCREEN_HEIGHT = event.size
                self.window = self.display.set_mode([SCREEN_WIDTH, SCREEN_HEIGHT], pygame.RESIZABLE, 32)

            if event.type == pygame.QUIT:
                self.end_game()
            if event.type == pygame.KEYDOWN:
                if event.key == pygame.K_w:
                    self.my_tank.direction = U
                elif event.key == pygame.K_s:
                    self.my_tank.direction = D
                elif event.key == pygame.K_a:
                    self.my_tank.direction = L
                elif event.key == pygame.K_d:
                    self.my_tank.direction = R
                else:
                    return None
                self.my_tank.move_stop = False
            elif event.type == pygame.MOUSEBUTTONDOWN:
                if len(TankGame.my_bullet_list) < 3:
                    bullet = self.my_tank.fire()
                    load_music('fire')
                    TankGame.my_bullet_list.append(bullet)
            elif event.type == pygame.KEYUP:
                self.my_tank.move_stop = True 
开发者ID:jtyoui,项目名称:Jtyoui,代码行数:31,代码来源:tank.py

示例7: init_pygame

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import RESIZABLE [as 别名]
def init_pygame(self):
        if self.__is_init is False:
            pygame.init()
            self.display_called = False
            self.screen = pygame.display.set_mode((self.video_width, self.video_height), pygame.RESIZABLE)
            self.font = pygame.font.Font(None, self.fontsize)
            self.__is_init = True 
开发者ID:rte-france,项目名称:Grid2Op,代码行数:9,代码来源:PlotPyGame.py

示例8: main

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import RESIZABLE [as 别名]
def main():
    # Start program
    debug("Starting pygame...")
    pygame.init()
    debug("Defining screen object...")
    if not(args.nodrawing):
        if not(args.save_images):
            infoObject = pygame.display.Info()
            image_icon = pygame.image.load("resources/various/pyrat.ico")
            pygame.display.set_icon(image_icon)
            pygame.display.set_caption("PyRat")
            if args.fullscreen:
                screen = pygame.display.set_mode((infoObject.current_w, infoObject.current_h), pygame.FULLSCREEN)
                args.window_width = infoObject.current_w
                args.window_height = infoObject.current_h
            else:
                screen = pygame.display.set_mode((args.window_width, args.window_height), pygame.RESIZABLE)
        else:
            screen = pygame.surface.Surface((args.window_width, args.window_height))            
            infoObject = ""
    else:        
        screen = ""
        infoObject = ""        
    # Run first game
    debug("Starting first game")
    result = run_game(screen, infoObject)
    # Run other games (if any)
    for i in range(args.tests - 1):
        debug("Starting match number " + str(i))
        print("match " + str(i+2) + "/" + str(args.tests))
        new = run_game(screen, infoObject)
        debug("Aggregating stats")
        result = {x: result.get(x, 0) + new.get(x, 0) for x in set(result).union(new)}
    debug("Writing stats and exiting")
    result = {k: v / args.tests for k, v in result.items()}
    # Print stats and exit
    print("{")
    for key,value in sorted(result.items()):
        print("\t\"" + str(key) + "\": " + str(value))
    print("}")
    pygame.quit() 
开发者ID:vgripon,项目名称:PyRat,代码行数:43,代码来源:pyrat.py

示例9: display_init

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import RESIZABLE [as 别名]
def display_init(self):
        # try to create a surface and check if it fails
        try:
            # fullscreen is the default
            if self.fullscreen:
                # create a hardware accelerated fullscreen surface
                self.display_surface = pygame.display.set_mode(
                    self.display_size, pygame.FULLSCREEN)
            # alternatively try a windowed surface
            else:
                self.display_surface = pygame.display.set_mode(size=self.window_size,
                                                               flags=pygame.RESIZABLE, display=1)
        except Exception as exc:
            print(exc)
            print("Display initialization failed. This program needs a running X-Server.")
            exit()

        self.loadImageCache()
        # get absolute size of the surface independend from what was
        # requested.
        self.display_size = self.display_surface.get_size()

        self.current_wallpaper_surface = pygame.image.load(
            self.wallpaper_path + "/wallpaper.jpg")
        self.current_wallpaper_surface = aspect_scale(
            self.current_wallpaper_surface, self.display_size).convert() 
开发者ID:ct-Open-Source,项目名称:ct-Raspi-Radiowecker,代码行数:28,代码来源:gui.py

示例10: on_resize

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import RESIZABLE [as 别名]
def on_resize(self, size, info):
        if android is None:
            repost = False
            if size[0] < self.config.size_limits[0]:
                size[0] = self.config.size_limits[0]
                repost = True
            if size[0] > self.config.size_limits[2]:
                size[0] = self.config.size_limits[2]
                repost = True

            if size[1] < self.config.size_limits[1]:
                size[1] = self.config.size_limits[1]
                repost = True
            if size[1] > self.config.size_limits[3]:
                size[1] = self.config.size_limits[3]
                repost = True

            if size != self.fs_size or self.config.platform == "macos":
                self.wn_size = size[:]
                self.size = size[:]
            self.screen = pygame.display.set_mode(self.size, pygame.RESIZABLE)

            self.sizer.update_sizer(self.size[0], self.size[1])
            self.fs_rescale(info)
            #self.create_subsurfaces()

            self.config.settings["screenw"] = self.size[0]
            self.config.settings["screenh"] = self.size[1]
            self.config.settings_changed = True
            self.config.save_settings(self.db)

            # TODO check if commenting out the following code affects Windows/MacOS
            """
            if repost:
                pygame.event.post(
                    pygame.event.Event(pygame.VIDEORESIZE, size=self.size[:], w=self.size[0], h=self.size[1]))
            """

        if android is not None:
            self.size = self.android_screen_size[:]
        self.info.rescale_title_space() 
开发者ID:imiolek-ireneusz,项目名称:eduActiv8,代码行数:43,代码来源:eduactiv8.py

示例11: displayMode

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import RESIZABLE [as 别名]
def displayMode():
        return pygame.OPENGL | pygame.RESIZABLE | pygame.DOUBLEBUF 
开发者ID:mcgreentn,项目名称:GDMC,代码行数:4,代码来源:gl_display_context.py

示例12: setWindowSize

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import RESIZABLE [as 别名]
def setWindowSize(self, width, height):
        self.screenSize = (width, height)
        self.displayFlags = pygame.DOUBLEBUF | pygame.OPENGL | pygame.RESIZABLE
        self.screen = pygame.display.set_mode( self.screenSize, self.displayFlags )
        
    # implement by extending class 
开发者ID:stemkoski,项目名称:three.py,代码行数:8,代码来源:Base.py

示例13: gameLoop

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import RESIZABLE [as 别名]
def gameLoop(self):
        global fighter
        #TODO figure out that window snap thing that's messing up a lot
        self.screen = pygame.display.set_mode((self.winfo_width(), self.winfo_height()),pygame.RESIZABLE)
        if fighter: self.centerFighter()
        
        self.screen.fill(pygame.Color("pink"))
        if fighter:
            fighter.mask = None #These don't work inside of the builder
            fighter.draw(self.screen, fighter.sprite.rect.topleft, self.scale)
            for hbox in fighter.active_hitboxes:
                hbox.draw(self.screen,hbox.rect.topleft,self.scale)        
            
        pygame.display.flip()
        #self.after(5, self.gameLoop) #Loop every 5ms 
开发者ID:digiholic,项目名称:universalSmashSystem,代码行数:17,代码来源:builderWindow.py

示例14: __init__

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import RESIZABLE [as 别名]
def __init__(self, **kwargs):
        super().__init__(**kwargs)

        pygame.display.init()

        pygame.display.gl_set_attribute(pygame.GL_CONTEXT_MAJOR_VERSION, self.gl_version[0])
        pygame.display.gl_set_attribute(pygame.GL_CONTEXT_MINOR_VERSION, self.gl_version[1])
        pygame.display.gl_set_attribute(pygame.GL_CONTEXT_PROFILE_MASK, pygame.GL_CONTEXT_PROFILE_CORE)
        pygame.display.gl_set_attribute(pygame.GL_CONTEXT_FORWARD_COMPATIBLE_FLAG, 1)
        pygame.display.gl_set_attribute(pygame.GL_DOUBLEBUFFER, 1)
        pygame.display.gl_set_attribute(pygame.GL_DEPTH_SIZE, 24)

        if self.samples > 1:
            pygame.display.gl_set_attribute(pygame.GL_MULTISAMPLEBUFFERS, 1)
            pygame.display.gl_set_attribute(pygame.GL_MULTISAMPLESAMPLES, self.samples)

        self._depth = 24
        self._flags = pygame.OPENGL | pygame.DOUBLEBUF
        if self.fullscreen:
            self._flags |= pygame.FULLSCREEN

            info = pygame.display.Info()
            desktop_size = info.current_w, info.current_h
            self._width, self._height = desktop_size
            self._buffer_width, self._buffer_height = self._width, self._height
        else:
            if self.resizable:
                self._flags |= pygame.RESIZABLE

        self._set_mode()
        self.title = self._title
        self.cursor = self._cursor
        self.init_mgl_context()
        self.set_default_viewport() 
开发者ID:moderngl,项目名称:moderngl-window,代码行数:36,代码来源:window.py

示例15: __init__

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import RESIZABLE [as 别名]
def __init__(self, title,
                 size=(800, 480),
                 color=(0, 0, 0),
                 text_color=(255, 255, 255),
                 arrow_location=background.ARROW_BOTTOM,
                 arrow_offset=0,
                 debug=False):
        self.__size = size
        self.debug = debug
        self.bg_color = color
        self.text_color = text_color
        self.arrow_location = arrow_location
        self.arrow_offset = arrow_offset

        # Save the desktop mode, shall be done before `setmode` (SDL 1.2.10, and pygame 1.8.0)
        info = pygame.display.Info()

        pygame.display.set_caption(title)
        self.is_fullscreen = False
        self.display_size = (info.current_w, info.current_h)
        self.surface = pygame.display.set_mode(self.__size, pygame.RESIZABLE)

        self._buffered_images = {}
        self._current_background = None
        self._current_foreground = None
        self._print_number = 0
        self._print_failure = False
        self._capture_number = (0, 4)  # (current, max)

        self._pos_map = {self.CENTER: self._center_pos,
                         self.RIGHT: self._right_pos,
                         self.LEFT: self._left_pos}

        # Don't use pygame.mouse.get_cursor() because will be removed in pygame2
        self._cursor = ((16, 16), (0, 0),
                        (0, 0, 64, 0, 96, 0, 112, 0, 120, 0, 124, 0, 126, 0, 127, 0,
                         127, 128, 124, 0, 108, 0, 70, 0, 6, 0, 3, 0, 3, 0, 0, 0),
                        (192, 0, 224, 0, 240, 0, 248, 0, 252, 0, 254, 0, 255, 0, 255,
                         128, 255, 192, 255, 224, 254, 0, 239, 0, 207, 0, 135, 128, 7, 128, 3, 0)) 
开发者ID:pibooth,项目名称:pibooth,代码行数:41,代码来源:window.py


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