Beispiel #1
0
 def wrapTwoLines(self, words):
     list = [[],[]]
     screen_width = getConfig('window_size')[0]
     while self.font.size(' '.join(words))[0] > screen_width:
         list[1].append(words[len(words) - 1])
         del words[len(words) - 1]
     list[0] = words
     list[1].reverse()
     return list
Beispiel #2
0
 def wordWrap(self, text):
     screen_width = getConfig('window_size')[0]
     if self.font.size(text)[0] > screen_width:
         words = text.split()
         result = []
         list = self.wrapTwoLines(words)
         result.append(list[0])
         while len(list[1]) > 0:
             list = self.wrapTwoLines(list[1])
             result.append(list[0])
         return result
     else:
         return [text]
Beispiel #3
0
def _getConfig():
    return config.getConfig(CONFIG_PATH)
Beispiel #4
0
 def getTextCenterY(self, textList):
     screen_size = getConfig('window_size')
     return (screen_size[1] - len(textList)  * 60) / 2
Beispiel #5
0
 def getTextCenterX(self, text):
     textSize = self.font.size(text)
     screen_size = getConfig('window_size')
     #return ((screen_size[0] - textSize[0])/2, (screen_size[1] - textSize[1])/2)
     return (screen_size[0] - textSize[0])/2
Beispiel #6
0
import pygame
from pygame.locals import *

if not pygame.font: print('Warning, fonts disabled')
if not pygame.mixer: print('Warning, sound disabled')

from internal.scene_action import SceneAction
from internal.action import ActionWait, ActionMove, ActionText, ActionScale
from internal.drawable.emoji import Emoji
from util.observer import Observer, Event
from util.timer import Timer
from util.vector2 import Vector2
from util.config import getConfig, COL_WHITE, COL_BLACK, COL_RED, COL_ORANGE, COL_YELLOW, COL_BLUE, COL_GREEN

pygame.init()
screen = pygame.display.set_mode(tuple(getConfig('window_size')))
pygame.display.set_caption('Python Storytelling')

class Game(Observer):
    """ begun      :: Bool
        scenes     :: [Scene]
        sceneIndex :: Int
    """
    def __init__(self):
        self.begun = False
        self.scenes = []
        self.sceneIndex = -1

    def start(self):
        if not self.begun and not self.isFinished():
            self.getCurrentScene().start(screen)