I was browsing my controller code when I noticed the SDL_PollEvent(SDL_Event *event) function. Now that's promising. It works liek soo:
Code: Select all
SDL_Event event;
if( SDL_PollEvent(&event) )
{
switch( event.type )
{
...
Moderator: Coders of Rage
Code: Select all
SDL_Event event;
if( SDL_PollEvent(&event) )
{
switch( event.type )
{
...
Small girl at the harbor wrote:Look Brandon, that crab's got ham!
Code: Select all
SDL_PollEvents(&event);
switch(event.type)
{
case SDL_KEYDOWN://I think
if(event.key.keysym.sym == SDLK_LEFT)
m_position.x += 5;//whatever assuming position is a vector
else if(event.key.keysym.sym == SDLK_RIGHT)
m_position.x -= 5;
break;
};
Code: Select all
SDL_PumpEvents();
memcpy(keyboard.oldKeys, keyboard.keys,sizeof(unsigned char) * keycount);
unsigned char *tempKeys = SDL_GetKeyState(&keycount);
memcpy(keyboard.keys, tempKeys,sizeof(unsigned char) * keycount);
Code: Select all
if(Input::GetSingleton().keyDown(SDLK_RIGHT) == true)
Code: Select all
if(Input::GetSingleton().keyStillDown(SDLK_RIGHT) == true)
Gyro Sheen wrote:you pour their inventory onto my life
IRC wrote: <sparda> The routine had a stack overflow, sorry.
<sparda> Apparently the stack was full of shit.
It seems alot like you're describing a *dun dun dun* singleton! xDAnd I could put that anywhere. Anyone know how this is done? How I could call something like getControllerClassPointer() and have it return the pointer to the initiated class?
Code: Select all
class Hector {
[ . . . ]
public:
Hector *get(void) { return this; }
[ . . . ]
}
Code: Select all
InputClass *input =InputClass::getInstance();
if(input->key[A] ) {
x++
}
Code: Select all
if((InputClass::getInstance())->key[A] ) {
x++
}
Then input would be the equivalent of a MySpace whoreArce wrote: Alternatively, I guess you could make the input class friends with everything else, but that'd be pretty gay...o.o;
Gyro Sheen wrote:you pour their inventory onto my life
IRC wrote: <sparda> The routine had a stack overflow, sorry.
<sparda> Apparently the stack was full of shit.
Small girl at the harbor wrote:Look Brandon, that crab's got ham!
M_D_K wrote:Then input would be the equivalent of a MySpace whoreArce wrote: Alternatively, I guess you could make the input class friends with everything else, but that'd be pretty gay...o.o;
Small girl at the harbor wrote:Look Brandon, that crab's got ham!
Code: Select all
int main() {
srand((unsigned)time(0));
//main func init stuff
Singleton *master;
master = Singleton::getInstance();
master->drawTitleScreen();
master->showRules() ;
//main loop
while(master->running()) {
//Start a new game if not already started
if(!master->gameStarted())
initGame();
//Go, assbritches.
master->contestant[master->current].playTurn();
//self explanatory, rendering this comment useless...
master->drawGame();
}
//thus end my platform independence...Oh, wait, it's been gone since well before this time.
system("pause");
return 0;
}
Code: Select all
Update()
{
playerObj->handleInput(inputState);
}
trufun actually isn't an OO Nazi.Arce wrote:Okay, Mr. Beautiful OO design, I see how you're too good for singletons.