diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-01-25 00:52:31 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-01-25 00:53:57 +0000 |
commit | 3ad1eca1b7c0992ff5f64fce5d26a722ea6fe5dc (patch) | |
tree | ee7eaf49ea120428c86a6c63a7d862b2cda85ba4 | |
parent | Remove the weird view/model/camera connectedness (diff) | |
download | ilt-3ad1eca1b7c0992ff5f64fce5d26a722ea6fe5dc.tar.bz2 ilt-3ad1eca1b7c0992ff5f64fce5d26a722ea6fe5dc.tar.xz ilt-3ad1eca1b7c0992ff5f64fce5d26a722ea6fe5dc.zip |
Basic key controls to move the camera around
-rw-r--r-- | application/main.cpp | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/application/main.cpp b/application/main.cpp index 015f128..2f9ae36 100644 --- a/application/main.cpp +++ b/application/main.cpp @@ -67,7 +67,8 @@ public: world.create<Monkey>(); Shader shader; - Camera camera({0.0F, 0.0F, -5.0F}, 70.0F, (float)DISPLAY_WIDTH / (float)DISPLAY_HEIGHT, 0.1F, 100.0F); + Camera camera({-5.0F, 2.0F, -5.0F}, 70.0F, (float)DISPLAY_WIDTH / (float)DISPLAY_HEIGHT, 0.1F, 100.0F); + camera.RotateY(0.7854); shader.Bind(); shader.setView(camera.GetViewProjection()); @@ -79,8 +80,33 @@ public: while (isRunning) { while (SDL_PollEvent(&e)) { - if (e.type == SDL_QUIT) { - isRunning = false; + switch (e.type) { + case SDL_QUIT: + isRunning = false; + break; + case SDL_KEYDOWN: + switch (e.key.keysym.sym) { + case SDLK_KP_8: + camera.MoveForward(1); + break; + case SDLK_KP_2: + camera.MoveForward(-1); + break; + case SDLK_KP_4: + camera.MoveRight(1); + break; + case SDLK_KP_6: + camera.MoveRight(-1); + break; + case SDLK_KP_7: + camera.RotateY(0.04); + break; + case SDLK_KP_9: + camera.RotateY(-0.04); + break; + } + shader.setView(camera.GetViewProjection()); + break; } } |