fixes
This commit is contained in:
+2
-18
@@ -1,11 +1,7 @@
|
|||||||
#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/Window.hpp>
|
#include <SFML/Window.hpp>
|
||||||
#include <SFML/System.hpp>
|
#include <SFML/System.hpp>
|
||||||
#include <SFML/Window/Keyboard.hpp>
|
|
||||||
#include <SFML/Window/Mouse.hpp>
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
@@ -41,14 +37,6 @@ 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);
|
||||||
|
|
||||||
@@ -63,7 +51,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));
|
||||||
@@ -73,6 +61,7 @@ int main() {
|
|||||||
window.close();
|
window.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Escape)) {
|
if(sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Escape)) {
|
||||||
running = false;
|
running = false;
|
||||||
window.close();
|
window.close();
|
||||||
@@ -97,7 +86,6 @@ int main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle Horizontal movement and collisions
|
|
||||||
player.handle_movment();
|
player.handle_movment();
|
||||||
player.get_horizontal_collision(wall_list);
|
player.get_horizontal_collision(wall_list);
|
||||||
|
|
||||||
@@ -109,22 +97,18 @@ int main() {
|
|||||||
player.get_vertical_top_collision(wall_list);
|
player.get_vertical_top_collision(wall_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Drawing Everything to window
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
for(auto[i, j] : ranges::views::cartesian_product(ranges::views::iota(0, MAX_ROWS), ranges::views::iota(0, MAX_COLS))) {
|
for(auto[i, j] : ranges::views::cartesian_product(ranges::views::iota(0, MAX_ROWS), ranges::views::iota(0, MAX_COLS))) {
|
||||||
if(wall_list[i][j] == nullptr) continue;
|
if(wall_list[i][j] == nullptr) continue;
|
||||||
window.draw(wall_list[i][j]->rect);
|
window.draw(wall_list[i][j]->rect);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|
||||||
for(auto[i, j] : std::views::cartesian_product(std::views::iota(0, MAX_ROWS), std::views::iota(0, MAX_COLS))) {
|
for(auto[i, j] : std::views::cartesian_product(std::views::iota(0, MAX_ROWS), std::views::iota(0, MAX_COLS))) {
|
||||||
if(wall_list[i][j] == nullptr) continue;
|
if(wall_list[i][j] == nullptr) continue;
|
||||||
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();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,11 @@ void clear_map(Entity* wall_list[MAX_ROWS][MAX_COLS]) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void create_map() {
|
||||||
|
char output[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]) {
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
for(auto[i, j] : ranges::views::cartesian_product(ranges::views::iota(0, MAX_ROWS), ranges::views::iota(0, MAX_COLS))) {
|
for(auto[i, j] : ranges::views::cartesian_product(ranges::views::iota(0, MAX_ROWS), ranges::views::iota(0, MAX_COLS))) {
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
// timer for player cooldown
|
// timer for player cooldown
|
||||||
//
|
|
||||||
#include "scheduler.hpp"
|
#include "scheduler.hpp"
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|||||||
Reference in New Issue
Block a user