Code: Select all
LNK2019: unresolved external symbol __imp___CrtDbgReportW
Moderator: Coders of Rage
Code: Select all
LNK2019: unresolved external symbol __imp___CrtDbgReportW
Code: Select all
keystates = SDL_GetKeyState( NULL );
Code: Select all
Access violation reading location 0xcccccccc
I apologize.GyroVorbis wrote:...You can't just show us a line of code that is syntactically correct then show us an error. Obviously that's not enough information. =/
Code: Select all
class Input
{
public:
void Init();
int Poll();
bool Type( Uint8 type );
SDL_Event *Get();
Uint8 GetKey( int key, int check = INPUT_ISDOWN );
int GetMouse( int button, int check = INPUT_ISDOWN );
private:
SDL_Event event;
Uint8 *keystates;
bool keyEvents[322][2];
int mousestates[3];
bool mouseEvents[3][2];
};
Code: Select all
void Input::Init()
{
keystates = SDL_GetKeyState( NULL );
mousestates[0] = false;
mousestates[1] = false;
mousestates[2] = false;
for( int i = 0; i < 322; i++ )
{
keyEvents[i][0] = false;
keyEvents[i][1] = false;
}
}
int Input::Poll()
{
SDL_PumpEvents();
for( int i = 0; i < 322; i++ )
{
keyEvents[i][0] = keyEvents[i][1];
if( keystates[i] == 0 )
{
keyEvents[i][1] = false;
}
else
{
keyEvents[i][1] = true;
}
}
mousestates[0] = SDL_GetMouseState( NULL, NULL ) & SDL_BUTTON( 1 );
mousestates[1] = SDL_GetMouseState( NULL, NULL ) & SDL_BUTTON( 2 );
mousestates[2] = SDL_GetMouseState( NULL, NULL ) & SDL_BUTTON( 3 );
for( int i = 0; i < 3; i++ )
{
mouseEvents[i][0] = mouseEvents[i][1];
if( mousestates[i] == 0 )
{
mouseEvents[i][1] = false;
}
else
{
mouseEvents[i][1] = true;
}
}
return SDL_PollEvent( &event );
}
bool Input::Type( Uint8 type )
{
return event.type == type;
}
SDL_Event *Input::Get()
{
return &event;
}
Uint8 Input::GetKey( int key, int check )
{
if( check == INPUT_RELEASE )
{
if( keyEvents[key][0] == true && keyEvents[key][1] == false )
{
return true;
}
else
{
return false;
}
}
else if( check == INPUT_PRESS )
{
if( keyEvents[key][0] == false && keyEvents[key][1] == true )
{
return true;
}
else
{
return false;
}
}
return keystates[key];
}
int Input::GetMouse( int button, int check )
{
if( check == INPUT_RELEASE )
{
if( mouseEvents[button][0] == true && mouseEvents[button][0] == false )
{
return true;
}
else
{
return false;
}
}
else if( check == INPUT_PRESS )
{
if( mouseEvents[button][0] == false && mouseEvents[button][0] == true )
{
return true;
}
else
{
return false;
}
}
return mousestates[button - 1];
}
Code: Select all
SDL.lib SDLmain.lib SDL_image.lib SDL_mixer.lib OpenGL32.lib glu32.lib
This^Boogy wrote:Have you initialized SDL before calling SDL_GetKeyState()?
And are you running in debug mode because release can produce different result
Code: Select all
int Input::GetMouse( int button, int check )
Code: Select all
return mousestates[button - 1];