From 18c4375b61a15b253bbd9941ed1dd6e91ad35ba3 Mon Sep 17 00:00:00 2001 From: Rafefix <36264913+Rafefix@users.noreply.github.com> Date: Sun, 22 Apr 2018 20:42:07 +0200 Subject: [PATCH] player limits with camera established --- ModulePlayer.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/ModulePlayer.cpp b/ModulePlayer.cpp index 0a36dcf..ff78b42 100644 --- a/ModulePlayer.cpp +++ b/ModulePlayer.cpp @@ -145,22 +145,21 @@ update_status ModulePlayer::Update() if (enable_movement) { - if (App->input->keyboard[SDL_SCANCODE_D] == KEY_STATE::KEY_REPEAT) + if (App->input->keyboard[SDL_SCANCODE_D] == KEY_STATE::KEY_REPEAT && position.x < App->render->camera.x / SCREEN_SIZE + SCREEN_WIDTH-40) { - position.x += speed; + position.x += speed; } - if (App->input->keyboard[SDL_SCANCODE_A] == KEY_STATE::KEY_REPEAT &&position.x>App->render->camera.x/SCREEN_SIZE) + if (App->input->keyboard[SDL_SCANCODE_A] == KEY_STATE::KEY_REPEAT && position.x > App->render->camera.x / SCREEN_SIZE) { position.x -= speed; } - if (App->input->keyboard[SDL_SCANCODE_W] == KEY_STATE::KEY_DOWN) + if (App->input->keyboard[SDL_SCANCODE_W] == KEY_STATE::KEY_DOWN && position.y > App->render->camera.y/SCREEN_SIZE) { position.y -= speed; current_animation = &upward; current_animation->Reset(); - } - if (App->input->keyboard[SDL_SCANCODE_W] == KEY_STATE::KEY_REPEAT && position.y>App->render->camera.y) + if (App->input->keyboard[SDL_SCANCODE_W] == KEY_STATE::KEY_REPEAT && position.y > App->render->camera.y/SCREEN_SIZE) { position.y -= speed; current_animation = &upward; @@ -171,14 +170,14 @@ update_status ModulePlayer::Update() current_animation = &upwardreturn; } } - if (App->input->keyboard[SDL_SCANCODE_S] == KEY_STATE::KEY_DOWN) + if (App->input->keyboard[SDL_SCANCODE_S] == KEY_STATE::KEY_DOWN && position.y < App->render->camera.y /SCREEN_SIZE + SCREEN_HEIGHT-50) { position.y += speed * 1.5f; current_animation = &downward; current_animation->Reset(); } - if (App->input->keyboard[SDL_SCANCODE_S] == KEY_STATE::KEY_REPEAT) + if (App->input->keyboard[SDL_SCANCODE_S] == KEY_STATE::KEY_REPEAT && position.y < App->render->camera.y /SCREEN_SIZE + SCREEN_HEIGHT - 50) { position.y += speed * 1.5f; current_animation = &downward;