diff --git a/assets/base_tile.png b/assets/base_tile.png new file mode 100644 index 0000000..e5b4233 Binary files /dev/null and b/assets/base_tile.png differ diff --git a/assets/base_tile_4.png b/assets/base_tile_4.png new file mode 100644 index 0000000..2eab95c Binary files /dev/null and b/assets/base_tile_4.png differ diff --git a/include/maps.hpp b/include/maps.hpp index b671001..11cfc05 100644 --- a/include/maps.hpp +++ b/include/maps.hpp @@ -6,6 +6,7 @@ extern char test_level_0[MAX_ROWS][MAX_COLS]; extern char test_level_1[MAX_ROWS][MAX_COLS]; +extern char test_level_2[MAX_ROWS][MAX_COLS]; void clear_map(Entity* wall_list[MAX_ROWS][MAX_COLS]); void load_map(Entity* wall_list[MAX_ROWS][MAX_COLS], const char map_data[MAX_ROWS][MAX_COLS]); diff --git a/src/elements.cpp b/src/elements.cpp index 6f4566d..3dcfdc0 100644 --- a/src/elements.cpp +++ b/src/elements.cpp @@ -144,7 +144,7 @@ for(auto [i, j] : ranges::views::cartesian_product(ranges::views::iota(0, MAX_RO auto collision = find_intersection(*wall_list[i][j]); if(collision == CollisionDir::None) continue; if(collision == CollisionDir::Top) { - rect.setPosition({ rect.getPosition().x, wall_list[i][j]->rect.getSize().y + wall_list[i][j]->rect.getPosition().y + rect.getOutlineThickness()}); + rect.setPosition({ rect.getPosition().x, wall_list[i][j]->rect.getSize().y + wall_list[i][j]->rect.getPosition().y}); set_velocity_y(0); return true; } diff --git a/src/main.cpp b/src/main.cpp index a3d2a81..695e6ed 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,11 +1,11 @@ #include #include +#include #include #include #include #include #include -#include #include #include #include @@ -30,7 +30,7 @@ int main() { float max_velocity_y { 15.0f }; float border_size { -1.0f }; float dash_distance { 20.0f }; - sf::Vector2f velocity { 4.0f, 0 }; + sf::Vector2f velocity { 3.0f, 0 }; } player_data; load_map(wall_list, test_level_0); @@ -41,6 +41,14 @@ int main() { player_data.dash_distance, sf::Color::Black, sf::Color::White }; + Entity enemy { + { TILESIZE / 2.0f, TILESIZE / 2.0f }, + { TILESIZE * 5, TILESIZE * 3 }, + { 0, 0 }, + -1.0f, + sf::Color::Red + }; + sf::RenderWindow window(sf::VideoMode({WIDTH, HEIGHT}), "SFML window", sf::Style::Default); window.setFramerateLimit(FPS); @@ -55,6 +63,7 @@ int main() { bool running = true; std::thread player_dash_cooldown([&] { time.update_timers(running, player.timers); } ); + // sf::View view1(sf::FloatRect({000.f, 000.f}, {WIDTH + (TILESIZE * 3), HEIGHT + (TILESIZE * 3)})); while (window.isOpen()) { window.clear(sf::Color::Black); text.setString(std::to_string(player.timers.dash_cooldown)); @@ -77,6 +86,11 @@ int main() { player.timers.level_switch_cooldown = player.timers.level_switch_cooldown_max; } else if(current_level == 1) { + load_map(wall_list, test_level_2); + current_level = 2; + player.timers.level_switch_cooldown = player.timers.level_switch_cooldown_max; + } + else if(current_level == 2) { load_map(wall_list, test_level_0); current_level = 0; player.timers.level_switch_cooldown = player.timers.level_switch_cooldown_max; @@ -108,7 +122,9 @@ int main() { window.draw(wall_list[i][j]->rect); } #endif + // window.setView(view1); window.draw(player.rect); + window.draw(enemy.rect); window.draw(text); window.display(); } diff --git a/src/maps.cpp b/src/maps.cpp index e55cebc..0abe81c 100644 --- a/src/maps.cpp +++ b/src/maps.cpp @@ -90,14 +90,14 @@ char test_level_0[MAX_ROWS][MAX_COLS] = { { '1', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '1' }, { '|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|' }, { '|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|' }, - { '|', '1', '2', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|' }, - { '|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '1', '-', '2', ' ', ' ', ' ', '|' }, { '|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|' }, { '|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|' }, { '|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|' }, { '|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|' }, - { '|', ' ', ' ', ' ', ' ', '1', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '1', ' ', ' ', ' ', ' ', '|' }, - { '2', ' ', ' ', ' ', ' ', '2', '0', ' ', ' ', ' ', ' ', ' ', ' ', '2', ' ', ' ', ' ', ' ', '2' }, + { '|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|' }, + { '|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|' }, + { '|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|' }, + { '2', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '2' }, { '1', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '2' }, }; @@ -116,3 +116,19 @@ char test_level_1[MAX_ROWS][MAX_COLS] = { { '2', ' ', ' ', ' ', ' ', '2', '0', ' ', ' ', ' ', ' ', ' ', ' ', '2', ' ', ' ', ' ', ' ', '2' }, { '1', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '2' }, }; + +char test_level_2[MAX_ROWS][MAX_COLS] = { + { '1', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '2' }, + { '1', '-', '-', '-', '2', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '1' }, + { '|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|' }, + { '|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|' }, + { '|', '1', '-', '-', '-', '-', '2', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|' }, + { '|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '1', '-', '-', '-', '-', '2', ' ', ' ', ' ', '|' }, + { '|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|' }, + { '|', ' ', ' ', ' ', ' ', ' ', ' ', '0', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|' }, + { '|', ' ', ' ', ' ', ' ', '0', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|' }, + { '|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|' }, + { '|', ' ', ' ', ' ', ' ', '1', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '1', ' ', ' ', ' ', ' ', '|' }, + { '2', ' ', ' ', ' ', ' ', '2', '0', ' ', ' ', ' ', ' ', ' ', ' ', '2', ' ', ' ', ' ', ' ', '2' }, + { '1', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '2' }, +};