Skip to content

Commit

Permalink
player limits with camera established
Browse files Browse the repository at this point in the history
  • Loading branch information
Rafefix committed Apr 22, 2018
1 parent 7143dce commit 18c4375
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions ModulePlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit 18c4375

Please sign in to comment.