|
|
@ -168,7 +168,27 @@ int main() { |
|
|
|
float x = player_x; |
|
|
|
float x = player_x; |
|
|
|
float y = player_y; |
|
|
|
float y = player_y; |
|
|
|
|
|
|
|
|
|
|
|
player_angle -= 0.01; |
|
|
|
if(window.key('Q')) { |
|
|
|
|
|
|
|
player_angle -= 0.1; |
|
|
|
|
|
|
|
} else if(window.key('E')) { |
|
|
|
|
|
|
|
player_angle += 0.1; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(window.key('W')) { |
|
|
|
|
|
|
|
x += -1 * std::sin(player_angle) * 5; |
|
|
|
|
|
|
|
y += std::cos(player_angle) * 5; |
|
|
|
|
|
|
|
} else if(window.key('S')) { |
|
|
|
|
|
|
|
x -= -1 * std::sin(player_angle) * 5; |
|
|
|
|
|
|
|
y -= std::cos(player_angle) * 5; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(window.key('D')) { |
|
|
|
|
|
|
|
x += -1 * std::sin(player_angle + std::numbers::pi * 0.5) * 5; |
|
|
|
|
|
|
|
y += std::cos(player_angle + std::numbers::pi * 0.5) * 5; |
|
|
|
|
|
|
|
} else if(window.key('A')) { |
|
|
|
|
|
|
|
x -= -1 * std::sin(player_angle + std::numbers::pi * 0.5) * 5; |
|
|
|
|
|
|
|
y -= std::cos(player_angle + std::numbers::pi * 0.5) * 5; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(!collision(x, y)) { |
|
|
|
if(!collision(x, y)) { |
|
|
|
player_x = x; |
|
|
|
player_x = x; |
|
|
|