Quote:Original post by Anonymous PosterQuote:Original post by EvilKnuckles666
hmm... would i be able to just have something that looks like this?
*** Source Snippet Removed ***
also:
so the pollevent() needs to be at the top with the getkeystate() and the pumpevents() needs to be at the bottom once i'm done checking the states and whatnot?
edit:
since the SDL_EVENT only checks one key, and i'm going to use the getkeystate() anyway? could i just avoid using pollevent() completely? or would i have to do just what i'm doing in that code i posted and just ahve a call to it?
Basicly, yes, you can have code like that. Take this as a note though, it DOESN'T have to look like that, it's just how I wrote some code. What you should do is:
*** Source Snippet Removed ***
My previous code was just an example.
No, it doesn't have to be in that order. It's just the order that I and many others prefer because of it's readability.
SDL_Event will hold events. Each key press, and any other message is an event. However, when you press 'w' and key holding it and press 'd' you will get a message for 'd', and not for 'w'. This is not what you wan't in games because your character then won't be able to move diagnoally. However, this is good for menus. This is where SDL_GetKeyState is nice. It get's a snapshot of the keys. So it can capture many keys at once. This way, you can have diagnol movement.
C++
I thought you said not 'avoid' but 'only use'. Anyways, not really.
SDL will send many messages. For example, the 'X' on top of your window is a message. When you click it, you get SDL_QUIT. Knowing that, you would quit. However, you would not get SDL_QUIT without SDL_PollEvent.
Do you see what I mean? I don't know how to explain, really... Ask if you have any more questions.
C++