예제 #1
0
 def __drawMessageBox(self, text):
     if text is not None:
         renderedText = self.__messageBoxFont.render(
             text, True, _MESSAGE_BOX_FOREGROUND_COLOR,
             _MESSAGE_BOX_BACKGROUND_COLOR)
         size = renderedText.get_size()
         x = (self.__canvas.right - self.__canvas.left) / 2 - size[0] / 4
         y = (self.__canvas.top - self.__canvas.bottom) / 2 - size[1] / 4
         Drawing.drawRenderedText(x, y, renderedText)
예제 #2
0
    def __drawInformationBar(self, framesPerSecond):
        a = (self.__canvas.left, self.__canvas.top)
        b = (self.__canvas.right, self.__canvas.top)
        c = (self.__canvas.right, self.__canvas.top - _INFORMATION_BAR_HEIGHT)
        d = (self.__canvas.left, self.__canvas.top - _INFORMATION_BAR_HEIGHT)
        Drawing.drawQuadrilateral2d(a, b, c, d, Color.BLACK.value)

        status = (" Level %d | FPS %d | Balls %d | Points %d " %
                  (self.__currentLevel.index, framesPerSecond, len(
                      self.__balls), self.__totalPoints))

        renderedStatus = self.__informationBarFont.render(
            status, True, _INFORMATION_BAR_FOREGROUND_COLOR,
            _INFORMATION_BAR_BACKGROUND_COLOR)
        x = self.__canvas.left
        y = self.__canvas.top - _INFORMATION_BAR_HEIGHT
        Drawing.drawRenderedText(x, y, renderedStatus)
예제 #3
0
 def build(self):
     level = Level(1)
     level.backgroundTexture = Drawing.loadTexture(_BACKGROUND_TEXTURE_FILE,
                                                   False)
     level.backgroundMusic = Sound(_BACKGROUND_MUSIC_FILE)
     level.blocks = self.__buildBlocks()
     level.balls = self.__buildBalls()
     return level
예제 #4
0
    def __drawPaddleSpeedBar(self):
        a = (self.__canvas.left, self.__canvas.bottom)
        b = (self.__canvas.right, self.__canvas.bottom)
        c = (self.__canvas.right,
             self.__canvas.bottom + _PADDLE_SPEED_BAR_HEIGHT)
        d = (self.__canvas.left,
             self.__canvas.bottom + _PADDLE_SPEED_BAR_HEIGHT)
        Drawing.drawQuadrilateral2d(a, b, c, d, Color.BLACK.value)

        median = (self.__canvas.right - self.__canvas.left) / 2
        paddleSpeed = self.__paddle.speed.x

        a = (median, self.__canvas.bottom)
        b = (median, self.__canvas.bottom + _PADDLE_SPEED_BAR_HEIGHT)
        c = (paddleSpeed * median / _PADDLE_MAX_SPEED + median,
             self.__canvas.bottom + _PADDLE_SPEED_BAR_HEIGHT)
        d = (paddleSpeed * median / _PADDLE_MAX_SPEED + median,
             self.__canvas.bottom)
        Drawing.drawQuadrilateral2d(a, b, c, d, Color.OLIVE.value)
예제 #5
0
파일: Paddle.py 프로젝트: felipead/breakout
 def __drawInnerRectangle(self, colorBrightness, x, y, dx, dy):
     innerColor = tuple(i * colorBrightness for i in _INNER_COLOR.value)
     Drawing.drawRectangle2d(x, y, dx - _HORIZONTAL_BORDER, dy - _VERTICAL_BORDER, innerColor)
예제 #6
0
파일: Paddle.py 프로젝트: felipead/breakout
 def __drawOuterRectangle(self, colorBrightness, x, y, dx, dy):
     outerColor = tuple(i * (1-colorBrightness) for i in _OUTER_COLOR.value)
     Drawing.drawRectangle2d(x, y, dx, dy, outerColor)
예제 #7
0
파일: Block.py 프로젝트: felipead/breakout
 def __drawOuterRectangle(self, x, y, dx, dy, colorBrightness):
     outerColor = tuple(i * (1 - colorBrightness) for i in self.color.value)
     Drawing.drawRectangle2d(x, y, dx, dy, outerColor)