diff --git a/.idea/editor.xml b/.idea/editor.xml
index f5ce3a9..dbe54e8 100644
--- a/.idea/editor.xml
+++ b/.idea/editor.xml
@@ -33,7 +33,7 @@
-
+
@@ -523,8 +523,5 @@
-
-
-
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
index 309514d..4612212 100644
--- a/.idea/vcs.xml
+++ b/.idea/vcs.xml
@@ -2,6 +2,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2754ca5..0bb8e6a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -51,7 +51,7 @@ macro(blt_add_project name source type)
project(tower-defense)
endmacro()
-project(tower-defense VERSION 0.0.17)
+project(tower-defense VERSION 0.0.18)
option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF)
option(ENABLE_UBSAN "Enable the ub sanitizer" OFF)
diff --git a/include/enemies.h b/include/enemies.h
index 2ee7593..9ad0ac8 100644
--- a/include/enemies.h
+++ b/include/enemies.h
@@ -127,7 +127,7 @@ namespace td
void add_enemy(enemy_id_t enemy_id, const enemy_t& enemy)
{
const auto index = static_cast(enemy_id);
- if (enemies_registry.size() <= index)
+ if (static_cast(enemies_registry.size()) <= index)
enemies_registry.resize(index + 1, enemy_t{"no_enemy_texture", {}});
enemies_registry[index] = enemy;
}
diff --git a/include/map.h b/include/map.h
index 6a039b4..0ec26a5 100644
--- a/include/map.h
+++ b/include/map.h
@@ -27,43 +27,6 @@
namespace td
{
- struct curve_mesh_data_t
- {
- struct line_vertex_t
- {
- blt::vec3 pos;
- blt::vec2 uv;
- };
-
- [[nodiscard]] std::unique_ptr to_vertex_array() const;
- void populate_vertex_array(blt::gfx::vertex_array_t& va) const;
-
- [[nodiscard]] std::vector calculate_vertices() const;
-
- curve_mesh_data_t& with(const curve_mesh_data_t& mesh)
- {
- lines.insert(lines.end(), mesh.lines.begin(), mesh.lines.end());
- return *this;
- }
-
- std::vector lines;
- };
-
- class curve_t
- {
- public:
- curve_t(blt::vec2 p0, blt::vec2 p1, blt::vec2 p2);
- curve_t(blt::vec2 p0, blt::vec2 p1, blt::vec2 p2, blt::vec2 p3);
-
- [[nodiscard]] blt::vec2 get_point(float t) const;
-
- [[nodiscard]] std::vector to_lines(blt::i32 segments) const;
-
- [[nodiscard]] curve_mesh_data_t to_mesh(blt::i32 segments) const;
- private:
- blt::vec2 m_p0, m_p1, m_p2, m_p3;
- };
-
class path_segment_t
{
public:
diff --git a/lib/blt-with-graphics b/lib/blt-with-graphics
index 8a98d76..f60ce3d 160000
--- a/lib/blt-with-graphics
+++ b/lib/blt-with-graphics
@@ -1 +1 @@
-Subproject commit 8a98d767677d9bdc06889f21aa6c7ffc60a3efb5
+Subproject commit f60ce3dc0b6528e0fd8ce65eb4def187c8d5834a
diff --git a/src/main.cpp b/src/main.cpp
index bf7e52a..7dd6e28 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -13,7 +13,8 @@ blt::gfx::first_person_camera camera;
float t = 0;
float dir = 1;
-td::curve_t curve{blt::vec2{250, 250}, blt::vec2{400, 500}, blt::vec2{600, 500}, blt::vec2{750, 250}};
+blt::gfx::curve2d_t curve{blt::vec2{250, 250}, blt::vec2{400, 500}, blt::vec2{600, 500}, blt::vec2{750, 250}};
+blt::gfx::curve2d_mesh_data_t mesh;
void init(const blt::gfx::window_data&)
{
@@ -28,6 +29,7 @@ void init(const blt::gfx::window_data&)
global_matrices.create_internals();
resources.load_resources();
renderer_2d.create();
+ mesh = curve.to_mesh(32);
}
void update(const blt::gfx::window_data& data)
@@ -50,10 +52,11 @@ void update(const blt::gfx::window_data& data)
}
auto pos = curve.get_point(t);
- renderer_2d.drawRectangleInternal(blt::make_color(1, 0, 0), blt::gfx::rectangle2d_t{pos, blt::vec2{25, 25}});
- auto lines = curve.to_lines(32);
- for (const auto& line : lines)
- renderer_2d.drawLineInternal(blt::make_color(0, 1,0), line);
+ renderer_2d.drawRectangle(blt::gfx::rectangle2d_t{pos, blt::vec2{25, 25}}, blt::make_color(1, 0, 0));
+ renderer_2d.drawCurve(mesh, blt::make_color(0, 1, 0));
+ // auto lines = curve.to_lines(32);
+ // for (const auto& line : lines)
+ // renderer_2d.drawLineInternal(blt::make_color(0, 1,0), line);
renderer_2d.render(data.width, data.height);
}
diff --git a/src/map.cpp b/src/map.cpp
index 5943db9..51f6189 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -19,57 +19,5 @@
namespace td
{
- curve_t::curve_t(const blt::vec2 p0, const blt::vec2 p1, const blt::vec2 p2): m_p0(p0), m_p1(p1), m_p2(p1), m_p3(p2)
- {}
- curve_t::curve_t(const blt::vec2 p0, const blt::vec2 p1, const blt::vec2 p2, const blt::vec2 p3): m_p0(p0), m_p1(p1), m_p2(p2), m_p3(p3)
- {}
-
- blt::vec2 curve_t::get_point(const float t) const
- {
- const auto t_inv = 1.0f - t;
- const auto t_inv_sq = t_inv * t_inv;
- const auto t_inv_cub = t_inv_sq * t_inv;
- const auto t_sq = t * t;
- const auto t_cub = t_sq * t;
- return t_inv_cub * m_p0 + 3 * t_inv_sq * t * m_p1 + 3 * t_inv * t_sq * m_p2 + t_cub * m_p3;
- }
-
- std::vector curve_t::to_lines(const blt::i32 segments) const
- {
- std::vector lines;
- float t = 0;
- const float diff = 1.0f / static_cast(segments);
-
- for (blt::i32 i = 0; i < segments; ++i)
- {
- auto begin = get_point(t);
- t += diff;
- auto end = get_point(t);
-
- lines.emplace_back(begin, end);
- }
-
- return lines;
- }
-
- std::unique_ptr curve_mesh_data_t::to_vertex_array() const
- {}
-
- void curve_mesh_data_t::populate_vertex_array(blt::gfx::vertex_array_t& va) const
- {}
-
- std::vector curve_mesh_data_t::calculate_vertices() const
- {
- std::vector vertices;
-
- return vertices;
- }
-
- curve_mesh_data_t curve_t::to_mesh(const blt::i32 segments) const
- {
- curve_mesh_data_t mesh_data;
- mesh_data.lines = to_lines(segments);
- return mesh_data;
- }
}