Python 3/PyGame/Game_approaches/camera_in_a_room.py
def run(self):
        """Create a pygame screen until it is closed."""
        pygame.mouse.set_visible(False)
        key_to_function = {
            pygame.K_LEFT:   (lambda x: x.rotateAll('Y', -0.1)),
            pygame.K_RIGHT:   (lambda x: x.rotateAll('Y', 0.1)),
            pygame.K_UP:   (lambda x: x.rotateAll('X', -0.1)),
            pygame.K_DOWN:   (lambda x: x.rotateAll('X', 0.1)),
            pygame.K_q:   (lambda x: x.rotateAll('Z', -0.1)),
            pygame.K_e:   (lambda x: x.rotateAll('Z', 0.1)),
            pygame.K_d:  (lambda x: x.move_all('x', -10)),
            pygame.K_a:   (lambda x: x.move_all('x', 10)),
            pygame.K_s:   (lambda x: x.move_all('z', 10)),
            pygame.K_w:     (lambda x: x.move_all('z', -10)),
            pygame.K_LSHIFT: (lambda x: x.scaleAll(1.25)),
            pygame.K_LCTRL:  (lambda x: x.scaleAll( 0.8))
        }
        done = False
        while not done:
            keys = pygame.key.get_pressed()
            for key in key_to_function.keys():
                if keys[key]:
                    key_to_function[key](self)
            for event in pygame.event.get():
                if event.type == pygame.KEYDOWN:
                    if event.key == pygame.K_ESCAPE:
                        done = True
                        # pygame.event.get()

            self.track_mouse()
            self.move_camera()
            pygame.time.delay(100)
            self.display()
            pygame.display.flip()
        return done
Create a pygame screen until it is closed.
Create a pygame screen until it is closed.
Create a pygame screen until it is closed .
def run(self):
        pygame.mouse.set_visible(False)
        key_to_function = {
            pygame.K_LEFT:   (lambda x: x.rotateAll('Y', -0.1)),
            pygame.K_RIGHT:   (lambda x: x.rotateAll('Y', 0.1)),
            pygame.K_UP:   (lambda x: x.rotateAll('X', -0.1)),
            pygame.K_DOWN:   (lambda x: x.rotateAll('X', 0.1)),
            pygame.K_q:   (lambda x: x.rotateAll('Z', -0.1)),
            pygame.K_e:   (lambda x: x.rotateAll('Z', 0.1)),
            pygame.K_d:  (lambda x: x.move_all('x', -10)),
            pygame.K_a:   (lambda x: x.move_all('x', 10)),
            pygame.K_s:   (lambda x: x.move_all('z', 10)),
            pygame.K_w:     (lambda x: x.move_all('z', -10)),
            pygame.K_LSHIFT: (lambda x: x.scaleAll(1.25)),
            pygame.K_LCTRL:  (lambda x: x.scaleAll( 0.8))
        }
        done = False
        while not done:
            keys = pygame.key.get_pressed()
            for key in key_to_function.keys():
                if keys[key]:
                    key_to_function[key](self)
            for event in pygame.event.get():
                if event.type == pygame.KEYDOWN:
                    if event.key == pygame.K_ESCAPE:
                        done = True
            self.track_mouse()
            self.move_camera()
            pygame.time.delay(100)
            self.display()
            pygame.display.flip()
        return done
def run ( self ) : pygame . mouse . set_visible ( False ) key_to_function = { pygame . K_LEFT : ( lambda x : x . rotateAll ( 'Y' , - 0.1 ) ) , pygame . K_RIGHT : ( lambda x : x . rotateAll ( 'Y' , 0.1 ) ) , pygame . K_UP : ( lambda x : x . rotateAll ( 'X' , - 0.1 ) ) , pygame . K_DOWN : ( lambda x : x . rotateAll ( 'X' , 0.1 ) ) , pygame . K_q : ( lambda x : x . rotateAll ( 'Z' , - 0.1 ) ) , pygame . K_e : ( lambda x : x . rotateAll ( 'Z' , 0.1 ) ) , pygame . K_d : ( lambda x : x . move_all ( 'x' , - 10 ) ) , pygame . K_a : ( lambda x : x . move_all ( 'x' , 10 ) ) , pygame . K_s : ( lambda x : x . move_all ( 'z' , 10 ) ) , pygame . K_w : ( lambda x : x . move_all ( 'z' , - 10 ) ) , pygame . K_LSHIFT : ( lambda x : x . scaleAll ( 1.25 ) ) , pygame . K_LCTRL : ( lambda x : x . scaleAll ( 0.8 ) ) } done = False while not done : keys = pygame . key . get_pressed ( ) for key in key_to_function . keys ( ) : if keys [ key ] : key_to_function [ key ] ( self ) for event in pygame . event . get ( ) : if event . type == pygame . KEYDOWN : if event . key == pygame . K_ESCAPE : done = True self . track_mouse ( ) self . move_camera ( ) pygame . time . delay ( 100 ) self . display ( ) pygame . display . flip ( ) return done
Create a pygame screen until it is closed.
Create a pygame screen until it is closed .
"""Create a pygame screen until it is closed.""" # pygame.event.get()
self