SDL 2.0을 사용 중이므로 SDL_GetKeyboardState
이 예상대로 작동하지 않습니다. 플레이어는 위아래로 움직여야하지만 이것은 일어나지 않습니다. SDL_GetKeyboardState가 현재 키 상태를 반환하지 않습니다.
void Movements() {
const Uint8 *currentKey = SDL_GetKeyboardState(NULL); // Point has to be defined once
if (currentKey[SDLK_w]){
PlayerPaddle.y = PlayerPaddle.y+2;
}
if (currentKey[SDLK_s]){
PlayerPaddle.y = PlayerPaddle.y+2;
}
}
int main(int argc, char* args[]) {
main_menue();
bool running = true;
while (running == true) {
SDL_PollEvent(&occur);
if (occur.type == SDL_QUIT) { // Closes the window, if user stops running
running = false;
}
Movements();
}
}
나는 또한 키의 현재 상태를 읽을 수 없습니다 여전히
PumpEvents
와 이벤트 루프를 펌프하려했으나. 나는 또한이 stackoverflow (
SDL_GetKeyboardState not working) 발견했지만 거기에 대한 해결책을 찾을 도움이되지 않았다. 내가 여기서 뭔가 못 찾았 니? 나는 정말로 장님이고 오해하고 있습니까?
완전한 형식으로 코드를 보지 않고도 말하기가 너무 어렵습니다. 여기에 SDL 초기화 코드가 없거나 오류 검사가 없습니다. – Zammalad