Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.
Moderator: Coders of Rage
-
lalacomun
- VS Setup Wizard
- Posts: 114
- Joined: Wed Dec 28, 2011 10:18 pm
- Favorite Gaming Platforms: psx, nintendo ds, gameboy advance, xbox 360, ps2
- Programming Language of Choice: C++
- Location: Argentina
-
Contact:
Post
by lalacomun »
Well, i am making a engine, and my input core is not working corectly, it looks something like this:
Code: Select all
class acInput
{
acInput();
bool acKeyDown(Key key) //this is an enum of keys i made
...
that is for the Input.h
now the input.cpp:
Code: Select all
#include "input.h"
...
bool acInput::acKeyDown(Key key)
{
Uint8 *keystates = SDL_GetKeyState(NULL);
if(keystates[key])
return true;
}
and in the main funtion i use it like this:
Code: Select all
int main(int argc,char *argv[])
{
...
acInput input;
...
if(input.acKeyDown(KEY_UP)
{
//Do something, but it doesnt work!!!!!
}
but the problem is that it doesnt do anything!!
any suggestions??
-
lalacomun
- VS Setup Wizard
- Posts: 114
- Joined: Wed Dec 28, 2011 10:18 pm
- Favorite Gaming Platforms: psx, nintendo ds, gameboy advance, xbox 360, ps2
- Programming Language of Choice: C++
- Location: Argentina
-
Contact:
Post
by lalacomun »
Well, its solved!
, i needed to put "while(SDL_PollEvent(&event)" before using the function, i have no idea why as i am using keystates, no events =p