This commit is contained in:
DarthMooMancer
2025-10-28 20:50:02 -04:00
parent 3740070c48
commit ea738bb4b5
6 changed files with 40 additions and 7 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 543 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 852 B

+1
View File
@@ -6,6 +6,7 @@
extern char test_level_0[MAX_ROWS][MAX_COLS]; extern char test_level_0[MAX_ROWS][MAX_COLS];
extern char test_level_1[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 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]); void load_map(Entity* wall_list[MAX_ROWS][MAX_COLS], const char map_data[MAX_ROWS][MAX_COLS]);
+1 -1
View File
@@ -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]); auto collision = find_intersection(*wall_list[i][j]);
if(collision == CollisionDir::None) continue; if(collision == CollisionDir::None) continue;
if(collision == CollisionDir::Top) { 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); set_velocity_y(0);
return true; return true;
} }
+18 -2
View File
@@ -1,11 +1,11 @@
#include <SFML/Audio.hpp> #include <SFML/Audio.hpp>
#include <SFML/Graphics.hpp> #include <SFML/Graphics.hpp>
#include <SFML/Graphics/Color.hpp>
#include <SFML/System/Vector2.hpp> #include <SFML/System/Vector2.hpp>
#include <SFML/Window.hpp> #include <SFML/Window.hpp>
#include <SFML/System.hpp> #include <SFML/System.hpp>
#include <SFML/Window/Keyboard.hpp> #include <SFML/Window/Keyboard.hpp>
#include <SFML/Window/Mouse.hpp> #include <SFML/Window/Mouse.hpp>
#include <cmath>
#include <cstdlib> #include <cstdlib>
#include <string> #include <string>
#include <thread> #include <thread>
@@ -30,7 +30,7 @@ int main() {
float max_velocity_y { 15.0f }; float max_velocity_y { 15.0f };
float border_size { -1.0f }; float border_size { -1.0f };
float dash_distance { 20.0f }; float dash_distance { 20.0f };
sf::Vector2f velocity { 4.0f, 0 }; sf::Vector2f velocity { 3.0f, 0 };
} player_data; } player_data;
load_map(wall_list, test_level_0); load_map(wall_list, test_level_0);
@@ -41,6 +41,14 @@ int main() {
player_data.dash_distance, sf::Color::Black, sf::Color::White 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); sf::RenderWindow window(sf::VideoMode({WIDTH, HEIGHT}), "SFML window", sf::Style::Default);
window.setFramerateLimit(FPS); window.setFramerateLimit(FPS);
@@ -55,6 +63,7 @@ int main() {
bool running = true; bool running = true;
std::thread player_dash_cooldown([&] { time.update_timers(running, player.timers); } ); 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()) { while (window.isOpen()) {
window.clear(sf::Color::Black); window.clear(sf::Color::Black);
text.setString(std::to_string(player.timers.dash_cooldown)); 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; player.timers.level_switch_cooldown = player.timers.level_switch_cooldown_max;
} }
else if(current_level == 1) { 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); load_map(wall_list, test_level_0);
current_level = 0; current_level = 0;
player.timers.level_switch_cooldown = player.timers.level_switch_cooldown_max; player.timers.level_switch_cooldown = player.timers.level_switch_cooldown_max;
@@ -108,7 +122,9 @@ int main() {
window.draw(wall_list[i][j]->rect); window.draw(wall_list[i][j]->rect);
} }
#endif #endif
// window.setView(view1);
window.draw(player.rect); window.draw(player.rect);
window.draw(enemy.rect);
window.draw(text); window.draw(text);
window.display(); window.display();
} }
+20 -4
View File
@@ -90,14 +90,14 @@ char test_level_0[MAX_ROWS][MAX_COLS] = {
{ '1', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '1' }, { '1', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '1' },
{ '|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|' }, { '|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|' },
{ '|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|' }, { '|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|' },
{ '|', '1', '2', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|' },
{ '|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '1', '-', '2', ' ', ' ', ' ', '|' },
{ '|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|' }, { '|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|' },
{ '|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|' }, { '|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|' },
{ '|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|' }, { '|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|' },
{ '|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|' }, { '|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|' },
{ '|', ' ', ' ', ' ', ' ', '1', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '1', ' ', ' ', ' ', ' ', '|' }, { '|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|' },
{ '2', ' ', ' ', ' ', ' ', '2', '0', ' ', ' ', ' ', ' ', ' ', ' ', '2', ' ', ' ', ' ', ' ', '2' }, { '|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|' },
{ '|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|' },
{ '2', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '2' },
{ '1', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '2' }, { '1', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '2' },
}; };
@@ -116,3 +116,19 @@ char test_level_1[MAX_ROWS][MAX_COLS] = {
{ '2', ' ', ' ', ' ', ' ', '2', '0', ' ', ' ', ' ', ' ', ' ', ' ', '2', ' ', ' ', ' ', ' ', '2' }, { '2', ' ', ' ', ' ', ' ', '2', '0', ' ', ' ', ' ', ' ', ' ', ' ', '2', ' ', ' ', ' ', ' ', '2' },
{ '1', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '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' },
};