示例#1
0
文件: tile.py 项目: wolmir/cristina
def loadTileTypes():
	global tileTypes
	tileTypes = {}
	tileDir = (os.path.join(data.data_dir, "tiletypes"))
	for filename in os.listdir(tileDir):
		if filename[-3:].lower() != "txt": continue
		data.trace("  loading "+filename)
		tileTypes[filename] = tile_style(filename)
	
	return True
示例#2
0
文件: powers.py 项目: wolmir/cristina
def loadPowers():
    global powerTypes
    powerTypes = {}
    powerDir = (os.path.join(data.data_dir, "powers"))
    for filename in os.listdir(powerDir):
        if filename[-3:].lower() != "txt": continue
        data.trace("  loading " + filename)
        powerTypes[filename] = power_style(filename)

    return True
示例#3
0
文件: tile.py 项目: wolmir/cristina
def loadTileTypes():
    global tileTypes
    tileTypes = {}
    tileDir = (os.path.join(data.data_dir, "tiletypes"))
    for filename in os.listdir(tileDir):
        if filename[-3:].lower() != "txt": continue
        data.trace("  loading " + filename)
        tileTypes[filename] = tile_style(filename)

    return True
示例#4
0
def loadCreatures():
    global creatureTypes
    creatureTypes = {}
    creatureDir = (os.path.join(data.data_dir, "creatures"))
    for filename in os.listdir(creatureDir):
        if filename[-3:].lower() != "txt": continue
        data.trace("  loading " + filename)
        creatureTypes[filename] = creature_style(filename)

    return True
示例#5
0
def loadCreatures():
	global creatureTypes
	creatureTypes = {}
	creatureDir = (os.path.join(data.data_dir, "creatures"))
	for filename in os.listdir(creatureDir):
		if filename[-3:].lower() != "txt": continue
		data.trace("  loading "+filename)
		creatureTypes[filename] = creature_style(filename)
	
	return True
示例#6
0
文件: powers.py 项目: wolmir/cristina
def loadPowers():
	global powerTypes
	powerTypes = {}
	powerDir = (os.path.join(data.data_dir, "powers"))
	for filename in os.listdir(powerDir):
		if filename[-3:].lower() != "txt": continue
		data.trace("  loading "+filename)
		powerTypes[filename] = power_style(filename)
	
	return True
示例#7
0
文件: powers.py 项目: wolmir/cristina
    def __init__(self, filename):
        self.name = filename
        self.title = ""
        self.tile = ["base.png", 0, 0]
        self.powerRange = 1
        self.damage = 1
        rawdata = data.loadText(os.path.join("powers", filename))
        for line in rawdata:
            splitLine = line.split("=", 1)
            if len(splitLine) < 2:
                data.warn("could not understand: " + line)
                continue
            splitLine[0] = splitLine[0].strip().lower()
            splitLine[1] = splitLine[1].strip()
            if splitLine[0] == "tile":
                tilePointer = splitLine[1].split(" ", 2)
                if len(tilePointer) < 3:
                    data.warn("not enough information: " + line)
                    continue
                self.tile[0] = tilePointer[0].strip()
                try:
                    self.tile[1] = int(tilePointer[1])
                    self.tile[2] = int(tilePointer[2])
                except ValueError:
                    data.warn("xy coords not a number: " + line)
                    self.tile[1] = 0
                    self.tile[2] = 0
                    continue
            elif splitLine[0] == "name":
                self.title = splitLine[1]
            elif splitLine[0] == "range":
                try:
                    self.powerRange = int(splitLine[1])
                except ValueError:
                    data.warn("power range not a number: " + line)
                    self.powerRange = 1
                    continue
            elif splitLine[0] == "damage":
                try:
                    self.damage = int(splitLine[1])
                except ValueError:
                    data.warn("damage not a number: " + line)
                    self.damage = 1
                    continue
            else:
                data.warn("I don't understand: " + line)

        data.trace("    name: " + self.name)
        data.trace("    title: " + self.title)
        data.trace("    tile: " + repr(self.tile))
        data.trace("    range: " + repr(self.powerRange))
        data.trace("    damage: " + repr(self.damage))
