void TFlyObjectEdit::showObject( unsigned typeBit , bool isShow ) { int type = 1 << typeBit; for( int i =0;i < g_editDataVec.size() ; ++i ) { EditData& data = g_editDataVec[i]; if ( data.type & typeBit ) { FnObject obj; obj.Object( data.id ); obj.Show( isShow ); } } }
void FyMain(int argc, char **argv) { srand(time(NULL)); AllocConsole(); freopen("CONIN$", "r", stdin); freopen("CONOUT$", "w", stdout); freopen("CONOUT$", "w", stderr); string ip, port; cout << "Enter ip [" << GAME_PROGRAMMING_DEFAULT_IP << "]: ";getline(cin, ip); cout << "Enter port [" << GAME_PROGRAMMING_DEFAULT_PORT << "]: ";getline(cin, port); if(ip.empty()) {ip = GAME_PROGRAMMING_DEFAULT_IP;} if(port.empty()) {port = GAME_PROGRAMMING_DEFAULT_PORT;} cout << "Connect to server: " << ip << "/" << port << endl; game_client.initialize(ip, port, &game_updater); game_client.connectServer(); cout << "Server connected." << endl; game_timer.initialize(&game_updater, game_client.getGmTree().getTotalGameTime(), game_client.getGmTree().getTotalGameRounds()); std::cout<<"Start Game" << std::endl; //create a new window FyStartFlyWin32("Final Project - with Fly2", 0, 0, window_w, window_h, FALSE); //set up path FySetShaderPath("C:\\Fly2Data\\Shaders"); FySetModelPath("C:\\Fly2Data\\Scenes"); FySetTexturePath("C:\\Fly2Data\\Scenes\\Textures"); FySetScenePath("C:\\Fly2Data\\Scenes"); FySetAudioPath("C:\\Fly2Data\\Audio"); //create a viewport viewportID = FyCreateViewport(0, 0, viewPortWidth, viewPortHeight); FnViewport viewport(viewportID); mouseInput.setWindowSize(wndWidth, wndHeight); //create 3D scene sceneID = FyCreateScene(10); FnScene scene(sceneID); scene.Load("gameScene01"); scene.SetAmbientLights(1.0f, 1.0f, 1.0f, 0.6f, 0.6f, 0.6f); // create a 2D scene for sprite rendering which will be rendered on the top of 3D FnScene scene2D; sID2 = FyCreateScene(1); scene2D.Object(sID2); scene2D.SetSpriteWorldSize(1024, 768); // 2D scene size in pixels FnSprite sp; spID0 = scene2D.CreateObject(SPRITE); sp.Object(spID0); sp.SetSize(sight_w, sight_h); sp.SetImage("C:\\Fly2Data\\Image\\spiner", 0, NULL, FALSE, NULL, 2, TRUE, FILTER_LINEAR); sp.SetPosition(window_w/2-sight_w/2, window_h/2-sight_h/2, 0); FnScene scene2Dmenu; sID2menu = FyCreateScene(1); scene2Dmenu.Object(sID2menu); scene2Dmenu.SetSpriteWorldSize(1024, 768); // 2D scene size in pixels FnSprite spExit; OBJECTid spIDexit = scene2Dmenu.CreateObject(SPRITE); spExit.Object(spIDexit); spExit.SetSize(400, 70); spExit.SetImage("C:\\Fly2Data\\Image\\exit_button", 0, NULL, FALSE, NULL, 2, TRUE, FILTER_LINEAR); spExit.SetPosition(window_w/2-400/2, window_h/2-70/2, 0); /* FnSprite sp1; spID1 = scene2Dmenu.CreateObject(SPRITE); sp1.Object(spID1); sp1.SetSize(C:\\Fly2Data\\Image\\mouse_w, mouse_h); sp1.SetImage("mouse", 0, NULL, FALSE, NULL, 2, TRUE, FILTER_LINEAR); sp1.SetPosition(window_w/2-mouse_w/2, window_h/2-mouse_h/2, 0); */ //load the terrain terrainID = scene.CreateObject(OBJECT); FnObject terrain; terrain.ID(terrainID); terrain.Load("terrain"); terrain.Show(FALSE); //set terrain environment terrainRoomID = scene.CreateRoom(SIMPLE_ROOM, 10); FnRoom room; room.ID(terrainRoomID); room.AddObject(terrainID); //load the character FySetModelPath("C:\\Fly2Data\\Characters"); FySetTexturePath("C:\\Fly2Data\\Characters"); FySetCharacterPath("C:\\Fly2Data\\Characters"); // put the character on terrain float pos[3], fDir[3], uDir[3]; pos[0] = 3569.0, pos[1] = -3108; pos[2] = 0; fDir[0] = 1, fDir[1] = 0; fDir[2] = 0; uDir[0] = 0, uDir[1] = 0, uDir[2] = 1; map<int, GmCharacter*> charNode = game_client.getGmTree().getCharacterNode(); cout << "Number of Character: " << charNode.size() << endl; map<int, Character *> actors; for (map<int, GmCharacter*>::iterator it = charNode.begin(); it != charNode.end(); it++) { actors[it->first] = new Character(); cout << "Local character:" << it->second->game_id << "/" << it->second->id << endl; actors[it->first]->setMeshFileName(it->second->mesh); actors[it->first]->setCharacterName(it->second->mesh); actors[it->first]->initialize(sceneID, NULL, terrainRoomID, it->second->fdir, it->second->udir, it->second->pos); actors[it->first]->setIsAI(it->second->is_ai); //actorID = actors[it->first]->getCharacterId(); chrMgtSystem.addCharacter(*(actors[it->first]), it->second->is_main_actor); game_updater.registerCharacter(it->second->game_id, actors[it->first]->getCharacterId()); } if(game_client.getClientId() == 0) { // AI Master!!! cout << "I am AI Master !!!" << endl; chrMgtSystem.becomeAIMaster(); } cameraID = scene.CreateObject(CAMERA); FnCamera camera; camera.ID(cameraID); camera.SetNearPlane(5.0f); camera.SetFarPlane(100000.0f); setCamera(); // setup a point light /* FnLight light; lightID = scene.CreateObject(LIGHT); light.ID(lightID); light.Translate(70.0f, -70.0f, 70.0f, REPLACE); light.SetColor(1.0f, 1.0f, 1.0f); light.SetIntensity(1.0f); */ //create a text object for display message on screen textID = FyCreateText("Trebuchet MS", 18, FALSE, FALSE); textCharID = FyCreateText("Trebuchet MS", 20, TRUE, FALSE); textHP_vID = FyCreateText("Trebuchet MS", 60, TRUE, FALSE); textInfo_vID = FyCreateText("Trebuchet MS", 30, TRUE, FALSE); //set up audio bckMiscID = FyCreateAudio(); FnAudio fnAudio(bckMiscID); fnAudio.Load("game_bckgnd"); fnAudio.SetVolume(0.1); fnAudio.Play(LOOP); mouseInput.hideMouse(); stateGhost = 0; //設定鬼一開始看不到的狀態 // set Hotkeys /* FyDefineHotKey(FY_ESCAPE, QuitGame, FALSE); // escape for quiting the game FyDefineHotKey(FY_UP, Movement, FALSE); // Up for moving forward FyDefineHotKey(FY_RIGHT, Movement, FALSE); // Right for turning right FyDefineHotKey(FY_LEFT, Movement, FALSE); // Left for turning left FyDefineHotKey(FY_DOWN, Movement, FALSE); // Down for moving backward */ FyDefineHotKey(FY_TAB, ChangeActor, FALSE); FyDefineHotKey(FY_ESC, showMenu, FALSE); //define some mouse function FyBindMouseFunction(LEFT_MOUSE, InitPivot, PivotCam, NULL, NULL); FyBindMouseFunction(MIDDLE_MOUSE, InitZoom, ZoomCam, NULL, NULL); FyBindMouseFunction(RIGHT_MOUSE, InitMove, MoveCam, NULL, NULL); //bind timers, frame rate = 30 fps FyBindTimer(0, 30.0f, GameAI, TRUE); FyBindTimer(1, 30.0f, RenderIt, TRUE); //invoke the system FyInvokeFly(TRUE); system("pause"); fclose(stdout); fclose(stderr); fclose(stdin); //FreeConsole(); }
/*------------------ the main program C.Wang 1010, 2014 -------------------*/ void FyMain(int argc, char **argv) { // create a new world BOOL4 beOK = FyStartFlyWin32("NTU@2015 Homework #02 - Use Fly2", 0, 0, 1024, 768, FALSE); // setup the data searching paths FySetShaderPath("Data\\NTU6\\Shaders"); FySetModelPath("Data\\NTU6\\Scenes"); FySetTexturePath("Data\\NTU6\\Scenes\\Textures"); FySetScenePath("Data\\NTU6\\Scenes"); //Tang: FX FySetGameFXPath("Data\\NTU6\\FX"); //Tang // create a viewport vID = FyCreateViewport(0, 0, 1024, 768); FnViewport vp; vp.ID(vID); // create a 3D scene sID = FyCreateScene(10); FnScene scene; scene.ID(sID); // load the scene scene.Load("gameScene02"); scene.SetAmbientLights(1.0f, 1.0f, 1.0f, 0.6f, 0.6f, 0.6f); // load the terrain tID = scene.CreateObject(OBJECT); FnObject terrain; terrain.ID(tID); BOOL beOK1 = terrain.Load("terrain"); terrain.Show(FALSE); // set terrain environment terrainRoomID = scene.CreateRoom(SIMPLE_ROOM, 10); FnRoom room; room.ID(terrainRoomID); room.AddObject(tID); // load the character FySetModelPath("Data\\NTU6\\Characters"); FySetTexturePath("Data\\NTU6\\Characters"); FySetCharacterPath("Data\\NTU6\\Characters"); actorID = scene.LoadCharacter("Lyubu2"); // put the character on terrain float pos[3], fDir[3], uDir[3]; SetValues(pos, 3569.0f, -3208.0f, 1000.0f); SetValues(fDir, 1.0f, 1.0f, 0.0f); SetValues(uDir, 0.0f, 0.0f, 1.0f); ActorGen(scene, terrainRoomID, LyubuID, "Lyubu2", "Idle", pos, fDir, uDir); actorID = LyubuID.actorID; FnCharacter actor; actor.ID(actorID); // Get two character actions pre-defined at Lyubu2 idleID = actor.GetBodyAction(NULL, "Idle"); runID = actor.GetBodyAction(NULL, "Run"); NormalAttack1ID = actor.GetBodyAction(NULL, "NormalAttack1"); NormalAttack2ID = actor.GetBodyAction(NULL, "NormalAttack2"); HeavyAttack1ID = actor.GetBodyAction(NULL, "HeavyAttack1"); // translate the camera cID = scene.CreateObject(CAMERA); FnCamera camera; camera.ID(cID); camera.SetNearPlane(5.0f); camera.SetFarPlane(100000.0f); //hw3 : Donzo and Robber02 initialization float temp_pos[3]; float temp_fDir[3]; /* for (int i = 0; i < NUM_OF_BADGUYS; i++) { temp_pos[0] = pos[0] + 30 * (rand()%8); temp_pos[1] = pos[1] + 30 * (rand()%8); temp_pos[2] = pos[2] + 30 * (rand()%8); temp_fDir[0] = -1.0f; temp_fDir[1] = -1.0f; temp_fDir[2] = 1.0f; ActorGen(scene, terrainRoomID, badguyID[i], "Robber02", "CombatIdle", temp_pos, temp_fDir, uDir); } */ for (int i = 0; i < NUM_OF_BOSS; i++) { temp_pos[0] = pos[0] + 30 * (rand() % 8); temp_pos[1] = pos[1] + 30 * (rand() % 8); temp_pos[2] = pos[2] + 30 * (rand() % 8); SetValues(temp_fDir, -1.0f, -1.0f, 1.0f); ActorGen(scene, terrainRoomID, BossID[i], "Donzo2", "CombatIdle", temp_pos, temp_fDir, uDir); } // hw2 initial : set camera position actor.GetPosition(pos); pos[0] = pos[0] - SHORTDIST * fDir[0]; pos[1] = pos[1] - SHORTDIST * fDir[1]; pos[2] = pos[2] + HEIGHTOFFSET; SetValues(fDir, 1.0f, 1.0f, 0.0f); SetValues(uDir, 0.0f, 0.0f, 1.0f); camera.SetPosition(pos); camera.SetDirection(fDir, uDir); // the same as actor float mainLightPos[3] = { -4579.0, -714.0, 15530.0 }; float mainLightFDir[3] = { 0.276, 0.0, -0.961 }; float mainLightUDir[3] = { 0.961, 0.026, 0.276 }; FnLight lgt; lgt.ID(scene.CreateObject(LIGHT)); lgt.Translate(mainLightPos[0], mainLightPos[1], mainLightPos[2], REPLACE); lgt.SetDirection(mainLightFDir, mainLightUDir); lgt.SetLightType(PARALLEL_LIGHT); lgt.SetColor(1.0f, 1.0f, 1.0f); lgt.SetName("MainLight"); lgt.SetIntensity(0.4f); // create a text object for displaying messages on screen textID = FyCreateText("Trebuchet MS", 18, FALSE, FALSE); // create a 2D scene for sprite rendering which will be rendered on the top of 3D sID2 = FyCreateScene(1); scene.ID(sID2); scene.SetSpriteWorldSize(800, 600); // 2D scene size in pixels spID0 = scene.CreateObject(SPRITE); sp.ID(spID0); //showPicture(sp, "talk_mission.jpg", 780, 200 , 10, 10); //showPicture parameter : FnSprite ,imageName, size, position // set Hotkeys FyDefineHotKey(FY_ESCAPE, QuitGame, FALSE); // escape for quiting the game FyDefineHotKey(FY_UP, Movement, FALSE); // Up for moving forward FyDefineHotKey(FY_RIGHT, Movement, FALSE); // Right for turning right FyDefineHotKey(FY_LEFT, Movement, FALSE); // Left for turning left FyDefineHotKey(FY_DOWN, Movement, FALSE); FyDefineHotKey(FY_Q, Movement, FALSE); FyDefineHotKey(FY_W, Movement, FALSE); FyDefineHotKey(FY_E, Movement, FALSE); FyDefineHotKey(FY_A, Movement, FALSE); // Turn left with camera rotation FyDefineHotKey(FY_D, Movement, FALSE); // Turn right with camera rotation FyDefineHotKey(FY_S, Movement, FALSE); // define some mouse functions FyBindMouseFunction(LEFT_MOUSE, InitPivot, PivotCam, NULL, NULL); FyBindMouseFunction(MIDDLE_MOUSE, InitZoom, ZoomCam, NULL, NULL); FyBindMouseFunction(RIGHT_MOUSE, InitMove, MoveCam, NULL, NULL); // bind timers, frame rate = 30 fps FyBindTimer(0, 30.0f, GameAI, TRUE); FyBindTimer(1, 30.0f, RenderIt, TRUE); // invoke the system FyInvokeFly(TRUE); }
/*----------------------- show / hide the shadow C.Wang 0910, 2006 ------------------------*/ void FuCShadowModify::Show(BOOL beShow) { FnObject seed; seed.Object(mSeed); seed.Show(beShow); }
/* ------------------ the main program C.Wang 1010, 2014 -------------------*/ void FyMain(int argc, char **argv) { // create a new world BOOL4 beOK = FyStartFlyWin32("NTU@2014 Homework #02 - Use Fly2", 0, 0, 1024, 768, FALSE); // setup the data searching paths FySetShaderPath("Data\\NTU6\\Shaders"); FySetModelPath("Data\\NTU6\\Scenes"); FySetTexturePath("Data\\NTU6\\Scenes\\Textures"); FySetScenePath("Data\\NTU6\\Scenes"); // create a viewport vID = FyCreateViewport(0, 0, 1024, 768); FnViewport vp; vp.ID(vID); // create a 3D scene sID = FyCreateScene(10); FnScene scene; scene.ID(sID); // load the scene scene.Load("gameScene02"); scene.SetAmbientLights(1.0f, 1.0f, 1.0f, 0.6f, 0.6f, 0.6f); // load the terrain tID = scene.CreateObject(OBJECT); FnObject terrain; terrain.ID(tID); BOOL beOK1 = terrain.Load("terrain"); terrain.Show(FALSE); // set terrain environment terrainRoomID = scene.CreateRoom(SIMPLE_ROOM, 10); FnRoom room; room.ID(terrainRoomID); room.AddObject(tID); // load the character FySetModelPath("Data\\NTU6\\Characters"); FySetTexturePath("Data\\NTU6\\Characters"); FySetCharacterPath("Data\\NTU6\\Characters"); actorID = scene.LoadCharacter("Lyubu2"); npc1ID = scene.LoadCharacter("Donzo2"); npc2ID = scene.LoadCharacter("Robber02"); // put the character on terrain float apos[3], cpos[3], fDir[3], uDir[3]; FnCharacter actor, npc1, npc2; actor.ID(actorID); npc1.ID(npc1ID); npc2.ID(npc2ID); apos[0] = 3569.0f; apos[1] = -3208.0f; apos[2] = 1000.0f; fDir[0] = 1.0f; fDir[1] = 0.0f; fDir[2] = 0.0f; uDir[0] = 0.0f; uDir[1] = 0.0f; uDir[2] = 1.0f; actor.SetDirection(fDir, uDir); fDir[0] = -1.0f; fDir[1] = -1.0f; npc1.SetDirection(fDir, uDir); fDir[0] = 1.0f; npc2.SetDirection(fDir, uDir); actor.SetTerrainRoom(terrainRoomID, 10.0f); npc1.SetTerrainRoom(terrainRoomID, 10.0f); npc2.SetTerrainRoom(terrainRoomID, 10.0f); beOK = actor.PutOnTerrain(apos); apos[1] -= 150.0f; beOK = npc1.PutOnTerrain(apos); apos[1] -= 50.0f; beOK = npc2.PutOnTerrain(apos); // Get two character actions pre-defined at Lyubu2 idleID = actor.GetBodyAction(NULL, "Idle"); runID = actor.GetBodyAction(NULL, "Run"); attackID = actor.GetBodyAction(NULL, "NormalAttack1"); idle1ID = npc1.GetBodyAction(NULL, "Idle"); damage1ID = npc1.GetBodyAction(NULL, "DamageL"); die1ID = npc1.GetBodyAction(NULL, "Die"); idle2ID = npc2.GetBodyAction(NULL, "CombatIdle"); damage2ID = npc2.GetBodyAction(NULL, "Damage1"); die2ID = npc2.GetBodyAction(NULL, "DEAD"); // set the character to idle action curPoseID = idleID; actor.SetCurrentAction(NULL, 0, curPoseID); actor.Play(START, 0.0f, FALSE, TRUE); actor.TurnRight(90.0f); npc1.SetCurrentAction(NULL, 0, idle1ID); npc1.Play(START, 0.0f, FALSE, TRUE); npc2.SetCurrentAction(NULL, 0, idle2ID); npc2.Play(START, 0.0f, FALSE, TRUE); // translate the camera cID = scene.CreateObject(CAMERA); FnCamera camera; camera.ID(cID); camera.SetNearPlane(5.0f); camera.SetFarPlane(100000.0f); // set camera initial position and orientation actor.GetPosition(apos); //cpos[0] = 4315.783f; cpos[1] = -3199.686f; cpos[2] = 93.046f; fDir[0] = DIST; fDir[1] = 0.0f; fDir[2] = -HEIGHT; cpos[0] = apos[0] - fDir[0]; cpos[1] = apos[1] - fDir[1]; cpos[2] = apos[2] - fDir[2]; float distance = sqrt(double((fDir[0])*(fDir[0]) + (fDir[1])*(fDir[1]))); uDir[0] = -fDir[2] * fDir[0] / distance; uDir[1] = -fDir[2] * fDir[1] / distance; uDir[2] = distance; //fDir[0] = -0.983f; fDir[1] = -0.143f; fDir[2] = -0.119f; //uDir[0] = -0.116f; uDir[1] = -0.031f; uDir[2] = 0.993f; camera.SetPosition(cpos); camera.SetDirection(fDir, uDir); float mainLightPos[3] = { -4579.0, -714.0, 15530.0 }; float mainLightFDir[3] = { 0.276, 0.0, -0.961 }; float mainLightUDir[3] = { 0.961, 0.026, 0.276 }; FnLight lgt; lgt.ID(scene.CreateObject(LIGHT)); lgt.Translate(mainLightPos[0], mainLightPos[1], mainLightPos[2], REPLACE); lgt.SetDirection(mainLightFDir, mainLightUDir); lgt.SetLightType(PARALLEL_LIGHT); lgt.SetColor(1.0f, 1.0f, 1.0f); lgt.SetName("MainLight"); lgt.SetIntensity(0.4f); // create a text object for displaying messages on screen textID = FyCreateText("Trebuchet MS", 18, FALSE, FALSE); // set Hotkeys FyDefineHotKey(FY_ESCAPE, QuitGame, FALSE); // escape for quiting the game FyDefineHotKey(FY_UP, Movement, FALSE); // Up for moving forward FyDefineHotKey(FY_DOWN, Movement, FALSE); // Down for turning right FyDefineHotKey(FY_RIGHT, Movement, FALSE); // Right for turning right FyDefineHotKey(FY_LEFT, Movement, FALSE); // Left for turning left FyDefineHotKey('W', Movement, FALSE); // Up for moving forward FyDefineHotKey('S', Movement, FALSE); // Down for turning right FyDefineHotKey('D', Movement, FALSE); // Right for turning right FyDefineHotKey('A', Movement, FALSE); // Left for turning left FyDefineHotKey('J', Movement, FALSE); // define some mouse functions FyBindMouseFunction(LEFT_MOUSE, InitPivot, PivotCam, NULL, NULL); FyBindMouseFunction(MIDDLE_MOUSE, InitZoom, ZoomCam, NULL, NULL); FyBindMouseFunction(RIGHT_MOUSE, InitMove, MoveCam, NULL, NULL); // bind timers, frame rate = 30 fps FyBindTimer(0, 30.0f, GameAI, TRUE); FyBindTimer(1, 30.0f, RenderIt, TRUE); // invoke the system FyInvokeFly(TRUE); }
/*------------------ the main program C.Wang 1010, 2014 -------------------*/ void FyMain(int argc, char **argv) { // create a new world BOOL4 beOK = FyStartFlyWin32("NTU@2014 Homework #01 - Use Fly2", 0, 0, 1024, 768, FALSE); // setup the data searching paths FySetShaderPath("Data\\NTU6\\Shaders"); FySetModelPath("Data\\NTU6\\Scenes"); FySetTexturePath("Data\\NTU6\\Scenes\\Textures"); FySetScenePath("Data\\NTU6\\Scenes"); // create a viewport vID = FyCreateViewport(0, 0, 1024, 768); FnViewport vp; vp.ID(vID); // create a 3D scene sID = FyCreateScene(10); FnScene scene; scene.ID(sID); // load the scene scene.Load("gameScene02"); scene.SetAmbientLights(1.0f, 1.0f, 1.0f, 0.6f, 0.6f, 0.6f); // load the terrain tID = scene.CreateObject(OBJECT); FnObject terrain; terrain.ID(tID); BOOL beOK1 = terrain.Load("terrain"); terrain.Show(FALSE); // set terrain environment terrainRoomID = scene.CreateRoom(SIMPLE_ROOM, 10); FnRoom room; room.ID(terrainRoomID); room.AddObject(tID); // load the character FySetModelPath("Data\\NTU6\\Characters"); FySetTexturePath("Data\\NTU6\\Characters"); FySetCharacterPath("Data\\NTU6\\Characters"); actorID = scene.LoadCharacter("Lyubu2"); // put the character on terrain float pos[3], fDir[3], uDir[3]; FnCharacter actor; actor.ID(actorID); pos[0] = 3569.0f; pos[1] = -3208.0f; pos[2] = 1000.0f; fDir[0] = 1.0f; fDir[1] = -1.0f; fDir[2] = 0.0f; uDir[0] = 0.0f; uDir[1] = 0.0f; uDir[2] = 1.0f; actor.SetDirection(fDir, uDir); actor.SetTerrainRoom(terrainRoomID, 10.0f); beOK = actor.PutOnTerrain(pos); // Get two character actions pre-defined at Lyubu2 idleID = actor.GetBodyAction(NULL, "Idle"); runID = actor.GetBodyAction(NULL, "Run"); // set the character to idle action curPoseID = idleID; actor.SetCurrentAction(NULL, 0, curPoseID); actor.Play(START, 0.0f, FALSE, TRUE); actor.TurnRight(90.0f); // translate the camera cID = scene.CreateObject(CAMERA); FnCamera camera; camera.ID(cID); camera.SetNearPlane(5.0f); camera.SetFarPlane(100000.0f); // set camera initial position and orientation pos[0] = 4069.0f; pos[1] = -3208.0f; pos[2] = 93.046f; fDir[0] = -500.0f; fDir[1] = -0.0f; fDir[2] = -0.0f; uDir[0] = -0.116f; uDir[1] = -0.031f; uDir[2] = 0.993f; camera.SetPosition(pos); camera.SetDirection(fDir, uDir); float mainLightPos[3] = { -4579.0, -714.0, 15530.0 }; float mainLightFDir[3] = { 0.276, 0.0, -0.961 }; float mainLightUDir[3] = { 0.961, 0.026, 0.276 }; FnLight lgt; lgt.ID(scene.CreateObject(LIGHT)); lgt.Translate(mainLightPos[0], mainLightPos[1], mainLightPos[2], REPLACE); lgt.SetDirection(mainLightFDir, mainLightUDir); lgt.SetLightType(PARALLEL_LIGHT); lgt.SetColor(1.0f, 1.0f, 1.0f); lgt.SetName("MainLight"); lgt.SetIntensity(0.4f); // create a text object for displaying messages on screen textID = FyCreateText("Trebuchet MS", 18, FALSE, FALSE); // set Hotkeys FyDefineHotKey(FY_ESCAPE, QuitGame, FALSE); // escape for quiting the game FyDefineHotKey(FY_UP, Movement, FALSE); // Up for moving forward FyDefineHotKey(FY_RIGHT, Movement, FALSE); // Right for turning right FyDefineHotKey(FY_LEFT, Movement, FALSE); // Left for turning left // define some mouse functions if (!IsCameraFollow) { FyBindMouseFunction(LEFT_MOUSE, InitPivot, PivotCam, NULL, NULL); FyBindMouseFunction(MIDDLE_MOUSE, InitZoom, ZoomCam, NULL, NULL); FyBindMouseFunction(RIGHT_MOUSE, InitMove, MoveCam, NULL, NULL); } else { FyBindMouseFunction(LEFT_MOUSE, InitZoom2, ZoomCam2, NULL, NULL); FyBindMouseFunction(RIGHT_MOUSE, NULL, RotateCam, NULL, NULL); } // bind timers, frame rate = 30 fps FyBindTimer(0, 30.0f, GameAI, TRUE); FyBindTimer(1, 30.0f, RenderIt, TRUE); // invoke the system FyInvokeFly(TRUE); }