Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/MAFH2/TermBox.py
blob: a273bb5feaae92a039433f95a0b3188b80d50026 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import pygame
from fortuneengine.GameEngineElement import GameEngineElement
class TermBox(GameEngineElement):
    def __init__(self, x,y,width,height,lines):
        GameEngineElement.__init__(self, has_draw=True, has_event=False)

        self.max_lines = lines
        self.x = x
        self.y = y
        self.width = width
        self.height = height
        self.font = pygame.font.Font(None, 20)
        self.__lines = []

        self.add_to_engine()

    def add_line(self, line):
        self.__lines.append( line )
        if len( self.__lines ) > self.max_lines:
            self.__lines.pop(0)

    def draw(self,screen,time_delta):
        pygame.draw.rect(screen, [0, 0, 0], (self.x, self.y, self.width, self.height))
        i=0
        for line in self.__lines:
            ren = self.font.render(line, 1, [255, 255, 255])
            screen.blit(ren, (self.x, self.y + i*self.font.get_height()))
            i+=1