示例#8
0
文件: powers.py 项目: wolmir/cristina
	def __init__(self, filename):
		self.name = filename
		self.title = ""
		self.tile = ["base.png", 0, 0]
		self.powerRange = 1
		self.damage = 1
		rawdata = data.loadText(os.path.join("powers",filename))
		for line in rawdata:
			splitLine = line.split("=", 1)
			if len(splitLine) < 2:
				data.warn("could not understand: "+line)
				continue
			splitLine[0] = splitLine[0].strip().lower()
			splitLine[1] = splitLine[1].strip()
			if splitLine[0] == "tile":
				tilePointer = splitLine[1].split(" ", 2)
				if len(tilePointer) < 3:
					data.warn("not enough information: "+line)
					continue
				self.tile[0] = tilePointer[0].strip()
				try:
					self.tile[1] = int(tilePointer[1])
					self.tile[2] = int(tilePointer[2])
				except ValueError:
					data.warn("xy coords not a number: "+line)
					self.tile[1] = 0
					self.tile[2] = 0
					continue
			elif splitLine[0] == "name":
				self.title=splitLine[1]
			elif splitLine[0] == "range":
				try:
					self.powerRange = int(splitLine[1])
				except ValueError:
					data.warn("power range not a number: "+line)
					self.powerRange = 1
					continue
			elif splitLine[0] == "damage":
				try:
					self.damage = int(splitLine[1])
				except ValueError:
					data.warn("damage not a number: "+line)
					self.damage = 1
					continue
			else:
				data.warn("I don't understand: "+line)
				
		data.trace("    name: "+self.name)
		data.trace("    title: "+self.title)
		data.trace("    tile: "+repr(self.tile))
		data.trace("    range: "+repr(self.powerRange))
		data.trace("    damage: "+repr(self.damage))
示例#9
0
def main():
	data.trace("started main")
	pygame.init()
	pygame.font.init()
	
	pygame.display.set_caption("The Mimic Slime and the Forbidden Dungeon")
	g.simpleFont = pygame.font.Font(data.filepath("vera.ttf"), 8)

	data.trace("reading "+str(len(sys.argv)-1)+" arguments")

	data.trace("creating screen")
	g.screen = pygame.display.set_mode(g.screen_size)

	data.trace("loading images")
	if not data.loadImages():
		return

	for i in range((g.images["base.png"].get_size()[1])/32):
		for j in range((g.images["base.png"].get_size()[0])/32):
			tempSurface = g.simpleFont.render(str(j)+", "+str(i), False,
			(255,255,255))
			g.images["base.png"].blit(tempSurface, (j*32, i*32))
	pygame.image.save(g.images["base.png"], "base_with_xy.png")
	data.trace("complete!")
示例#10
0
def main():
    data.trace("started main")
    pygame.init()
    pygame.font.init()

    pygame.display.set_caption("The Mimic Slime and the Forbidden Dungeon")
    g.simpleFont = pygame.font.Font(data.filepath("vera.ttf"), 8)

    data.trace("reading " + str(len(sys.argv) - 1) + " arguments")

    data.trace("creating screen")
    g.screen = pygame.display.set_mode(g.screen_size)

    data.trace("loading images")
    if not data.loadImages():
        return

    for i in range((g.images["base.png"].get_size()[1]) / 32):
        for j in range((g.images["base.png"].get_size()[0]) / 32):
            tempSurface = g.simpleFont.render(
                str(j) + ", " + str(i), False, (255, 255, 255))
            g.images["base.png"].blit(tempSurface, (j * 32, i * 32))
    pygame.image.save(g.images["base.png"], "base_with_xy.png")
    data.trace("complete!")
