Mercurial > LightClone
comparison LightClone/Source/GameScreen.cpp @ 74:40c0b5305de8
Work on removing ScreenManager
author | koryspansel |
---|---|
date | Tue, 18 Oct 2011 11:56:49 -0700 |
parents | 0574e2cf8bac |
children |
comparison
equal
deleted
inserted
replaced
73:0574e2cf8bac | 74:40c0b5305de8 |
---|---|
1 /* | 1 /* |
2 * GameScreen | 2 * GameScreen |
3 */ | 3 */ |
4 | 4 |
5 #include "GameScreen.h" | 5 #include "GameScreen.h" |
6 #include "ScreenManager.h" | |
7 | 6 |
8 /* | 7 /* |
9 * Initialize | 8 * Initialize |
10 */ | 9 */ |
11 ErrorCode GameScreen::Initialize(ServiceProvider* pServiceProvider) | 10 ErrorCode GameScreen::Initialize(ServiceProvider* pServiceProvider) |
53 | 52 |
54 Terminate(); | 53 Terminate(); |
55 return eCode; | 54 return eCode; |
56 } | 55 } |
57 | 56 |
58 nLogicState = LogicState_LevelLoad; | 57 nGameState = GameState_Load; |
59 nSimulationState = SimulationState_Idle; | 58 nSimulationState = SimulationState_Idle; |
60 nCurrentLevel = 0; | 59 nCurrentLevel = 0; |
61 | 60 |
62 return eCode; | 61 return eCode; |
63 } | 62 } |
69 { | 68 { |
70 kInterface.Terminate(); | 69 kInterface.Terminate(); |
71 kProgram.Terminate(); | 70 kProgram.Terminate(); |
72 kBot.Terminate(); | 71 kBot.Terminate(); |
73 kEnvironment.Terminate(); | 72 kEnvironment.Terminate(); |
74 | |
75 Screen::Terminate(); | |
76 } | 73 } |
77 | 74 |
78 /* | 75 /* |
79 * Update | 76 * Update |
80 */ | 77 */ |
99 /* | 96 /* |
100 * Render | 97 * Render |
101 */ | 98 */ |
102 void GameScreen::Render(RenderContext& kContext) | 99 void GameScreen::Render(RenderContext& kContext) |
103 { | 100 { |
104 if(nLogicState != LogicState_LevelLoad) | 101 if(nGameState != GameState_Load) |
105 { | 102 { |
106 D3DVIEWPORT9 kOriginal; | 103 D3DVIEWPORT9 kOriginal; |
107 kContext.GetViewport(&kOriginal); | 104 kContext.GetViewport(&kOriginal); |
108 | 105 |
109 D3DVIEWPORT9 kViewport; | 106 D3DVIEWPORT9 kViewport; |
411 if(!pInputManager->IsKeyDown(DIK_LCONTROL)) | 408 if(!pInputManager->IsKeyDown(DIK_LCONTROL)) |
412 { | 409 { |
413 if(nCount > 0) | 410 if(nCount > 0) |
414 { | 411 { |
415 nCurrentLevel = 0; | 412 nCurrentLevel = 0; |
416 nLogicState = LogicState_LevelLoad; | 413 nGameState = GameState_Load; |
417 | 414 |
418 for(uint32 i = 0; i < nCount; ++i) | 415 for(uint32 i = 0; i < nCount; ++i) |
419 { | 416 { |
420 nCurrentLevel += (uint32)(nBuffer[i] * powf(10.0f, (float)i)); | 417 nCurrentLevel += (uint32)(nBuffer[i] * powf(10.0f, (float)i)); |
421 } | 418 } |
438 /* | 435 /* |
439 * UpdateLogic | 436 * UpdateLogic |
440 */ | 437 */ |
441 void GameScreen::UpdateLogic(float fElapsed) | 438 void GameScreen::UpdateLogic(float fElapsed) |
442 { | 439 { |
443 if(nLogicState == LogicState_LevelLoad) | 440 if(nGameState == GameState_Load) |
444 { | 441 { |
445 char kBuffer[256]; | 442 char kBuffer[256]; |
446 sprintf(kBuffer, "Data\\Maps\\Map%02d.map", nCurrentLevel++); | 443 sprintf(kBuffer, "Data\\Maps\\Map%02d.map", nCurrentLevel++); |
447 | 444 |
448 ErrorCode eCode = Load(kBuffer); | 445 ErrorCode eCode = Load(kBuffer); |
453 for(uint32 i = 0; i < MaximumFunctionCount; ++i) | 450 for(uint32 i = 0; i < MaximumFunctionCount; ++i) |
454 { | 451 { |
455 pCode[i]->Clear(); | 452 pCode[i]->Clear(); |
456 } | 453 } |
457 | 454 |
458 nLogicState = LogicState_GameActive; | 455 nGameState = GameState_Active; |
459 } | 456 } |
460 else | 457 else |
461 { | 458 { |
462 pScreenManager->Push("GameOver"); | 459 //pScreenManager->Push("GameOver"); |
463 } | 460 } |
464 | 461 |
465 nSimulationState = SimulationState_Idle; | 462 nSimulationState = SimulationState_Idle; |
466 } | 463 } |
467 else | 464 else |
468 | 465 |
469 if(nLogicState == LogicState_GameActive) | 466 if(nGameState == GameState_Active) |
470 { | 467 { |
471 if(nSimulationState == SimulationState_Active) | 468 if(nSimulationState == SimulationState_Active) |
472 { | 469 { |
473 if(kBot.Update(fElapsed)) | 470 if(kBot.Update(fElapsed)) |
474 { | 471 { |
475 if(kEnvironment.RequirementsMet()) | 472 if(kEnvironment.RequirementsMet()) |
476 { | 473 { |
477 nLogicState = LogicState_LevelLoad; | 474 nGameState = GameState_Load; |
478 pScreenManager->Push("LevelOver"); | 475 //pScreenManager->Push("LevelOver"); |
479 } | 476 } |
480 } | 477 } |
481 } | 478 } |
482 } | 479 } |
483 } | 480 } |
549 /* | 546 /* |
550 * OnExit | 547 * OnExit |
551 */ | 548 */ |
552 void GameScreen::OnExit(GuiEventArguments& kArguments) | 549 void GameScreen::OnExit(GuiEventArguments& kArguments) |
553 { | 550 { |
554 pScreenManager->Push("Confirm"); | 551 //pScreenManager->Push("Confirm"); |
555 } | 552 } |