Beispiel #1
0
    def drawFillBack(self, screen, c1, c2):
        c1Fac = self.C1.depthAdjustFactor() * c.resScale
        c2Fac = self.C2.depthAdjustFactor() * c.resScale

        col = co(c1).interpColors(c2, self.backVal)

        points = [(self.C1.x * c2Fac + c.halfDims[0],
                   c.windowDims[1] - self.C1.y * c2Fac - c.halfDims[1]),
                  (self.C2.x * c2Fac + c.halfDims[0],
                   c.windowDims[1] - self.C1.y * c2Fac - c.halfDims[1]),
                  (self.C2.x * c2Fac + c.halfDims[0],
                   c.windowDims[1] - self.C2.y * c2Fac - c.halfDims[1]),
                  (self.C1.x * c2Fac + c.halfDims[0],
                   c.windowDims[1] - self.C2.y * c2Fac - c.halfDims[1])]

        co.drawPoly(screen, col, points)
        if (self.backVal > 0):
            self.backVal -= self.fadeAmount
        else:
            self.backVal = 0
Beispiel #2
0
    def drawFrameGame(self, update):
        self.screen.fill(self.backCol)
        font = pygame.font.SysFont(None, 70)
        img = font.render(
            'Score: ' + str(c.score), True,
            co((20, 255, 130)).interpColors((255, 255, 255),
                                            self.ball.bounds[1].backVal))
        self.screen.blit(img, (30, c.halfDims[1] + 25))

        font = pygame.font.SysFont(None, 70)
        img = font.render(
            'Lives: ' + str(self.ball.lives), True,
            co((255, 0, 0)).interpColors((255, 255, 255),
                                         self.ball.bounds[0].frontVal))
        self.screen.blit(img, (30, c.halfDims[1] - 25))

        # Draw arena first
        self.ball.bounds[0].drawFillBack(self.screen, (100, 100, 100, 100),
                                         (100, 100, 100, 20))
        self.ball.bounds[0].drawFillRight(self.screen, (100, 100, 100, 100),
                                          (100, 100, 100, 20))
        self.ball.bounds[0].drawFillLeft(self.screen, (100, 100, 100, 100),
                                         (100, 100, 100, 20))
        self.ball.bounds[0].drawFillTop(self.screen, (100, 100, 100, 100),
                                        (100, 100, 100, 20))
        self.ball.bounds[0].drawFillBottom(self.screen, (100, 100, 100, 100),
                                           (100, 100, 100, 20))
        self.ball.bounds[0].drawFillFront(self.screen, (255, 0, 0, 255),
                                          (100, 100, 100, 20))
        self.ball.bounds[0].drawWire(self.screen, 2)

        # Draw opponent second
        self.ball.bounds[2].drawFillBack(self.screen, (100, 100, 100, 100),
                                         (150, 100, 100, 20))
        self.ball.bounds[2].drawFillRight(self.screen, (100, 100, 100, 100),
                                          (150, 100, 100, 20))
        self.ball.bounds[2].drawFillLeft(self.screen, (100, 100, 100, 100),
                                         (150, 100, 100, 20))
        self.ball.bounds[2].drawFillTop(self.screen, (100, 100, 100, 100),
                                        (150, 100, 100, 20))
        self.ball.bounds[2].drawFillBottom(self.screen, (100, 100, 100, 100),
                                           (150, 100, 100, 20))
        self.ball.bounds[2].drawFillFront(self.screen, (255, 0, 0, 255),
                                          (150, 100, 100, 20))
        self.ball.bounds[2].drawWire(self.screen, 2)

        #Draw Power ups
        if len(self.ball.bounds) == 4:
            self.ball.bounds[3].drawFillBack(self.screen, (100, 100, 255, 100),
                                             (100, 100, 255, 20))
            self.ball.bounds[3].drawFillRight(self.screen,
                                              (100, 100, 255, 100),
                                              (100, 100, 255, 20))
            self.ball.bounds[3].drawFillLeft(self.screen, (100, 100, 255, 100),
                                             (100, 100, 255, 20))
            self.ball.bounds[3].drawFillTop(self.screen, (100, 100, 255, 100),
                                            (100, 100, 255, 20))
            self.ball.bounds[3].drawFillBottom(self.screen,
                                               (100, 100, 255, 100),
                                               (100, 100, 255, 20))
            self.ball.bounds[3].drawFillFront(self.screen,
                                              (100, 100, 255, 255),
                                              (100, 100, 255, 20))
            self.ball.bounds[3].drawWire(self.screen, 2)

        # Draw player on top
        self.ball.bounds[1].drawFillBack(self.screen, (100, 255, 130, 255),
                                         (100, 100, 100, 20))
        self.ball.bounds[1].drawFillRight(self.screen, (100, 100, 100, 100),
                                          (100, 100, 100, 20))
        self.ball.bounds[1].drawFillLeft(self.screen, (100, 100, 100, 100),
                                         (100, 100, 100, 20))
        self.ball.bounds[1].drawFillTop(self.screen, (100, 100, 100, 100),
                                        (100, 100, 100, 20))
        self.ball.bounds[1].drawFillBottom(self.screen, (100, 100, 100, 100),
                                           (100, 100, 100, 20))
        self.ball.bounds[1].drawFillFront(self.screen, (100, 100, 100, 100),
                                          (100, 100, 100, 20))
        self.ball.bounds[1].drawWire(self.screen, 2)

        self.ball.draw(self.screen)

        if update:
            pygame.display.flip()
            pygame.display.update()
