Commit 6a1abb5d authored by Srb František's avatar Srb František
Browse files

fix #5

Nyní žádně warningy/errory na mám stroji i pro /Wall
parent 2db75ed9
...@@ -8,7 +8,7 @@ Enemy::Enemy(float fov, float vision_range, std::pair<float, float> position, ...@@ -8,7 +8,7 @@ Enemy::Enemy(float fov, float vision_range, std::pair<float, float> position,
{ {
// recalculate point stops to lines (to show them on DEBUG_MODE) // recalculate point stops to lines (to show them on DEBUG_MODE)
std::vector<Line> line_path; std::vector<Line> line_path;
auto [last_x, last_y, _] = path[0]; auto&& [last_x, last_y, _] = path[0];
for (auto&& [x, y, _] : path) { for (auto&& [x, y, _] : path) {
if (x != last_x || y != last_y) { if (x != last_x || y != last_y) {
line_path.push_back(Line(last_x, last_y, x, y, color, color)); line_path.push_back(Line(last_x, last_y, x, y, color, color));
...@@ -19,12 +19,10 @@ Enemy::Enemy(float fov, float vision_range, std::pair<float, float> position, ...@@ -19,12 +19,10 @@ Enemy::Enemy(float fov, float vision_range, std::pair<float, float> position,
this->line_path = line_path; this->line_path = line_path;
} }
void Enemy::update(double delta_time) void Enemy::update(float delta_time)
{ {
//TODO
//probably will redo this piece of code
static constexpr float epsilon = 0.01f; static constexpr float epsilon = 0.01f;
auto [stop_x, stop_y, wait_time] = path[path_index]; auto&& [stop_x, stop_y, wait_time] = path[path_index];
auto [x, y] = position; auto [x, y] = position;
if (path.size() == 1) { if (path.size() == 1) {
rotation += delta_time; rotation += delta_time;
...@@ -54,7 +52,7 @@ void Enemy::update(double delta_time) ...@@ -54,7 +52,7 @@ void Enemy::update(double delta_time)
++path_index; ++path_index;
} }
} }
auto [next_stop_x, next_stop_y, _] = path[path_index]; auto&& [next_stop_x, next_stop_y, _] = path[path_index];
rotation = atan2(next_stop_y - y, next_stop_x - x); rotation = atan2(next_stop_y - y, next_stop_x - x);
} }
} }
......
...@@ -24,11 +24,11 @@ public: ...@@ -24,11 +24,11 @@ public:
size_t path_index; size_t path_index;
float progress; float progress;
bool waiting; bool waiting;
std::optional<std::vector<Line>> line_path; std::optional<std::vector<Line>> line_path;
Enemy(float fov, float vision_range, std::pair<float, float> position, Enemy(float fov, float vision_range, std::pair<float, float> position,
float mov_speed, float rot_speed, int rays, tuple_color color, float mov_speed, float rot_speed, int rays, tuple_color color,
std::vector<std::tuple<float, float, int>> path); std::vector<std::tuple<float, float, int>> path);
void update(double delta_time); void update(float delta_time);
}; };
\ No newline at end of file
...@@ -132,13 +132,14 @@ ...@@ -132,13 +132,14 @@
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile> <ClCompile>
<WarningLevel>Level3</WarningLevel> <WarningLevel>EnableAllWarnings</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking> <FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions> <IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck> <SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode> <ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>$(SolutionDir)\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>$(SolutionDir)\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Console</SubSystem> <SubSystem>Console</SubSystem>
......
...@@ -117,25 +117,24 @@ void Scene::load_scene_from_file(std::string file) ...@@ -117,25 +117,24 @@ void Scene::load_scene_from_file(std::string file)
void Scene::render_scene(const Display& display) const void Scene::render_scene(const Display& display) const
{ {
if(DEBUG_MODE || draw_walls) if(DEBUG_MODE || draw_walls)
display.DrawObject((float*)& (walls[0]), walls.size() * 2); display.DrawObject((float*)& (walls[0]), (unsigned int)walls.size() * 2);
//draw sonar //draw sonar
if(sonar.has_value()){ if(sonar.has_value()){
auto sonar_lines_ptr = get_player_lines(walls,sonar.value()); auto sonar_lines_ptr = get_player_lines(walls,sonar.value());
float sin_green = (sin(time)+1)/2; display.DrawObject((float*)&((*sonar_lines_ptr)[0]), (unsigned int)sonar_lines_ptr->size() * 2);
display.DrawObject((float*)&((*sonar_lines_ptr)[0]), sonar_lines_ptr->size() * 2);
} }
if(DEBUG_MODE) if(DEBUG_MODE)
//draw paths //draw paths
for (auto&& enemy : enemies) { for (auto&& enemy : enemies) {
auto&& line_path = enemy.line_path.value(); auto&& line_path = enemy.line_path.value();
display.DrawObject((float*)&(line_path[0]), line_path.size() * 2); display.DrawObject((float*)&(line_path[0]), (unsigned int)line_path.size() * 2);
} }
//draw enemies //draw enemies
for (auto&& enemy : enemies) { for (auto&& enemy : enemies) {
if (!pos_is_visible(player, enemy.position) && !DEBUG_MODE && (!sonar.has_value() || !pos_is_visible((*sonar), enemy.position))) if (!pos_is_visible(player, enemy.position) && !DEBUG_MODE && (!sonar.has_value() || !pos_is_visible((*sonar), enemy.position)))
continue; continue;
auto enemy_lines_ptr = get_player_lines(walls, enemy); auto enemy_lines_ptr = get_player_lines(walls, enemy);
display.DrawObject((float*)&((*enemy_lines_ptr)[0]), enemy_lines_ptr->size() * 2); display.DrawObject((float*)&((*enemy_lines_ptr)[0]), (unsigned int)enemy_lines_ptr->size() * 2);
} }
//draw goal //draw goal
if (DEBUG_MODE || pos_is_visible(player, goal)) { if (DEBUG_MODE || pos_is_visible(player, goal)) {
...@@ -147,7 +146,7 @@ void Scene::render_scene(const Display& display) const ...@@ -147,7 +146,7 @@ void Scene::render_scene(const Display& display) const
display.DrawObject((float*)&(goal_lines[0]), 4); display.DrawObject((float*)&(goal_lines[0]), 4);
} }
auto player_lines_ptr = get_player_lines(walls,player); auto player_lines_ptr = get_player_lines(walls,player);
display.DrawObject((float*)&((*player_lines_ptr)[0]), player_lines_ptr->size() * 2); display.DrawObject((float*)&((*player_lines_ptr)[0]), (unsigned int)player_lines_ptr->size() * 2);
} }
void Scene::restart_scene() void Scene::restart_scene()
...@@ -207,7 +206,7 @@ void Scene::handle_input(GLFWwindow* window) ...@@ -207,7 +206,7 @@ void Scene::handle_input(GLFWwindow* window)
delta_pos = new_pos; delta_pos = new_pos;
} }
bool Scene::update(double delta_time) bool Scene::update(float delta_time)
{ {
//----player---- //----player----
if (!check_collision(delta_time)) if (!check_collision(delta_time))
...@@ -247,8 +246,8 @@ bool Scene::end_screen(const Display& display) ...@@ -247,8 +246,8 @@ bool Scene::end_screen(const Display& display)
} }
bar.push_back(Line(-1.0f, y, 1.0f, y, red, red)); bar.push_back(Line(-1.0f, y, 1.0f, y, red, red));
} }
display.DrawObject((float*)&(bar[0]), bar.size()); display.DrawObject((float*)&(bar[0]), (unsigned int)bar.size());
end_screen_height += bar.size()/4; end_screen_height += (int)(bar.size()/4);
return false; return false;
} }
...@@ -309,7 +308,7 @@ std::unique_ptr<vec_lines> Scene::get_player_lines(const vec_lines& walls, const ...@@ -309,7 +308,7 @@ std::unique_ptr<vec_lines> Scene::get_player_lines(const vec_lines& walls, const
{ {
vec_lines lines; vec_lines lines;
auto [x, y] = player.position; //unstructre pair to 2 floats auto [x, y] = player.position; //unstructre pair to 2 floats
double line_size=player.vision_range; float line_size=player.vision_range;
//beginning angle of rays //beginning angle of rays
float angle = player.rotation-player.fov/2; float angle = player.rotation-player.fov/2;
for (size_t i = 0; i < player.rays; i++) for (size_t i = 0; i < player.rays; i++)
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include <optional> #include <optional>
#include <memory> #include <memory>
#define PI 3.14159265 #define PI 3.14159265f
#define DEBUG_MODE false #define DEBUG_MODE false
using vec_lines = std::vector<Line>; using vec_lines = std::vector<Line>;
...@@ -21,7 +21,7 @@ public: ...@@ -21,7 +21,7 @@ public:
void render_scene(const Display& display) const; void render_scene(const Display& display) const;
void restart_scene(); void restart_scene();
void handle_input(GLFWwindow* window); void handle_input(GLFWwindow* window);
bool update(double delta_time); bool update(float delta_time);
bool end_screen(const Display& display); bool end_screen(const Display& display);
bool check_collision(float delta_time) const; bool check_collision(float delta_time) const;
bool pos_is_visible(const Player& character, pos position) const; bool pos_is_visible(const Player& character, pos position) const;
......
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