Commit 34cce019 authored by Benjamin Barz's avatar Benjamin Barz
Browse files

added level borders for ship movement

parent 10899e61
......@@ -35,7 +35,9 @@ namespace gdw {
if(!move) return;
auto input = engine_.input();
if (input.isKeyDown(SDLK_a)) {
float maximum_movement_distance = 11.f;
if (input.isKeyDown(SDLK_a) && player->position().x > -maximum_movement_distance) {
move->add_force(glm::vec3(-level_manager.player_speed(), 0.f,0.f));
auto euler = glm::eulerAngles(player->rotation());
auto diff = std::abs(euler.z - (-(M_PI/2.f)));
......@@ -44,7 +46,7 @@ namespace gdw {
} else
move->add_angular_force(glm::vec3(0.f, 0.f , -10.f*diff));
}
if (engine_.input().isKeyDown(SDLK_d)) {
if (engine_.input().isKeyDown(SDLK_d) && player->position().x < maximum_movement_distance) {
move->add_force(glm::vec3(level_manager.player_speed(), 0.f,0.f));
auto euler = glm::eulerAngles(player->rotation());
auto diff = std::abs(euler.z - ((M_PI/2.f)));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment