Ejemplo n.º 1
0
    def runningLoop(self):

        mb = pygame.mouse.get_pressed()
        k = pygame.key.get_pressed()

        for e in pygame.event.get():
            if e.type == pygame.QUIT:
                self.running = False

        if self.delay == 0:
            if mb[0] == 1:
                self.cam.screen.rotateAboutY(0.01)
                self.delay = 1
            if mb[2] == 1:
                self.cam.screen.rotateAboutY(-0.01)
                self.delay = 1
            if k[pygame.K_w]:
                self.cam.screen.translate(Geometry.AVector3(1, 0, 0))
                self.delay = 1
            if k[pygame.K_s]:
                self.cam.screen.translate(Geometry.AVector3(-1, 0, 0))
                self.delay = 1
            if k[pygame.K_a]:
                self.cam.screen.translate(Geometry.AVector3(0, 0, 1))
                self.delay = 1
            if k[pygame.K_d]:
                self.cam.screen.translate(Geometry.AVector3(0, 0, -1))
                self.delay = 1
        if self.delay > 0:
            self.delay -= 1

        self.cam.draw()
        self.screen.blit(self.cam.canvas, (0, 0))
        pygame.display.flip()
Ejemplo n.º 2
0
 def __init__(self):
     self.running = True
     self.screen = pygame.display.set_mode((600, 480))
     self.objects = [SL.Cube(0, 0, 0, 100), SL.Cube(100, 0, 0, 50)]
     canvas = Geometry.VPlane(Geometry.AVector3(1, 0, 1),
                              Geometry.AVector3(0, 1, 0),
                              Geometry.Point(0, 0, 0))
     self.cam = Camera(canvas, 150, 480, 600, self.objects)
     self.delay = 0