def __init__(self): imagePath = os.path.join("images", "horizon.png") self.backgroundImage = view.loadScaledImage(imagePath) imagePath = os.path.join("images", "title.png") self.titleImage = view.loadScaledImage(imagePath, view.TRANSPARENT_COLOUR) self.playLine = titleFont.getTextImage("PRESS SPACE TO PLAY") self.titleTicks = self.getTitleTicks() self.startRegistry = Registry("start", PLAYER_OFF_SCREEN_START, 1) self.screenImage = None self.playState = None self.started = False self.ticks = 0
def loadTileSet(name): # print "load tileset: %s" % (name) # tileSet = map.TileSet() tiles = {} # load tile set image imagePath = os.path.join(TILES_FOLDER, name + ".png") tilesImage = view.loadScaledImage(imagePath, view.TRANSPARENT_COLOUR) # parse metadata - each line represents one tile in the tile set metadataPath = os.path.join(TILES_FOLDER, name + "_metadata.txt") with open(metadataPath) as metadata: # eg. 1,5 lst1 for line in metadata: try: line = line.strip() if len(line) > 0: tilePoint, tileName = line.strip().split() # print "%s -> %s" % (tileRef, tileName) x, y = tilePoint.split(COMMA) px, py = int(x) * view.TILE_SIZE, int(y) * view.TILE_SIZE tileRect = Rect(px, py, view.TILE_SIZE, view.TILE_SIZE) tileImage = tilesImage.subsurface(tileRect).copy() tiles[tileName] = tileImage # self.maskTiles[tileName] = view.createMaskTile(tileImage) except ValueError: pass # create tile set and return return map.TileSet(tiles)
def __init__(self): if NumbersFont.fontImage is None: imagePath = os.path.join(FONT_FOLDER, "numbers.png") NumbersFont.fontImage = view.loadScaledImage(imagePath, None) charImages = view.processFontImage(NumbersFont.fontImage, 8 * SCALAR) Font.__init__(self, NUMBERS, charImages)
def __init__(self): if GameFont.fontImage is None: imagePath = os.path.join(FONT_FOLDER, "font.png") GameFont.fontImage = view.loadScaledImage(imagePath, None) charImages = view.processFontImage(GameFont.fontImage, 8 * SCALAR, 3) Font.__init__(self, CHARS, charImages)