sdl3_3d_oop_basic_game git · main
SDL3 3D OOP basic game (entities, systems, CMake)
C++ 99%git clone https://git.christianimmanuel.de/sdl-graphics/sdl3_3d_oop_basic_game.gitwget https://git.christianimmanuel.de/sdl-graphics/sdl3_3d_oop_basic_game/archive/sdl3_3d_oop_basic_game.tar.gzsrc/systems/input_system.cpp raw
#include "systems/input_system.hpp"
void InputSystem::handleEvent(const SDL_Event& e, PlayerInputState& input, Player& player)
{
switch (e.type) {
case SDL_EVENT_MOUSE_MOTION:
player.addLook((int)e.motion.xrel, (int)e.motion.yrel);
break;
case SDL_EVENT_KEY_DOWN:
case SDL_EVENT_KEY_UP: {
bool down = (e.type == SDL_EVENT_KEY_DOWN);
SDL_Keycode sym = e.key.key;
if (sym == SDLK_W) input.forward = down;
if (sym == SDLK_A) input.left = down;
if (sym == SDLK_S) input.backward = down;
if (sym == SDLK_D) input.right = down;
if (sym == SDLK_SPACE && down) player.jump_pressed = true;
break;
}
}
}