Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!
Werbeanzeige
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
void Game_ProcessInput (unsigned int wParam) { switch(wParam) { case VK_LEFT: if(Player.x_pos >= STEP_SIZE) { Player.x_pos = Player.x_pos - STEP_SIZE; } break; case VK_RIGHT: if(Player.x_pos <= 765) { Player.x_pos = Player.x_pos + STEP_SIZE; } break; case VK_UP: if(Player.y_pos >= STEP_SIZE) { Player.y_pos = Player.y_pos - STEP_SIZE; } break; case VK_DOWN: if(Player.y_pos <= 528) { Player.y_pos = Player.y_pos + STEP_SIZE;} break; default: break; } } // Game_ProcessInput() |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
// Windoe procedure for messages _w64 long __stdcall WndProc (HWND hwnd, unsigned int msg, unsigned int wParam, _w64 long lParam) { // Provess message switch (msg) { // Key pressed case WM_KEYDOWN: { // If 'ESCAPE' has been pressed: Quit if (wParam == VK_ESCAPE) PostQuitMessage (0); // Process input.. Game_ProcessInput(wParam); } break; // [...] return DefWindowProc (hwnd, msg, wParam, lParam); } // WndProc() |
Zitat von »"$nooc"«
ich würde das lieber über die windows messages machen, jedoch weiss ich nicht wie das genau funktioniert
Zitat von »"$nooc"«
Game_ProcessInput() wird bei jeden frame 1mal aufgerufen..
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 |
if( GetAsyncKeyState(VK_LEFT) ) Player.x_pos -= STEP_SIZE; if( GetAsyncKeyState(VK_RIGHT) ) Player.x_pos += STEP_SIZE; if( GetAsyncKeyState(VK_UP) ) Player.y_pos -= STEP_SIZE; if( GetAsyncKeyState(VK_DOWN) ) Player.y_pos += STEP_SIZE; |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 |
if( GetAsyncKeyState(VK_LEFT)<0 ) Player.x_pos -= STEP_SIZE; if( GetAsyncKeyState(VK_RIGHT)<0 ) Player.x_pos += STEP_SIZE; if( GetAsyncKeyState(VK_UP)<0 ) Player.y_pos -= STEP_SIZE; if( GetAsyncKeyState(VK_DOWN)<0 ) Player.y_pos += STEP_SIZE; |
Werbeanzeige