Python pygame.RESIZABLE Examples

The following are 27 code examples of pygame.RESIZABLE(). 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: eduactiv8.py    From eduActiv8 with GNU General Public License v3.0 6 votes vote down vote up
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() 
Example #2
Source File: RUN_ME.py    From SciSlice with MIT License 6 votes vote down vote up
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 = '' 
Example #3
Source File: weather.py    From PiWeatherRock with MIT License 6 votes vote down vote up
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' 
Example #4
Source File: builderWindow.py    From universalSmashSystem with GNU General Public License v3.0 6 votes vote down vote up
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() 
Example #5
Source File: builderWindow.py    From universalSmashSystem with GNU General Public License v3.0 5 votes vote down vote up
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 
Example #6
Source File: gl_display_context.py    From MCEdit-Unified with ISC License 5 votes vote down vote up
def displayMode():
        return pygame.OPENGL | pygame.RESIZABLE | pygame.DOUBLEBUF 
Example #7
Source File: quest.py    From pyscroll with GNU Lesser General Public License v3.0 5 votes vote down vote up
def init_screen(width, height):
    screen = pygame.display.set_mode((width, height), pygame.RESIZABLE)
    return screen


# make loading maps a little easier 
Example #8
Source File: demo.py    From pyscroll with GNU Lesser General Public License v3.0 5 votes vote down vote up
def init_screen(width, height):
    return pygame.display.set_mode((width, height), pygame.RESIZABLE) 
Example #9
Source File: PyKinectBodyGame.py    From PyKinect2 with MIT License 5 votes vote down vote up
def __init__(self):
        pygame.init()

        # Used to manage how fast the screen updates
        self._clock = pygame.time.Clock()

        # Set the width and height of the screen [width, height]
        self._infoObject = pygame.display.Info()
        self._screen = pygame.display.set_mode((self._infoObject.current_w >> 1, self._infoObject.current_h >> 1), 
                                               pygame.HWSURFACE|pygame.DOUBLEBUF|pygame.RESIZABLE, 32)

        pygame.display.set_caption("Kinect for Windows v2 Body Game")

        # 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_Color | PyKinectV2.FrameSourceTypes_Body)

        # back buffer surface for getting Kinect color frames, 32bit color, width and height equal to the Kinect color frame size
        self._frame_surface = pygame.Surface((self._kinect.color_frame_desc.Width, self._kinect.color_frame_desc.Height), 0, 32)

        # here we will store skeleton data 
        self._bodies = None 
Example #10
Source File: PyKinectInfraRed.py    From PyKinect2 with MIT License 5 votes vote down vote up
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() 
Example #11
Source File: PyKinectInfraRed.py    From PyKinect2 with MIT License 5 votes vote down vote up
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") 
Example #12
Source File: RUN_ME.py    From SciSlice with MIT License 5 votes vote down vote up
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() 
Example #13
Source File: window.py    From pibooth with MIT License 5 votes vote down vote up
def toggle_fullscreen(self):
        """Set window to full screen or initial size.
        """
        if self.is_fullscreen:
            self.is_fullscreen = False  # Set before resize
            pygame.mouse.set_cursor(*self._cursor)
            self.surface = pygame.display.set_mode(self.__size, pygame.RESIZABLE)
        else:
            self.is_fullscreen = True  # Set before resize
            # Make an invisible cursor (don't use pygame.mouse.set_visible(False) because
            # the mouse event will always return the window bottom-right coordinate)
            pygame.mouse.set_cursor((8, 8), (0, 0), (0, 0, 0, 0, 0, 0, 0, 0), (0, 0, 0, 0, 0, 0, 0, 0))
            self.surface = pygame.display.set_mode(self.display_size, pygame.FULLSCREEN)

        self.update() 
Example #14
Source File: window.py    From pibooth with MIT License 5 votes vote down vote up
def resize(self, size):
        """Resize the window keeping aspect ratio.
        """
        if not self.is_fullscreen:
            self.__size = size  # Manual resizing
            self.surface = pygame.display.set_mode(self.__size, pygame.RESIZABLE)
        self.update() 
Example #15
Source File: window.py    From pibooth with MIT License 5 votes vote down vote up
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)) 
Example #16
Source File: window.py    From moderngl-window with MIT License 5 votes vote down vote up
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() 
Example #17
Source File: tank.py    From Jtyoui with MIT License 5 votes vote down vote up
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 
Example #18
Source File: Base.py    From three.py with MIT License 5 votes vote down vote up
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 
Example #19
Source File: eduactiv8.py    From eduActiv8 with GNU General Public License v3.0 5 votes vote down vote up
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() 
Example #20
Source File: gui.py    From ct-Raspi-Radiowecker with GNU General Public License v3.0 5 votes vote down vote up
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() 
Example #21
Source File: pyrat.py    From PyRat with GNU General Public License v3.0 5 votes vote down vote up
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() 
Example #22
Source File: PlotPyGame.py    From Grid2Op with Mozilla Public License 2.0 5 votes vote down vote up
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 
Example #23
Source File: PlotPyGame.py    From Grid2Op with Mozilla Public License 2.0 5 votes vote down vote up
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 
Example #24
Source File: tank.py    From Jtyoui with MIT License 5 votes vote down vote up
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 
Example #25
Source File: gl_display_context.py    From GDMC with ISC License 4 votes vote down vote up
def displayMode():
        return pygame.OPENGL | pygame.RESIZABLE | pygame.DOUBLEBUF 
Example #26
Source File: integrations_pygame.py    From pyimgui with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
def main():
    pygame.init()
    size = 800, 600

    pygame.display.set_mode(size, pygame.DOUBLEBUF | pygame.OPENGL | pygame.RESIZABLE)

    imgui.create_context()
    impl = PygameRenderer()

    io = imgui.get_io()
    io.display_size = size

    while 1:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                sys.exit()

            impl.process_event(event)

        imgui.new_frame()

        if imgui.begin_main_menu_bar():
            if imgui.begin_menu("File", True):

                clicked_quit, selected_quit = imgui.menu_item(
                    "Quit", 'Cmd+Q', False, True
                )

                if clicked_quit:
                    exit(1)

                imgui.end_menu()
            imgui.end_main_menu_bar()

        imgui.show_test_window()

        imgui.begin("Custom window", True)
        imgui.text("Bar")
        imgui.text_colored("Eggs", 0.2, 1., 0.)
        imgui.end()

        # note: cannot use screen.fill((1, 1, 1)) because pygame's screen
        #       does not support fill() on OpenGL sufraces
        gl.glClearColor(1, 1, 1, 1)
        gl.glClear(gl.GL_COLOR_BUFFER_BIT)
        imgui.render()
        impl.render(imgui.get_draw_data())

        pygame.display.flip() 
Example #27
Source File: PyKinectBodyGame.py    From PyKinect2 with MIT License 4 votes vote down vote up
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()