From 3e5094db87d978542f93478d64a0c4df44868d69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20=C4=8C=C3=AD=C5=BE?= Date: Tue, 18 Jun 2019 22:58:37 +0200 Subject: [PATCH] Update city --- programs/city.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/programs/city.c b/programs/city.c index 5a11e6a..c887d19 100644 --- a/programs/city.c +++ b/programs/city.c @@ -206,15 +206,11 @@ int main() int16_t stepRotation = S3L_max(1,300 * frameDiff); if (state[SDL_SCANCODE_LEFT]) - { models[1].transform.rotation.y += stepRotation; - S3L_rotationToDirections(models[1].transform.rotation,S3L_FRACTIONS_PER_UNIT,&carDirection,0,0); - } else if (state[SDL_SCANCODE_RIGHT]) - { models[1].transform.rotation.y -= stepRotation; - S3L_rotationToDirections(models[1].transform.rotation,S3L_FRACTIONS_PER_UNIT,&carDirection,0,0); - } + + S3L_rotationToDirections(models[1].transform.rotation,S3L_FRACTIONS_PER_UNIT,&carDirection,0,0); if (state[SDL_SCANCODE_UP]) { @@ -227,6 +223,12 @@ int main() models[1].transform.translation.z -= (carDirection.z * step) / S3L_FRACTIONS_PER_UNIT; } + scene.camera.transform.translation.x = scene.models[1].transform.translation.x - carDirection.x; + scene.camera.transform.translation.y = S3L_FRACTIONS_PER_UNIT; + scene.camera.transform.translation.z = scene.models[1].transform.translation.z - carDirection.z; + + scene.camera.transform.rotation.y = -1 * scene.models[1].transform.rotation.y; + SDL_RenderClear(renderer); SDL_RenderCopy(renderer,textureSDL,NULL,NULL); SDL_RenderPresent(renderer);