示例#11
0
文件: tile.py 项目: wolmir/cristina
    def __init__(self, filename):
        self.name = filename
        self.walkable = True
        self.picture = ["base.png", 0, 0]
        self.canEat = False
        self.armor = 0
        self.replace = "replacethis.txt"
        self.symbol = "_"
        rawdata = data.loadText(os.path.join("tiletypes", filename))
        for line in rawdata:
            splitLine = line.split("=", 1)
            if len(splitLine) < 2:
                data.warn("could not understand: " + line)
                continue
            splitLine[0] = splitLine[0].strip().lower()
            splitLine[1] = splitLine[1].strip()
            if splitLine[0] == "walkable":
                self.walkable = data.strToBool(splitLine[1])
                if self.walkable == None:
                    self.walkable = False
                    data.warn("walkable not true or false: " + line)
            elif splitLine[0] == "tile":
                tilePointer = splitLine[1].split(" ", 2)
                if len(tilePointer) < 3:
                    data.warn("not enough information: " + line)
                    continue
                self.picture[0] = tilePointer[0].strip()
                try:
                    self.picture[1] = int(tilePointer[1])
                    self.picture[2] = int(tilePointer[2])
                except ValueError:
                    data.warn("xy coords not a number: " + line)
                    continue
            elif splitLine[0] == "caneat":
                self.canEat = data.strToBool(splitLine[1])
                if self.canEat == None:
                    self.canEat = False
                    data.warn("canEat not true or false: " + line)
            elif splitLine[0] == "armor":
                self.armor = data.strToInt(splitLine[1])
                if self.armor == None:
                    self.armor = 0
                    data.warn("armor not a number: " + line)
            elif splitLine[0] == "replace":
                self.replace = splitLine[1]
            elif splitLine[0] == "symbol":
                if len(splitLine[1]) != g.symbolLength:
                    data.warn("symbol wrong length: " + line)
                    continue
                self.symbol = splitLine[1]
            else:
                data.warn("I don't understand: " + line)

        data.trace("    name: " + self.name)
        data.trace("    walkable: " + str(self.walkable))
        data.trace("    picture: " + repr(self.picture))
        data.trace("    canEat: " + str(self.canEat))
        data.trace("    armor: " + str(self.armor))
        data.trace("    replace: " + self.replace)
示例#12
0
    def __init__(self, filename):
        self.name = filename
        self.picture = ["base.png", 0, 0]
        self.statType = "melee"
        self.statStrength = 1
        self.symbol = "?"
        self.levelRange = [1, 1]
        rawdata = data.loadText(os.path.join("creatures", filename))
        for line in rawdata:
            splitLine = line.split("=", 1)
            if len(splitLine) < 2:
                data.warn("could not understand: " + line)
                continue
            splitLine[0] = splitLine[0].strip().lower()
            splitLine[1] = splitLine[1].strip()
            if splitLine[0] == "tile":
                tilePointer = splitLine[1].split(" ", 2)
                if len(tilePointer) < 3:
                    data.warn("not enough information: " + line)
                    continue
                self.picture[0] = tilePointer[0].strip()
                try:
                    self.picture[1] = int(tilePointer[1])
                    self.picture[2] = int(tilePointer[2])
                except ValueError:
                    data.warn("xy coords not a number: " + line)
                    self.picture[1] = 0
                    self.picture[2] = 0
                    continue
            elif splitLine[0] == "symbol":
                if len(splitLine[1]) != g.symbolLength:
                    data.warn("symbol wrong length: " + line)
                    continue
                self.symbol = splitLine[1]
            elif splitLine[0] == "stats":
                statPointer = splitLine[1].split(" ", 1)
                if len(statPointer) < 2:
                    data.warn("not enough information: " + line)
                    continue
                self.statType = statPointer[0]
                if not self.statType in statTypes:
                    data.warn("stat type does not exist: " + line)
                    continue
                try:
                    self.statStrength = int(statPointer[1])
                except ValueError:
                    data.warn("stat strength not a number: " + line)
                    self.statStrength = 1
                    continue
            elif splitLine[0] == "level":
                statPointer = splitLine[1].split("-", 1)
                if len(statPointer) < 2:
                    data.warn("not enough information: " + line)
                    continue
                try:
                    self.levelRange[0] = int(statPointer[0])
                    self.levelRange[1] = int(statPointer[1])
                except ValueError:
                    data.warn("level range not a number: " + line)

            else:
                data.warn("I don't understand: " + line)

        data.trace("    name: " + self.name)
        data.trace("    picture: " + repr(self.picture))
