當前位置: 首頁>>代碼示例>>Python>>正文


Python pygame.VIDEORESIZE屬性代碼示例

本文整理匯總了Python中pygame.VIDEORESIZE屬性的典型用法代碼示例。如果您正苦於以下問題:Python pygame.VIDEORESIZE屬性的具體用法?Python pygame.VIDEORESIZE怎麽用?Python pygame.VIDEORESIZE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在pygame的用法示例。


在下文中一共展示了pygame.VIDEORESIZE屬性的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: update

# 需要導入模塊: import pygame [as 別名]
# 或者: from pygame import VIDEORESIZE [as 別名]
def update(self):
        self.keyDownList = []
        self.keyUpList   = []
        self.mouseButtonDown = False
        self.mouseButtonUp   = False
        self.windowResize    = False
        for event in pygame.event.get(): # checks input events (discrete)
            if event.type == pygame.KEYDOWN:
                self.keyDownList.append( event.key )
                self.keyPressedList.append( event.key )
            elif event.type == pygame.KEYUP:
                self.keyPressedList.remove( event.key )
                self.keyUpList.append( event.key )
            elif event.type == pygame.MOUSEBUTTONDOWN:
                self.mouseButtonDown = True
                self.mouseButtonPressed = True
            elif event.type == pygame.MOUSEBUTTONUP:
                self.mouseButtonPressed = False
                self.mouseButtonUp = True
            elif event.type == pygame.QUIT:
                self.quitStatus = True
            elif event.type == pygame.VIDEORESIZE:
                self.windowResize = True
                self.windowWidth = event.w
                self.windowHeight = event.h 
開發者ID:stemkoski,項目名稱:three.py,代碼行數:27,代碼來源:Input.py

示例2: get_event

# 需要導入模塊: import pygame [as 別名]
# 或者: from pygame import VIDEORESIZE [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

示例3: on_resize

# 需要導入模塊: import pygame [as 別名]
# 或者: from pygame import VIDEORESIZE [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

示例4: find_resize_event

# 需要導入模塊: import pygame [as 別名]
# 或者: from pygame import VIDEORESIZE [as 別名]
def find_resize_event(self, events):
        """Return the first found event if found in the list.
        """
        for event in events:
            if event.type == pygame.VIDEORESIZE:
                return event
        return None 
開發者ID:pibooth,項目名稱:pibooth,代碼行數:9,代碼來源:booth.py

示例5: run

# 需要導入模塊: import pygame [as 別名]
# 或者: from pygame import VIDEORESIZE [as 別名]
def run(self):
        # -------- Main Program Loop -----------
        while not self._done:
            # --- Main event loop
            for event in pygame.event.get(): # User did something
                if event.type == pygame.QUIT: # If user clicked close
                    self._done = True # Flag that we are done so we exit this loop

                elif event.type == pygame.VIDEORESIZE: # window resized
                    self._screen = pygame.display.set_mode(event.dict['size'], 
                                                pygame.HWSURFACE|pygame.DOUBLEBUF|pygame.RESIZABLE, 32)
                    

            # --- Getting frames and drawing  
            if self._kinect.has_new_infrared_frame():
                frame = self._kinect.get_last_infrared_frame()
                self.draw_infrared_frame(frame, self._frame_surface)
                frame = None

            self._screen.blit(self._frame_surface, (0,0))
            pygame.display.update()

            # --- Go ahead and update the screen with what we've drawn.
            pygame.display.flip()

            # --- Limit to 60 frames per second
            self._clock.tick(60)

        # Close our Kinect sensor, close the window and quit.
        self._kinect.close()
        pygame.quit() 
開發者ID:Kinect,項目名稱:PyKinect2,代碼行數:33,代碼來源:PyKinectInfraRed.py

示例6: process_events

# 需要導入模塊: import pygame [as 別名]
# 或者: from pygame import VIDEORESIZE [as 別名]
def process_events(self):
        clicked = False
        events = pygame.event.get()
        for event in events:
            # if the event is any type of quit request end the program
            if event.type == pygame.QUIT:
                quit()

            # resize the window if its requested
            elif event.type == pygame.VIDEORESIZE:
                self.window_size = event.size
                self.display_resize()

            # evaluate keypresses
            elif event.type == pygame.KEYDOWN:
                # exit on Escape
                if event.key == pygame.K_ESCAPE:
                    quit()
                # switch to fullscreen on F11
                elif event.key == pygame.K_F11:
                    self.fullscreen = not self.fullscreen

            # evaluate all presses of the left mousebutton
            elif event.type == pygame.MOUSEBUTTONUP and event.button == 1:
                clicked = True
                self.clicktime = pygame.time.get_ticks()
                self.clickEvent = event

        click = None
        timediff = pygame.time.get_ticks() - self.clicktime
        if clicked and self.await_dblclk == False and self.click is None:
            self.await_dblclk = True
            pass
        elif clicked and timediff < self.dblclktime and self.await_dblclk:
            click = "double"
            self.await_dblclk = False
        elif timediff > self.dblclktime and self.await_dblclk:
            click = "single"
            self.await_dblclk = False
        if click != None:
            self.await_dblclk = False
            self.clicktime = 0
            for element in self.elements:
                if hasattr(element, 'Callback') and element.Callback != None and element.Rect.collidepoint(self.clickEvent.pos):
                    if click == "double" and element.DblclkCallback != None:
                        element.DblclkCallback()
                    else:
                        element.Callback()

    # exit the programm 
