Ejemplo n.º 1
0
Archivo: main.py Proyecto: Kupoman/thor
	def __init__(self, _base):
		GameState.__init__(self, _base)
		self.accept("enter", self.cb_next_turn)

		self.clock = ClockObject()

		g_race = "golem" if self.player.monster.race.lower() == "ogre" else "ogre"
		hpr_list = ((-90, 0, 0), (90, 0, 0))
		pos_list = ((-2, 2, 0), (2, 2, 0))
		monster_list = ((self.player.monster,)*3, (Monster.new_from_race(g_race),)*3)
		# self.teams = [CombatTeam(monster_list[i], pos_list[i], hpr_list[i]) for i in range(2)]
		self.combat_world = CombatWorld()
		self.combat_world.add_team(monster_list[0], pos_list[0], hpr_list[0])
		self.combat_world.add_team(monster_list[1], pos_list[1], hpr_list[1])
		self.teams = self.combat_world.teams

		self.teams[0].set_targets(self.teams[1])
		self.teams[1].set_targets(self.teams[0])

		# Combatants
		self.combatants = {}
		self.combatants['red'] = self.player.monster
		self.combatants['red'].current_stamina = 50
		self.combatants['red'].current_hp = self.combatants['red'].hp
		g_race = "golem" if self.player.monster.race.lower() == "ogre" else "ogre"
		self.combatants['green'] = Monster.new_from_race(g_race)
		self.combatants['green'].current_hp = self.combatants['green'].hp
		self.combatants['green'].current_stamina = 50

		self.combatants['red'].target = self.combatants['green']
		self.combatants['green'].target = self.combatants['red']

		# Combat vars
		self.combat_time = 60.0
		self.turn = 60
		self.player_spells = [
			commands.Attack,
			commands.Wait,
			]

		self.base.background.setImage("art/background.png")

		self.player_command = None

		self.setup_ui()
Ejemplo n.º 2
0
Archivo: main.py Proyecto: Kupoman/thor
	def __init__(self):
		ShowBase.__init__(self)

		# Increase the texture resolution on DirectGui
		default_font = DirectGuiGlobals.getDefaultFont()
		default_font.clear()
		default_font.setPixelsPerUnit(64)
		DirectGuiGlobals.setDefaultFont(default_font)

		self.accept("f1", sys.exit)
		self.win.setCloseRequestEvent("f1")

		self.background = OnscreenImage(parent=self.render2dp, image="art/menu_background.png")
		self.cam2dp.node().getDisplayRegion(0).setSort(-20)

		# Setup camera
		self.disableMouse()
		self.camera.setPos(0, -5, 2.25)
		self.camera.setHpr(0, -10, 0)
		self.camLens.setFov(65)

		# Setup saves
		self.save_dir = os.path.join(appdirs.user_data_dir('ThorGame', roaming=True), 'saves')
		if not os.path.exists(self.save_dir):
			os.makedirs(self.save_dir)
		self.saved_trainer_ids = [i.split('.')[0] for i in os.listdir(self.save_dir)]

		# Setup UI
		self.ui = CEFPanda()
		src_dir = _file_dir
		template_folder = os.path.join(src_dir, 'ui')
		self.ui_env = Environment(loader=FileSystemLoader(template_folder),
								  trim_blocks=True)
		# HACK - CEFPython requires a regular LoadURL before LoadString works,
		# so we just give it something to work on. This doesn't render nicely,
		# but we replace it immediately with the UI for the first GameState.
		# CEFPython issue: https://code.google.com/p/chromiumembedded/issues/detail?id=763
		self.ui.load('ui/base.html')

		# Load monster data
		data_folder = os.path.join(src_dir, 'data')
		self.monster_data = []
		for i in os.listdir(data_folder):
			if i.startswith('race'):
				with open(os.path.join(data_folder, i)) as f:
					self.monster_data.append(json.load(f))

		# Setup the default player and monster
		self.player = Trainer(dont_save=True)
		self.player.monster = Monster.new_from_race("ogre")

		# Setup game states
		self.game_state = TitleState(self)
		self.taskMgr.add(self.main_loop, "MainLoop")
Ejemplo n.º 3
0
Archivo: main.py Proyecto: Kupoman/thor
		def set_monster(race):
			self.player.monster = Monster.new_from_race(race)
			self.load_monster_mesh()