示例#13
0
文件: tile.py 项目: wolmir/cristina
	def __init__(self, filename):
		self.name = filename
		self.walkable = True
		self.picture = ["base.png", 0, 0]
		self.canEat = False
		self.armor = 0
		self.replace = "replacethis.txt"
		self.symbol="_"
		rawdata = data.loadText(os.path.join("tiletypes",filename))
		for line in rawdata:
			splitLine = line.split("=", 1)
			if len(splitLine) < 2:
				data.warn("could not understand: "+line)
				continue
			splitLine[0] = splitLine[0].strip().lower()
			splitLine[1] = splitLine[1].strip()
			if splitLine[0] == "walkable":
				self.walkable = data.strToBool(splitLine[1])
				if self.walkable == None:
					self.walkable = False
					data.warn("walkable not true or false: "+line)
			elif splitLine[0] == "tile":
				tilePointer = splitLine[1].split(" ", 2)
				if len(tilePointer) < 3:
					data.warn("not enough information: "+line)
					continue
				self.picture[0] = tilePointer[0].strip()
				try:
					self.picture[1] = int(tilePointer[1])
					self.picture[2] = int(tilePointer[2])
				except ValueError:
					data.warn("xy coords not a number: "+line)
					continue
			elif splitLine[0] == "caneat":
				self.canEat = data.strToBool(splitLine[1])
				if self.canEat == None:
					self.canEat = False
					data.warn("canEat not true or false: "+line)
			elif splitLine[0] == "armor":
				self.armor = data.strToInt(splitLine[1])
				if self.armor == None:
					self.armor = 0
					data.warn("armor not a number: "+line)
			elif splitLine[0] == "replace":
				self.replace = splitLine[1]
			elif splitLine[0] == "symbol":
				if len(splitLine[1]) != g.symbolLength:
					data.warn("symbol wrong length: "+line)
					continue
				self.symbol=splitLine[1]
			else:
				data.warn("I don't understand: "+line)
				
		data.trace("    name: "+self.name)
		data.trace("    walkable: "+str(self.walkable))
		data.trace("    picture: "+repr(self.picture))
		data.trace("    canEat: "+str(self.canEat))
		data.trace("    armor: "+str(self.armor))
		data.trace("    replace: "+self.replace)
示例#14
0
	def __init__(self, filename):
		self.name = filename
		self.picture = ["base.png", 0, 0]
		self.statType = "melee"
		self.statStrength = 1
		self.symbol="?"
		self.levelRange = [1, 1]
		rawdata = data.loadText(os.path.join("creatures",filename))
		for line in rawdata:
			splitLine = line.split("=", 1)
			if len(splitLine) < 2:
				data.warn("could not understand: "+line)
				continue
			splitLine[0] = splitLine[0].strip().lower()
			splitLine[1] = splitLine[1].strip()
			if splitLine[0] == "tile":
				tilePointer = splitLine[1].split(" ", 2)
				if len(tilePointer) < 3:
					data.warn("not enough information: "+line)
					continue
				self.picture[0] = tilePointer[0].strip()
				try:
					self.picture[1] = int(tilePointer[1])
					self.picture[2] = int(tilePointer[2])
				except ValueError:
					data.warn("xy coords not a number: "+line)
					self.picture[1] = 0
					self.picture[2] = 0
					continue
			elif splitLine[0] == "symbol":
				if len(splitLine[1]) != g.symbolLength:
					data.warn("symbol wrong length: "+line)
					continue
				self.symbol=splitLine[1]
			elif splitLine[0] == "stats":
				statPointer = splitLine[1].split(" ", 1)
				if len(statPointer) < 2:
					data.warn("not enough information: "+line)
					continue
				self.statType = statPointer[0]
				if not self.statType in statTypes:
					data.warn("stat type does not exist: "+line)
					continue
				try:
					self.statStrength = int(statPointer[1])
				except ValueError:
					data.warn("stat strength not a number: "+line)
					self.statStrength = 1
					continue
			elif splitLine[0] == "level":
				statPointer = splitLine[1].split("-", 1)
				if len(statPointer) < 2:
					data.warn("not enough information: "+line)
					continue
				try:
					self.levelRange[0] = int(statPointer[0])
					self.levelRange[1] = int(statPointer[1])
				except ValueError:
					data.warn("level range not a number: "+line)
				
			else:
				data.warn("I don't understand: "+line)
				
		data.trace("    name: "+self.name)
		data.trace("    picture: "+repr(self.picture))