Jump to content
  • Advertisement
Sign in to follow this  
3dmodelerguy

Keyboars event error

This topic is 5036 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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" );

}

Share this post


Link to post
Share on other sites
Advertisement

I'm just taking a wild guess here, but do you have to call some function to check for messages (in the main loop)?

.bas

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!