From ea738bb4b560b3d1cf22b6c229bb434e297f74de Mon Sep 17 00:00:00 2001 From: DarthMooMancer <107283522+DarthMooMancer@users.noreply.github.com> Date: Tue, 28 Oct 2025 20:50:02 -0400 Subject: [PATCH] fixes --- assets/base_tile.png | Bin 0 -> 543 bytes assets/base_tile_4.png | Bin 0 -> 852 bytes include/maps.hpp | 1 + src/elements.cpp | 2 +- src/main.cpp | 20 ++++++++++++++++++-- src/maps.cpp | 24 ++++++++++++++++++++---- 6 files changed, 40 insertions(+), 7 deletions(-) create mode 100644 assets/base_tile.png create mode 100644 assets/base_tile_4.png diff --git a/assets/base_tile.png b/assets/base_tile.png new file mode 100644 index 0000000000000000000000000000000000000000..e5b4233f4315945cfe5d6b70c2b79b86d0f665cd GIT binary patch literal 543 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%C&rs6b?Si}mUKs7M+SzC z{oH>NSwSk3J%W507^>757#dm_7=8hT8eT9klo~KFyh>nTu$sZZAYL$MSD+10f-TA0 z-Gzab!JVNrMN;c0P=vFf)mdV#gNH&$3$r~(OrP|LE~Bmv(U@?C$0w6nRfOhrs3eCSFx}E2;nR^|7i-3# zaB5E1>B7hN=a#Z&ZP@P@JMp`gXPU@|ZO`wfuj2Q}?VLP?Gv!E#_yzXPI6FUvEy1LGy^CHZ(53hdTwG@bObV*=AO3;Am& z_?8L@>RuEQNO@y2?Y7INMIxL53Co*1GqO1>*uPoLny4ff$u92~t<=^aBBlH3<))MI d>5j>NMeR48jChf?(-0T~44$rjF6*2UngBiR#drV! literal 0 HcmV?d00001 diff --git a/assets/base_tile_4.png b/assets/base_tile_4.png new file mode 100644 index 0000000000000000000000000000000000000000..2eab95cc904334052671f985bd8712bc1f82c53f GIT binary patch literal 852 zcmeAS@N?(olHy`uVBq!ia0vp^2_VeD1|%QND7OGojKx9jPK-BC>eK@{Ea{HEjtmSN z`?>!lvI6-E$sR$z3=CCj3=9n|3=F@3LJcn%7)lKo7+xhXFj&oCU=S~uvn$XBD8ZKG z?e4?NMQuIw+lq*=_RqM~oQGcYjC z@N{tuskrrarmdf}qe#Pd*KGk+eiNh>j<9Mtc^>4vbV+&X1E!97ZB4=fJ5*RhcX9k= zvuo6E$jJ-`(Nb!ef8H=|I054 z`50?ozsp9DNuopFvc<=ybB?Vz5}e6UWTvA9I{f%sKL0!s(fo{d5ka^q-b4 z6D+&WE4C=yGsBMWn;qJIf&as&=l64-+S}h@|1Ztm%U{&-;q`OYN4iXBR9lw)&|q99 zrPTIg1>-UyrDYXg8Ge6V6*VW;U+Kt-A8(hf@~eL$now9~E3vReK+|u}FS!qYzu#Z{ zy&=X)Mz?PF$};)&+o})L?OpZlb?8RxmZK}fc>_KvJy)&YE%~oFFW)iw^MN8Wi_U!h zThG3GeF{xG@afgMJieq}jg3w#V$5}aE;LS9So`X?(~mQpZ`GZA_gq??zR7h><*V5B z%4Y=>^UddO5?wz}BRt@K-i11?UF(#lzdmW&a!cu{g3TAMpr5U00$R!@%rHLm^9Vm{ z#=pBB4FNy17`Hh8&?{OM?%NbBuiN0?;oP$D;9KJ#p-d_kA3eo3-o3r}%{@8QSr)C= z-RC#%`du+q;?rVVMn(UY_ckwhEz8bt7hlt-uyKhx{{yK z3w8?|L1xCFE^}T3v80@I3El@k%aRrCUI~1YyjB}DJL&c$cmLYYarQN-8u$NjUbrE@ z?}*194__q*kB)N;lDsz;F}3IvEuHg2iRs54-JL8a0&4^r_pDP}?3yLU$mT4fweJMO vTtz8HFClx*Y2oExKmA#Dj0K)*9Nzt5S1|5R<2#mj86@cG>gTe~DWM4f9CuR} literal 0 HcmV?d00001 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' }, +};