Skip to main content
gamedev.net
🔒 Locked

Keyboars event error

Started by 3dmodelerguy 3 replies 1.1k views
Original Post
3dmodelerguy
3dmodelerguy
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" );

}

Genjix
Genjix
have you declared the event table in MainApp.h?
3dmodelerguy
3dmodelerguy
yes, as i said the program compiles fine, this is a runtime error?
bastardos
bastardos

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
.basprintf ( "And for the %dth time, I'm not American!", ++lIdiots );My homepage
3dmodelerguy
3dmodelerguy
no, you probloby need to know wxWidgets to know the problem, nut thanks anyways.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.