Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/MAFH2
diff options
context:
space:
mode:
authorKevin Hockey <Blitzkev@gmail.com>2010-08-05 00:37:53 (GMT)
committer Kevin Hockey <Blitzkev@gmail.com>2010-08-05 00:37:53 (GMT)
commit868aa7724aa05e6236e8fdff3a922403fc53c8ea (patch)
tree267d1994052f4e44fc6bd0f7db6e2951db8067a3 /MAFH2
parent08c643345ba31474e8ed8e38448f1f998464dc9a (diff)
TermBox integrated
Diffstat (limited to 'MAFH2')
-rwxr-xr-xMAFH2/MafhActivity.py2
-rw-r--r--MAFH2/TermBox.py28
2 files changed, 17 insertions, 13 deletions
diff --git a/MAFH2/MafhActivity.py b/MAFH2/MafhActivity.py
index c148985..584d83d 100755
--- a/MAFH2/MafhActivity.py
+++ b/MAFH2/MafhActivity.py
@@ -7,7 +7,7 @@ from Comic import Comic
from Profile import Profile
from MafhGameManager import MafhGameManager
-ge = GameEngine(width=1200, height=900, always_draw=True)
+ge = GameEngine(width=1200, height=900, always_draw=True, fps_cap=15)
def start_game():
ge.add_object('manager', MafhGameManager() )
diff --git a/MAFH2/TermBox.py b/MAFH2/TermBox.py
index 9a3e6e9..2c93cfc 100644
--- a/MAFH2/TermBox.py
+++ b/MAFH2/TermBox.py
@@ -1,5 +1,7 @@
import pygame
from fortuneengine.GameEngineElement import GameEngineElement
+from fortuneengine.DrawableFontObject import DrawableFontObject
+from fortuneengine.DrawableObject import DrawableObject
class TermBox(GameEngineElement):
def __init__(self, x,y,width,height,lines):
GameEngineElement.__init__(self, has_draw=True, has_event=False)
@@ -7,25 +9,27 @@ class TermBox(GameEngineElement):
self.max_lines = lines
self.x = x
self.y = y
- self.width = width
- self.height = height
+ surf = pygame.Surface((width,height))
+ surf.fill([0,0,0])
+ self.box = DrawableObject([surf],"")
+ self.box.setPosition(x,y)
self.font = pygame.font.Font(None, 20)
self.__lines = []
-
+ for i in range(lines):
+ self.__lines.append(DrawableFontObject('', self.font))
+ self.game_engine.get_scene().addObject(self.box)
+ self.game_engine.get_scene().addObjects(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)
+ for i in range(self.max_lines-1, 0, -1):
+ if i == 0:
+ self.__lines[i].changeText(line, [255,255,255])
+ else:
+ self.__lines[i] = self.__lines[i-1]
def draw(self,screen,time_delta):
- dirtyList=[] #added Jul 20
- 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()))
- dirtyList.append(ren.get_rect().move( (self.x, self.y + i*self.font.get_height()) )) #added Jul 20
+ line.setPosition(self.x, self.y + i*self.font.get_height())
i+=1
- return dirtyList #added Jul 20