示例#1
0
int main (int argc, char *argv[])
{
	//load data files
	gdInit();
	gdLoadFile("gamedata/weapons.txt");
	cerr << "(weapon types loaded)" << endl;
	gdLoadFile("gamedata/mecha.txt");
	cerr << "(mecha types loaded)" << endl;

	//set up game
	GameState gs;
	cerr << "(setting up game state)" << endl;

	UIPlayer man;
	vector<Player*> bots;

	loadSetup("gamedata/setup.txt", gs, man, bots);

/*
	//TODO: make this set up from a file
	// {
	//players
	cerr << "\t(players)\n";
	UIPlayer man;
	DodgerAIPlayer bot;
	//pilots
	cerr << "\t(characters)\n";
	gs.pilots.push_back(Pilot(&man, "PC"));
	gs.pilots.push_back(Pilot(&bot, "AI"));
	Pilot &pc_pilot = gs.pilots[0];
	Pilot &ai_pilot = gs.pilots[1];

	//setting up 'average' stats with medium-high skills.
	pc_pilot.reflexes = 13;
	pc_pilot.speed = 13;
	pc_pilot.skMekPilot = 10;
	pc_pilot.skMekGun = 10;

	ai_pilot.reflexes = 13;
	ai_pilot.speed = 13;
	ai_pilot.skMekPilot = 10;
	ai_pilot.skMekGun = 10;
	//mecha
	cerr << "\t(mecha)\n";
	MekType *mt = gdMekTypeByDesig("SAN-X9");
	if (mt==NULL) {
		cerr << "Mech type SAN-X9 not loaded successfully! Aborting!" << endl;
		return 1;
	}
	gs.mecha.push_back(Mek(mt));
	gs.mecha.push_back(Mek(mt));
	Mek &pc_mek = gs.mecha[0];
	Mek &ai_mek = gs.mecha[1];
	//loadout
	cerr << "\t(mecha loadout)\n";
	gdDefaultLoadout(pc_mek);
	gdDefaultLoadout(ai_mek);
	//assigning
	cerr << "\t(linking elements together)\n";
	man.chara = &pc_pilot;
	bot.chara = &ai_pilot;
	pc_mek.pilot = &pc_pilot;   pc_pilot.cur_mek = &pc_mek;
	ai_mek.pilot = &ai_pilot;   ai_pilot.cur_mek = &ai_mek;
	//placement
	pc_mek.pos = Intvec3(5, 7);
	ai_mek.pos = Intvec3(-2, -1);
	// }
*/
	cerr << "(game state initialized)" << endl;

	cerr << "pointas\n" << "b\t"<<man.chara << endl << "a\t"<<man.chara->cur_mek << endl;

	//init UI
	try {
		//putting everything in this block just to unload curses on
		// uncaught error (prevent messing up terminal screen)
		cerr << "(initializing UI)" << endl;
		//uiInit(&pc_pilot, &pc_mek);
		uiInit(man.chara, man.chara->cur_mek);

		//start game loop
		cerr << "(starting game loop)\n";
		uiDrawAll(gs);
		while (not user_wants_out) {  //bool declared in UI.h
			gs.advance_turn();
			uiDrawAll(gs);
			usleep(20000);
		}

	} catch (...) {
		uiExit();
		gdExit();
		cerr << "(error occured!)" << endl;
		throw;
	}

	//close down UI
	cerr << "(closing UI)\n";
	uiExit();
	cerr << "(unloading game data)\n";
	gdExit();
	cerr << "(done)" << endl;
	return 0;
}