Yo, back again to spam your forum up with help problems don't mind me.
Anyways, When I am checking for the enter keystate it triggers the whole switch statement and places all the cards, its supposed place one card a time, when you hit enter.
Basically I just want it to run through the switch once and then exit once it goes through the case, until the next time the keystate is triggered.
Its black jack not a MMORPGFPSRTS, I don't need to make it inline, and yea I probably don't need to use getters and setters but, I am just lazy
Is there a keystate for a release return key?
EDIT: btw, for class methods you don't put inline if you already have it on a single line it automatically makes it inline
Current Games:
Black Jack [WIP]
Tic Tac Toe [SDL]
Tic Tac Toe
while (SDL_PollEvent(&keyevent)) //Poll our SDL key event for any keystrokes.
{
switch(keyevent.type){
case SDL_KEYUP:
switch(keyevent.key.keysym.sym){
case SDLK_RETURN:
//Enter key let up
break;
default:
break;
}
}
}
jakobnator wrote:EDIT: btw, for class methods you don't put inline if you already have it on a single line it automatically makes it inline
...no. The way C++ deals with methods is that, if the method's body is INSIDE the class declaration, it tries to inline it. The amount of lines doesn't matter one bit.
Quit procrastinating and make something awesome.
Ducky wrote:Give a man some wood, he'll be warm for the night. Put him on fire and he'll be warm for the rest of his life.
jakobnator wrote:EDIT: btw, for class methods you don't put inline if you already have it on a single line it automatically makes it inline
...no. The way C++ deals with methods is that, if the method's body is INSIDE the class declaration, it tries to inline it. The amount of lines doesn't matter one bit.
Alright cool, wasn't sure exactly how it works thanks for clearing it.
While Jesus equipped with angels, the Devil's equipped with cops
For God so loved the world that he blessed the thugs with rock
While polling will work for what you're doing right now, take this as a chance to learn how to dump the entire key state at once, it'll help make things clearer.
As for your immediate problem, it's a key repeat problem, you can solve it by checking to make sure the key hasn't already been pressed or you could disable key repeat.
You should look at SDL_GetKeyState if you wanna go the dumping the entire keystate route. Makes it really easy to keep 2 copies of the key state (current and last frame's) so you can do things like:
Odd....it works the first compile, then if I run it again it doesn't do anything but if I delete the line, recompile it, put the line back, then compile again it will work once more. Any ideas?
Current Games:
Black Jack [WIP]
Tic Tac Toe [SDL]
Tic Tac Toe
Did you change anything else? Trace your steps. Print some sort of debug text to the command line. The function "SDL_EnableKeyRepeat" returns a value of 0 on success, output what it returns. Also, if all you did was add, remove and then re-add the function, you must have done something else, otherwise im confused as fuck.
It returns 0, and I don't know what you mean about adding.
EDIT: I have a temporary fix by using a debounce that is reset by pressing the "G" key, so everytime you want to make a move you have to press "G" but oh well .
Current Games:
Black Jack [WIP]
Tic Tac Toe [SDL]
Tic Tac Toe