changes
This commit is contained in:
+30
-29
@@ -1,4 +1,5 @@
|
||||
#include "data.hpp"
|
||||
|
||||
#include <SFML/Audio.hpp>
|
||||
#include <SFML/Graphics.hpp>
|
||||
#include <SFML/Graphics/RectangleShape.hpp>
|
||||
@@ -6,10 +7,9 @@
|
||||
#include <SFML/System/Vector2.hpp>
|
||||
#include <SFML/Window.hpp>
|
||||
#include <SFML/Window/Mouse.hpp>
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <iostream>
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <range/v3/view/cartesian_product.hpp>
|
||||
@@ -24,6 +24,7 @@ namespace rv = std::views;
|
||||
#include "globals.hpp"
|
||||
#include "maps.hpp"
|
||||
#include "scheduler.hpp"
|
||||
#include "data.hpp"
|
||||
|
||||
int main() {
|
||||
Scheduler time;
|
||||
@@ -33,23 +34,25 @@ int main() {
|
||||
Timer("level_switch", 1),
|
||||
};
|
||||
|
||||
map_manager.load_map(levels[1].data);
|
||||
map_manager.load_map(level_data[1].data);
|
||||
|
||||
player_data player_data;
|
||||
Player player { player_data.size, player_data.pos, player_data.velocity,
|
||||
player_data.border_size, GRAVITY, player_data.max_velocity_y,
|
||||
player_data.dash_distance, sf::Color::Black, sf::Color::White };
|
||||
Player player { player_data, GRAVITY };
|
||||
|
||||
sf::RenderWindow window(sf::VideoMode({ WIDTH, HEIGHT }), "engine", sf::Style::Default);
|
||||
window.setFramerateLimit(FPS);
|
||||
|
||||
#ifdef __APPLE__
|
||||
sf::Font font("/Users/andrew/personal/Projects/CPP/engine/assets/pixel.ttf");
|
||||
#else
|
||||
sf::Font font("/home/andrew/personal/Projects/CPP/engine/assets/pixel.ttf");
|
||||
#endif
|
||||
|
||||
sf::Text text(font, "0, 0", 16);
|
||||
text.setPosition({ WIDTH - (TILESIZE * 11.5), HEIGHT - (int)(TILESIZE / 1.5) });
|
||||
|
||||
bool running = true;
|
||||
std::thread scheduler([&] { time.update(running, timers); });
|
||||
|
||||
while (window.isOpen()) {
|
||||
window.clear(sf::Color::Black);
|
||||
text.setString(std::to_string(timers.at(0).get_time()));
|
||||
@@ -71,39 +74,37 @@ int main() {
|
||||
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Enter) && timers.at(1).below_or_zero()) {
|
||||
map_manager.clear_map();
|
||||
if (map_manager.get_current_level() == 1) {
|
||||
map_manager.load_map(levels[1].data);
|
||||
map_manager.load_map(level_data[1].data);
|
||||
map_manager.set_current_level(2);
|
||||
} else if (map_manager.get_current_level() == 2) {
|
||||
map_manager.load_map(levels[2].data);
|
||||
map_manager.load_map(level_data[2].data);
|
||||
map_manager.set_current_level(3);
|
||||
} else if (map_manager.get_current_level() == 3) {
|
||||
map_manager.load_map(levels[3].data);
|
||||
map_manager.load_map(level_data[3].data);
|
||||
map_manager.set_current_level(1);
|
||||
} else {
|
||||
map_manager.load_map(levels[1].data);
|
||||
map_manager.load_map(level_data[1].data);
|
||||
map_manager.set_current_level(1);
|
||||
}
|
||||
timers.at(1).reset();
|
||||
}
|
||||
|
||||
// player.handle_movment(timers.at(time.pull(timers, "dash")));
|
||||
// if (!player.get_horizontal_collision(map_manager.wall_list)) {
|
||||
// std::cout << "\n";
|
||||
// } else { std::cout << "Yes horizontal collision\n"; }
|
||||
//
|
||||
// player.handle_gravity();
|
||||
// if (player.get_velocity().y > ((float)TILESIZE / 2 - GRAVITY)) {
|
||||
// player.set_velocity_y((TILESIZE / 2) - GRAVITY);
|
||||
// }
|
||||
// if (!player.get_vertical_bottom_collision(map_manager.wall_list)) {
|
||||
// std::cout << "\n";
|
||||
// if (!player.get_vertical_top_collision(map_manager.wall_list)) {
|
||||
// std::cout << "\n";
|
||||
// } else {
|
||||
// std::cout << "Yes vertical top collision\n";
|
||||
// }
|
||||
// } else { std::cout << "Yes vertical bottom collision\n"; }
|
||||
//
|
||||
player.handle_movment(timers.at(time.pull(timers, "dash")));
|
||||
player.get_horizontal_collision(map_manager.wall_list);
|
||||
|
||||
player.handle_gravity();
|
||||
if (player.get_velocity().y > ((float)TILESIZE / 2 - GRAVITY)) {
|
||||
player.set_velocity_y((TILESIZE / 2) - GRAVITY);
|
||||
}
|
||||
if (!player.get_vertical_bottom_collision(map_manager.wall_list)) {
|
||||
std::cout << "\n";
|
||||
if (!player.get_vertical_top_collision(map_manager.wall_list)) {
|
||||
std::cout << "\n";
|
||||
} else {
|
||||
std::cout << "Yes vertical top collision\n";
|
||||
}
|
||||
} else { std::cout << "Yes vertical bottom collision\n"; }
|
||||
|
||||
for (auto [i, j] : rv::cartesian_product(rv::iota(0, MAX_ROWS), rv::iota(0, MAX_COLS))) {
|
||||
if (map_manager.wall_list[i][j] == nullptr) {
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user