Beispiel #3
0
    def drawFrameGame(self, update):
        self.screen.fill(self.backCol)

        font = pygame.font.SysFont(None, int(c.windowDims[0] * 0.05))
        img = font.render(
            'Score: ' + str(c.score), True,
            co((20, 255, 130)).interpColors((255, 255, 255),
                                            self.ball.bounds[1].backVal))
        center = img.get_rect(center=(c.windowDims[0] * 0.1,
                                      c.windowDims[1] * 0.4))
        self.screen.blit(img, center)

        img = font.render(
            'Lives: ' + str(self.ball.lives), True,
            co((255, 0, 0)).interpColors((255, 255, 255),
                                         self.ball.bounds[0].frontVal))
        center = img.get_rect(center=(c.windowDims[0] * 0.1,
                                      c.windowDims[1] * 0.6))
        self.screen.blit(img, center)

        # Draw arena first
        if not c.drawWireOnly:
            self.ball.bounds[0].drawFillBack(self.screen, (100, 100, 100, 100),
                                             (100, 100, 100, 20))
            self.ball.bounds[0].drawFillRight(self.screen,
                                              (100, 100, 100, 100),
                                              (100, 100, 100, 20))
            self.ball.bounds[0].drawFillLeft(self.screen, (100, 100, 100, 100),
                                             (100, 100, 100, 20))
            self.ball.bounds[0].drawFillTop(self.screen, (100, 100, 100, 100),
                                            (100, 100, 100, 20))
            self.ball.bounds[0].drawFillBottom(self.screen,
                                               (100, 100, 100, 100),
                                               (100, 100, 100, 20))
            self.ball.bounds[0].drawFillFront(self.screen, (255, 0, 0, 255),
                                              (100, 100, 100, 20))
        if not c.drawMeshOnly:
            self.ball.bounds[0].drawWire(self.screen, 2)

        #Draw Power ups
        if len(self.ball.bounds) == 4:
            if not c.drawWireOnly:
                self.ball.bounds[3].drawFillBack(self.screen,
                                                 (100, 100, 255, 100),
                                                 (100, 100, 255, 20))
                self.ball.bounds[3].drawFillRight(self.screen,
                                                  (100, 100, 255, 100),
                                                  (100, 100, 255, 20))
                self.ball.bounds[3].drawFillLeft(self.screen,
                                                 (100, 100, 255, 100),
                                                 (100, 100, 255, 20))
                self.ball.bounds[3].drawFillTop(self.screen,
                                                (100, 100, 255, 100),
                                                (100, 100, 255, 20))
                self.ball.bounds[3].drawFillBottom(self.screen,
                                                   (100, 100, 255, 100),
                                                   (100, 100, 255, 20))
                self.ball.bounds[3].drawFillFront(self.screen,
                                                  (100, 100, 255, 255),
                                                  (100, 100, 255, 20))
            if not c.drawMeshOnly:
                self.ball.bounds[3].drawWire(self.screen, 2)

        # Draw player on top
        if not c.drawWireOnly:
            self.ball.bounds[1].drawFillBack(self.screen, (100, 255, 130, 255),
                                             (100, 100, 100, 20))
            self.ball.bounds[1].drawFillRight(self.screen,
                                              (100, 100, 100, 100),
                                              (100, 100, 100, 20))
            self.ball.bounds[1].drawFillLeft(self.screen, (100, 100, 100, 100),
                                             (100, 100, 100, 20))
            self.ball.bounds[1].drawFillTop(self.screen, (100, 100, 100, 100),
                                            (100, 100, 100, 20))
            self.ball.bounds[1].drawFillBottom(self.screen,
                                               (100, 100, 100, 100),
                                               (100, 100, 100, 20))
            self.ball.bounds[1].drawFillFront(self.screen,
                                              (100, 100, 100, 100),
                                              (100, 100, 100, 20))
        if not c.drawMeshOnly:
            self.ball.bounds[1].drawWire(self.screen, 2)

        self.ball.draw(self.screen)

        if update:
            pygame.display.flip()
            pygame.display.update()