Original Post
now this is the code that i think has the problem, this is my main game file and i am trying to get so when i press a Q (or any key) down it changes the Game_State value to 0 so the hile statement should end and the app should die. the thing is that it runs but when i push q or any other button nothing happens, what is wrong with my code?
#include "PrecompiledHeaders.h"
#include "MainApp.h"
#include "GameWindow.h"
#include "GLCanvas.h"
int Default_Window_Value = -1;
int test = 2;
int Game_State = 1;
DWORD Default_GL_Style = wxNO_BORDER;
wxString Empty_String;
// Event Table For The Main Game Window
BEGIN_EVENT_TABLE( GLCanvas, wxGLCanvas )
EVT_KEY_DOWN( MainApp::EndGame )
END_EVENT_TABLE()
IMPLEMENT_APP( MainApp );
bool MainApp::OnInit()
{
StartGame();
return true;
}
void MainApp::StartGame()
{
MainGameWindow *GameWindow = new MainGameWindow( _T ( "Stromgage Game Engine" ), wxPoint( 100, 100 ), wxSize( 800, 600 ) );
GLCanvas *GLWindow = new GLCanvas( GameWindow, test, wxPoint( 0, 0 ), wxSize( 800, 600 ), Default_GL_Style, Empty_String );
GameWindow -> Show( true );
GLWindow -> SetCurrent();
while(Game_State == 1)
{
GLWindow->SwapBuffers();
}
delete GLWindow;
delete GameWindow;
}
void MainApp::EndGame( wxKeyEvent &event )
{
Game_State = 0;
wxMessageBox( "Game_State = 0" );
}