開發者ID:ct-Open-Source,項目名稱:ct-Raspi-Radiowecker,代碼行數:52,代碼來源:gui.py

示例7: run

# 需要導入模塊: import pygame [as 別名]
# 或者: from pygame import VIDEORESIZE [as 別名]
def run(self):
        ''' Create a pygame screen until it is closed. '''
        pygame.init()
        self.myfont = pygame.font.SysFont('monospace', 15)
        
        #automatically translates image to center of window
        x, y = self.screen.get_size()
        self.translateAll('x', (x/2-self.wireframes[c.MODEL].findcenter()[0]))
        self.translateAll('y', (y/2-self.wireframes[c.MODEL].findcenter()[1]))
        self.scaleAll(4)
        
        while True:
            self.r = 0
            self.b = 0
            self.g = 0
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    pygame.quit()
                    
                elif event.type == pygame.KEYDOWN:
                    if event.key in key_to_function:
                        key_to_function[event.key](self)
                        
                elif event.type == pygame.MOUSEBUTTONDOWN:
                    if event.button == 4:
                        self.scaleAll(1.25)
                    elif event.button == 5:
                        self.scaleAll(0.8)
                elif event.type == pygame.MOUSEMOTION:
                    if event.buttons[0]:
                        shiftX, shiftY = event.rel
                        self.translateAll('x', shiftX)
                        self.translateAll('y', -shiftY)
                    elif event.buttons[2]:
                        rotY, rotX = event.rel
                        self.rotateAll('X', rotX/270)
                        self.rotateAll('Y', rotY/270)
                        
                elif event.type == pygame.VIDEORESIZE:
                    os.environ['SDL_VIDEO_WINDOW_POS'] = '' # Clears the default window location
                    self.width, self.height = event.dict['size']
                    self.screen = pygame.display.set_mode(event.dict['size'], pygame.RESIZABLE)
                    
            self.display()  
            pygame.display.flip() 
開發者ID:VanHulleOne,項目名稱:SciSlice,代碼行數:47,代碼來源:RUN_ME.py

示例8: run

# 需要導入模塊: import pygame [as 別名]
# 或者: from pygame import VIDEORESIZE [as 別名]
def run(self):
        # -------- Main Program Loop -----------
        while not self._done:
            # --- Main event loop
            for event in pygame.event.get(): # User did something
                if event.type == pygame.QUIT: # If user clicked close
                    self._done = True # Flag that we are done so we exit this loop

                elif event.type == pygame.VIDEORESIZE: # window resized
                    self._screen = pygame.display.set_mode(event.dict['size'], 
                                               pygame.HWSURFACE|pygame.DOUBLEBUF|pygame.RESIZABLE, 32)
                    
            # --- Game logic should go here

            # --- Getting frames and drawing  
            # --- Woohoo! We've got a color frame! Let's fill out back buffer surface with frame's data 
            if self._kinect.has_new_color_frame():
                frame = self._kinect.get_last_color_frame()
                self.draw_color_frame(frame, self._frame_surface)
                frame = None

            # --- Cool! We have a body frame, so can get skeletons
            if self._kinect.has_new_body_frame(): 
                self._bodies = self._kinect.get_last_body_frame()

            # --- draw skeletons to _frame_surface
            if self._bodies is not None: 
                for i in range(0, self._kinect.max_body_count):
                    body = self._bodies.bodies[i]
                    if not body.is_tracked: 
                        continue 
                    
                    joints = body.joints 
                    # convert joint coordinates to color space 
                    joint_points = self._kinect.body_joints_to_color_space(joints)
                    self.draw_body(joints, joint_points, SKELETON_COLORS[i])

            # --- copy back buffer surface pixels to the screen, resize it if needed and keep aspect ratio
            # --- (screen size may be different from Kinect's color frame size) 
            h_to_w = float(self._frame_surface.get_height()) / self._frame_surface.get_width()
            target_height = int(h_to_w * self._screen.get_width())
            surface_to_draw = pygame.transform.scale(self._frame_surface, (self._screen.get_width(), target_height));
            self._screen.blit(surface_to_draw, (0,0))
            surface_to_draw = None
            pygame.display.update()

            # --- Go ahead and update the screen with what we've drawn.
            pygame.display.flip()

            # --- Limit to 60 frames per second
            self._clock.tick(60)

        # Close our Kinect sensor, close the window and quit.
        self._kinect.close()
        pygame.quit() 
開發者ID:Kinect,項目名稱:PyKinect2,代碼行數:57,代碼來源:PyKinectBodyGame.py


注:本文中的pygame.VIDEORESIZE屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。