fixes and optimizations
This commit is contained in:
+5
-1
@@ -13,7 +13,7 @@ TabWidth: 8
|
|||||||
IndentWidth: 8
|
IndentWidth: 8
|
||||||
ContinuationIndentWidth: 8
|
ContinuationIndentWidth: 8
|
||||||
AlignAfterOpenBracket: Align
|
AlignAfterOpenBracket: Align
|
||||||
PointerAlignment: Right
|
PointerAlignment: Left
|
||||||
|
|
||||||
# Braces
|
# Braces
|
||||||
BreakBeforeBraces: Custom
|
BreakBeforeBraces: Custom
|
||||||
@@ -36,6 +36,10 @@ SpaceBeforeParensOptions:
|
|||||||
AfterControlStatements: true
|
AfterControlStatements: true
|
||||||
SpaceBeforeRangeBasedForLoopColon: true
|
SpaceBeforeRangeBasedForLoopColon: true
|
||||||
AllowShortFunctionsOnASingleLine: true
|
AllowShortFunctionsOnASingleLine: true
|
||||||
|
AllowShortIfStatementsOnASingleLine: true
|
||||||
|
AllowShortLoopsOnASingleLine: true
|
||||||
|
RemoveEmptyLinesInUnwrappedLines: true
|
||||||
|
SeparateDefinitionBlocks: Always
|
||||||
|
|
||||||
# Preprocessor
|
# Preprocessor
|
||||||
IndentPPDirectives: AfterHash
|
IndentPPDirectives: AfterHash
|
||||||
|
|||||||
@@ -1,22 +0,0 @@
|
|||||||
#ifndef DATA_HPP
|
|
||||||
#define DATA_HPP
|
|
||||||
|
|
||||||
#include "globals.hpp"
|
|
||||||
#include <SFML/Graphics/Color.hpp>
|
|
||||||
#include <SFML/System/Vector2.hpp>
|
|
||||||
|
|
||||||
struct Map {
|
|
||||||
const char map[MAX_ROWS][MAX_COLS];
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Player {
|
|
||||||
sf::Vector2<float> size { TILESIZE / 2.0f, TILESIZE / 2.0f };
|
|
||||||
sf::Vector2<float> pos { TILESIZE, TILESIZE };
|
|
||||||
float max_velocity_y { 15.0f };
|
|
||||||
float border_size { -1.0f };
|
|
||||||
|
|
||||||
float dash_distance { 20.0f };
|
|
||||||
sf::Vector2f velocity { 3.0f, 0 };
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
+14
-8
@@ -1,16 +1,19 @@
|
|||||||
#ifndef PLAYER_HPP
|
#ifndef PLAYER_HPP
|
||||||
#define PLAYER_HPP
|
#define PLAYER_HPP
|
||||||
|
|
||||||
|
#include "globals.hpp"
|
||||||
|
#include "scheduler.hpp"
|
||||||
|
|
||||||
#include <SFML/Graphics/Color.hpp>
|
#include <SFML/Graphics/Color.hpp>
|
||||||
#include <SFML/Graphics/RectangleShape.hpp>
|
#include <SFML/Graphics/RectangleShape.hpp>
|
||||||
#include <SFML/System/Vector2.hpp>
|
#include <SFML/System/Vector2.hpp>
|
||||||
#include "scheduler.hpp"
|
|
||||||
#include "globals.hpp"
|
|
||||||
|
|
||||||
enum class CollisionDir { None, Left, Right, Top, Bottom };
|
enum class CollisionDir { None, Left, Right, Top, Bottom };
|
||||||
|
|
||||||
class Entity {
|
class Entity {
|
||||||
public:
|
public:
|
||||||
Entity(sf::Vector2<float> size, sf::Vector2<float> pos, sf::Vector2f velocity, float border_thickness, sf::Color inside_color = sf::Color::Black, sf::Color border_color = sf::Color::White);
|
Entity(sf::Vector2<float> size, sf::Vector2<float> pos, sf::Vector2f velocity, float border_thickness,
|
||||||
|
sf::Color inside_color = sf::Color::Black, sf::Color border_color = sf::Color::White);
|
||||||
CollisionDir find_intersection(Entity& entity);
|
CollisionDir find_intersection(Entity& entity);
|
||||||
void set_velocity(sf::Vector2f velocity);
|
void set_velocity(sf::Vector2f velocity);
|
||||||
void set_velocity_x(int velocity);
|
void set_velocity_x(int velocity);
|
||||||
@@ -27,7 +30,9 @@ protected:
|
|||||||
|
|
||||||
class Player : public Entity {
|
class Player : public Entity {
|
||||||
public:
|
public:
|
||||||
Player(sf::Vector2<float> size, sf::Vector2<float> pos, sf::Vector2f velocity, float border_thickness, float gravity, float max_acceleration, float dash_distance, sf::Color inside_color, sf::Color border_color);
|
Player(sf::Vector2<float> size, sf::Vector2<float> pos, sf::Vector2f velocity, float border_thickness,
|
||||||
|
float gravity, float max_acceleration, float dash_distance, sf::Color inside_color,
|
||||||
|
sf::Color border_color);
|
||||||
float m_acceleration;
|
float m_acceleration;
|
||||||
float m_jump_strength;
|
float m_jump_strength;
|
||||||
float m_dash_distance;
|
float m_dash_distance;
|
||||||
@@ -39,11 +44,12 @@ public:
|
|||||||
bool get_jumping();
|
bool get_jumping();
|
||||||
void horizontal_no_out_of_bounds(Entity& base);
|
void horizontal_no_out_of_bounds(Entity& base);
|
||||||
void vertical_no_out_of_bounds(Entity& base);
|
void vertical_no_out_of_bounds(Entity& base);
|
||||||
bool get_horizontal_collision(Entity *wall_list[MAX_ROWS][MAX_COLS]);
|
bool get_horizontal_collision(std::array<std::array<Entity*, MAX_COLS>, MAX_ROWS>);
|
||||||
bool get_vertical_top_collision(Entity *wall_list[MAX_ROWS][MAX_COLS]);
|
bool get_vertical_top_collision(std::array<std::array<Entity*, MAX_COLS>, MAX_ROWS>);
|
||||||
bool get_vertical_bottom_collision(Entity *wall_list[MAX_ROWS][MAX_COLS]);
|
bool get_vertical_bottom_collision(std::array<std::array<Entity*, MAX_COLS>, MAX_ROWS>);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool get_vertical_bottom_collision_by_offset(Entity *wall_list[MAX_ROWS][MAX_COLS]);
|
bool get_vertical_bottom_collision_by_offset(std::array<std::array<Entity*, MAX_COLS>, MAX_ROWS>);
|
||||||
sf::Vector2f _min_velocity;
|
sf::Vector2f _min_velocity;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -1,10 +1,10 @@
|
|||||||
#ifndef GLOBALS_HPP
|
#ifndef GLOBALS_HPP
|
||||||
#define GLOBALS_HPP
|
#define GLOBALS_HPP
|
||||||
#define TILESIZE 32
|
#define TILESIZE 32
|
||||||
#define WIDTH 608
|
#define MAX_COLS 8 // 19 cols
|
||||||
#define HEIGHT 416
|
#define MAX_ROWS 8 // 13 rows
|
||||||
|
#define WIDTH TILESIZE * MAX_COLS
|
||||||
|
#define HEIGHT TILESIZE * MAX_ROWS
|
||||||
#define FPS 60
|
#define FPS 60
|
||||||
#define GRAVITY 1
|
#define GRAVITY 1
|
||||||
#define MAX_COLS WIDTH / TILESIZE // 19 cols
|
|
||||||
#define MAX_ROWS HEIGHT / TILESIZE // 13 rows
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+6
-12
@@ -1,10 +1,11 @@
|
|||||||
#ifndef MAPS_HPP
|
#ifndef MAPS_HPP
|
||||||
#define MAPS_HPP
|
#define MAPS_HPP
|
||||||
|
|
||||||
|
#include "elements.hpp"
|
||||||
|
#include "globals.hpp"
|
||||||
|
|
||||||
#include <SFML/Graphics/RenderWindow.hpp>
|
#include <SFML/Graphics/RenderWindow.hpp>
|
||||||
#include <array>
|
#include <array>
|
||||||
#include "globals.hpp"
|
|
||||||
#include "elements.hpp"
|
|
||||||
|
|
||||||
struct Level {
|
struct Level {
|
||||||
char data[MAX_ROWS][MAX_COLS];
|
char data[MAX_ROWS][MAX_COLS];
|
||||||
@@ -12,15 +13,8 @@ struct Level {
|
|||||||
};
|
};
|
||||||
|
|
||||||
extern Level levels[];
|
extern Level levels[];
|
||||||
|
extern const char map[MAX_ROWS][MAX_COLS];
|
||||||
|
|
||||||
void clear_map(std::array<std::array<Entity*, MAX_COLS>, MAX_ROWS> wall_list);
|
void clear_map(std::array<std::array<Entity*, MAX_COLS>, MAX_ROWS>& wall_list);
|
||||||
void load_map(std::array<std::array<Entity*, MAX_COLS>, MAX_ROWS> wall_list, const std::array<std::array<char, MAX_COLS>, MAX_ROWS> map_data);
|
void load_map(std::array<std::array<Entity*, MAX_COLS>, MAX_ROWS>& wall_list, const char map_data[MAX_ROWS][MAX_COLS]);
|
||||||
std::array<std::array<char, MAX_COLS>, MAX_ROWS> create_map(sf::RenderWindow &window,
|
|
||||||
sf::Vector2i &local_position,
|
|
||||||
sf::Vector2i &start_mouse_pos,
|
|
||||||
sf::Vector2i &end_mouse_pos,
|
|
||||||
bool &dragging,
|
|
||||||
bool &prev_dragging,
|
|
||||||
std::array<std::array<Entity*, MAX_COLS>, MAX_ROWS> wall_list);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
struct Times {
|
struct Times {
|
||||||
float dash_cooldown { 0 };
|
float dash_cooldown { 0 };
|
||||||
float dash_cooldown_max { 5 };
|
float dash_cooldown_max { .5 };
|
||||||
float level_switch_cooldown { 0 };
|
float level_switch_cooldown { 0 };
|
||||||
float level_switch_cooldown_max { 1 };
|
float level_switch_cooldown_max { 1 };
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
#include "data.hpp"
|
|
||||||
+14
-36
@@ -9,8 +9,10 @@
|
|||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
#include <range/v3/view/cartesian_product.hpp>
|
#include <range/v3/view/cartesian_product.hpp>
|
||||||
#include <range/v3/view/iota.hpp>
|
#include <range/v3/view/iota.hpp>
|
||||||
|
namespace rv = ranges::views;
|
||||||
#else
|
#else
|
||||||
#include <ranges>
|
#include <ranges>
|
||||||
|
namespace rv = std::views;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Entity::Entity(sf::Vector2<float> size, sf::Vector2<float> pos, sf::Vector2f velocity, float border_thickness,
|
Entity::Entity(sf::Vector2<float> size, sf::Vector2<float> pos, sf::Vector2f velocity, float border_thickness,
|
||||||
@@ -114,19 +116,11 @@ void Player::vertical_no_out_of_bounds(Entity &base) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Player::get_horizontal_collision(Entity *wall_list[MAX_ROWS][MAX_COLS]) {
|
bool Player::get_horizontal_collision(std::array<std::array<Entity*, MAX_COLS>, MAX_ROWS> wall_list) {
|
||||||
#ifdef __APPLE__
|
for (auto [i, j] : rv::cartesian_product(rv::iota(0, MAX_ROWS), rv::iota(0, MAX_COLS))) {
|
||||||
for (auto [i, j] :
|
if (wall_list[i][j] == nullptr) continue;
|
||||||
ranges::views::cartesian_product(ranges::views::iota(0, MAX_ROWS), ranges::views::iota(0, MAX_COLS))) {
|
|
||||||
#else
|
|
||||||
for (auto [i, j] :
|
|
||||||
std::views::cartesian_product(std::views::iota(0, MAX_ROWS), std::views::iota(0, MAX_COLS))) {
|
|
||||||
#endif
|
|
||||||
if (wall_list[i][j] == nullptr)
|
|
||||||
continue;
|
|
||||||
auto collision = wall_list[i][j]->find_intersection(*this);
|
auto collision = wall_list[i][j]->find_intersection(*this);
|
||||||
if (collision == CollisionDir::None)
|
if (collision == CollisionDir::None) continue;
|
||||||
continue;
|
|
||||||
if (collision == CollisionDir::Left) {
|
if (collision == CollisionDir::Left) {
|
||||||
rect.setPosition(
|
rect.setPosition(
|
||||||
{ wall_list[i][j]->rect.getPosition().x - rect.getSize().x, rect.getPosition().y });
|
{ wall_list[i][j]->rect.getPosition().x - rect.getSize().x, rect.getPosition().y });
|
||||||
@@ -141,19 +135,11 @@ bool Player::get_horizontal_collision(Entity *wall_list[MAX_ROWS][MAX_COLS]) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Player::get_vertical_top_collision(Entity *wall_list[MAX_ROWS][MAX_COLS]) {
|
bool Player::get_vertical_top_collision(std::array<std::array<Entity*, MAX_COLS>, MAX_ROWS> wall_list) {
|
||||||
#ifdef __APPLE__
|
for (auto [i, j] : rv::cartesian_product(rv::iota(0, MAX_ROWS), rv::iota(0, MAX_COLS))) {
|
||||||
for (auto [i, j] :
|
if (wall_list[i][j] == nullptr) continue;
|
||||||
ranges::views::cartesian_product(ranges::views::iota(0, MAX_ROWS), ranges::views::iota(0, MAX_COLS))) {
|
|
||||||
#else
|
|
||||||
for (auto [i, j] :
|
|
||||||
std::views::cartesian_product(std::views::iota(0, MAX_ROWS), std::views::iota(0, MAX_COLS))) {
|
|
||||||
#endif
|
|
||||||
if (wall_list[i][j] == nullptr)
|
|
||||||
continue;
|
|
||||||
auto collision = find_intersection(*wall_list[i][j]);
|
auto collision = find_intersection(*wall_list[i][j]);
|
||||||
if (collision == CollisionDir::None)
|
if (collision == CollisionDir::None) continue;
|
||||||
continue;
|
|
||||||
if (collision == CollisionDir::Top) {
|
if (collision == CollisionDir::Top) {
|
||||||
rect.setPosition({ rect.getPosition().x,
|
rect.setPosition({ rect.getPosition().x,
|
||||||
wall_list[i][j]->rect.getSize().y + wall_list[i][j]->rect.getPosition().y });
|
wall_list[i][j]->rect.getSize().y + wall_list[i][j]->rect.getPosition().y });
|
||||||
@@ -164,19 +150,11 @@ bool Player::get_vertical_top_collision(Entity *wall_list[MAX_ROWS][MAX_COLS]) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Player::get_vertical_bottom_collision(Entity *wall_list[MAX_ROWS][MAX_COLS]) {
|
bool Player::get_vertical_bottom_collision(std::array<std::array<Entity*, MAX_COLS>, MAX_ROWS> wall_list) {
|
||||||
#ifdef __APPLE__
|
for (auto [i, j] : rv::cartesian_product(rv::iota(0, MAX_ROWS), rv::iota(0, MAX_COLS))) {
|
||||||
for (auto [i, j] :
|
if (wall_list[i][j] == nullptr) continue;
|
||||||
ranges::views::cartesian_product(ranges::views::iota(0, MAX_ROWS), ranges::views::iota(0, MAX_COLS))) {
|
|
||||||
#else
|
|
||||||
for (auto [i, j] :
|
|
||||||
std::views::cartesian_product(std::views::iota(0, MAX_ROWS), std::views::iota(0, MAX_COLS))) {
|
|
||||||
#endif
|
|
||||||
if (wall_list[i][j] == nullptr)
|
|
||||||
continue;
|
|
||||||
auto collision = find_intersection(*wall_list[i][j]);
|
auto collision = find_intersection(*wall_list[i][j]);
|
||||||
if (collision == CollisionDir::None)
|
if (collision == CollisionDir::None) continue;
|
||||||
continue;
|
|
||||||
if (collision == CollisionDir::Bottom && get_velocity().y > 0) {
|
if (collision == CollisionDir::Bottom && get_velocity().y > 0) {
|
||||||
rect.setPosition(
|
rect.setPosition(
|
||||||
{ rect.getPosition().x, wall_list[i][j]->rect.getPosition().y - rect.getSize().y });
|
{ rect.getPosition().x, wall_list[i][j]->rect.getPosition().y - rect.getSize().y });
|
||||||
|
|||||||
+13
-30
@@ -5,17 +5,17 @@
|
|||||||
#include <SFML/System/Vector2.hpp>
|
#include <SFML/System/Vector2.hpp>
|
||||||
#include <SFML/Window.hpp>
|
#include <SFML/Window.hpp>
|
||||||
#include <SFML/Window/Mouse.hpp>
|
#include <SFML/Window/Mouse.hpp>
|
||||||
#include <cmath>
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
#include <range/v3/view/cartesian_product.hpp>
|
#include <range/v3/view/cartesian_product.hpp>
|
||||||
#include <range/v3/view/iota.hpp>
|
#include <range/v3/view/iota.hpp>
|
||||||
|
namespace rv = ranges::views;
|
||||||
#else
|
#else
|
||||||
#include <ranges>
|
#include <ranges>
|
||||||
|
namespace rv = std::views;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "elements.hpp"
|
#include "elements.hpp"
|
||||||
@@ -25,15 +25,12 @@
|
|||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
Timer time;
|
Timer time;
|
||||||
Entity *wall_list[MAX_ROWS][MAX_COLS] = {};
|
std::array<std::array<Entity*, MAX_COLS>, MAX_ROWS> wall_list = {};
|
||||||
sf::Vector2i local_position;
|
|
||||||
sf::Vector2i start_mouse_pos;
|
|
||||||
sf::Vector2i end_mouse_pos;
|
|
||||||
bool dragging = false;
|
bool dragging = false;
|
||||||
bool prev_dragging = false;
|
bool prev_dragging = false;
|
||||||
int current_level = 0;
|
int current_level = 0;
|
||||||
|
|
||||||
load_map(wall_list, );
|
load_map(wall_list, levels[3].data);
|
||||||
|
|
||||||
player_data player_data;
|
player_data player_data;
|
||||||
Player player { player_data.size, player_data.pos, player_data.velocity,
|
Player player { player_data.size, player_data.pos, player_data.velocity,
|
||||||
@@ -43,11 +40,7 @@ int main() {
|
|||||||
sf::RenderWindow window(sf::VideoMode({ WIDTH, HEIGHT }), "engine", sf::Style::Default);
|
sf::RenderWindow window(sf::VideoMode({ WIDTH, HEIGHT }), "engine", sf::Style::Default);
|
||||||
window.setFramerateLimit(FPS);
|
window.setFramerateLimit(FPS);
|
||||||
|
|
||||||
#ifdef __APPLE__
|
|
||||||
sf::Font font("/Users/andrew/personal/Projects/CPP/engine/assets/pixel.ttf");
|
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);
|
sf::Text text(font, "0, 0", 16);
|
||||||
text.setPosition({ WIDTH - (TILESIZE * 11.5), HEIGHT - (int)(TILESIZE / 1.5) });
|
text.setPosition({ WIDTH - (TILESIZE * 11.5), HEIGHT - (int)(TILESIZE / 1.5) });
|
||||||
@@ -55,10 +48,8 @@ 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); });
|
||||||
while (window.isOpen()) {
|
while (window.isOpen()) {
|
||||||
local_position = sf::Mouse::getPosition(window);
|
|
||||||
window.clear(sf::Color::Black);
|
window.clear(sf::Color::Black);
|
||||||
text.setString(std::to_string((int)std::floor(local_position.x / 32)) + ", " +
|
text.setString("Test");
|
||||||
std::to_string((int)std::floor(local_position.y / 32)));
|
|
||||||
while (const std::optional event = window.pollEvent()) {
|
while (const std::optional event = window.pollEvent()) {
|
||||||
if (event->is<sf::Event::Closed>()) {
|
if (event->is<sf::Event::Closed>()) {
|
||||||
running = false;
|
running = false;
|
||||||
@@ -76,20 +67,19 @@ int main() {
|
|||||||
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::A)) {
|
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::A)) {
|
||||||
dragging = false;
|
dragging = false;
|
||||||
}
|
}
|
||||||
create_map(window, local_position, start_mouse_pos, end_mouse_pos, dragging, prev_dragging, wall_list);
|
|
||||||
|
|
||||||
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Enter) && player.timers.level_switch_cooldown <= 0) {
|
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Enter) && player.timers.level_switch_cooldown <= 0) {
|
||||||
clear_map(wall_list);
|
clear_map(wall_list);
|
||||||
if (current_level == 0) {
|
if (current_level == 0) {
|
||||||
load_map(wall_list, test_level_1);
|
load_map(wall_list, levels[1].data);
|
||||||
current_level = 1;
|
current_level = 1;
|
||||||
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);
|
load_map(wall_list, levels[2].data);
|
||||||
current_level = 2;
|
current_level = 2;
|
||||||
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 == 2) {
|
} else if (current_level == 2) {
|
||||||
load_map(wall_list, test_level_0);
|
load_map(wall_list, levels[3].data);
|
||||||
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;
|
||||||
}
|
}
|
||||||
@@ -117,25 +107,18 @@ int main() {
|
|||||||
std::cout << "Yes vertical bottom collision\n";
|
std::cout << "Yes vertical bottom collision\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __APPLE__
|
for (auto [i, j] : rv::cartesian_product(rv::iota(0, MAX_ROWS), rv::iota(0, MAX_COLS))) {
|
||||||
for (auto [i, j] : ranges::views::cartesian_product(ranges::views::iota(0, MAX_ROWS),
|
if (wall_list[i][j] == nullptr) {
|
||||||
ranges::views::iota(0, MAX_COLS))) {
|
|
||||||
if (wall_list[i][j] == nullptr)
|
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
window.draw(wall_list[i][j]->rect);
|
window.draw(wall_list[i][j]->rect);
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
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;
|
|
||||||
window.draw(wall_list[i][j]->rect);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
window.draw(player.rect);
|
window.draw(player.rect);
|
||||||
window.draw(text);
|
window.draw(text);
|
||||||
window.display();
|
window.display();
|
||||||
}
|
}
|
||||||
|
|
||||||
clear_map(wall_list);
|
clear_map(wall_list);
|
||||||
player_dash_cooldown.join();
|
player_dash_cooldown.join();
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
+79
-155
@@ -14,7 +14,7 @@ namespace rv = ranges::views;
|
|||||||
namespace rv = std::views;
|
namespace rv = std::views;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void clear_map(std::array<std::array<Entity *, MAX_COLS>, MAX_ROWS> wall_list) {
|
void clear_map(std::array<std::array<Entity*, MAX_COLS>, MAX_ROWS>& wall_list) {
|
||||||
for (auto [i, j] : rv::cartesian_product(rv::iota(0, MAX_ROWS), rv::iota(0, MAX_COLS))) {
|
for (auto [i, j] : rv::cartesian_product(rv::iota(0, MAX_ROWS), rv::iota(0, MAX_COLS))) {
|
||||||
delete wall_list[i][j];
|
delete wall_list[i][j];
|
||||||
wall_list[i][j] = nullptr;
|
wall_list[i][j] = nullptr;
|
||||||
@@ -23,8 +23,7 @@ void clear_map(std::array<std::array<Entity *, MAX_COLS>, MAX_ROWS> wall_list) {
|
|||||||
|
|
||||||
bool is_tiles_clear_x(std::array<std::array<char, MAX_COLS>, MAX_ROWS> draw_list, int y_level, int start_x, int end_x) {
|
bool is_tiles_clear_x(std::array<std::array<char, MAX_COLS>, MAX_ROWS> draw_list, int y_level, int start_x, int end_x) {
|
||||||
for (int i : rv::iota(start_x, end_x)) {
|
for (int i : rv::iota(start_x, end_x)) {
|
||||||
if (draw_list[i][y_level] == ' ')
|
if (draw_list[i][y_level] == ' ') continue;
|
||||||
continue;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -32,105 +31,15 @@ bool is_tiles_clear_x(std::array<std::array<char, MAX_COLS>, MAX_ROWS> draw_list
|
|||||||
|
|
||||||
bool is_tiles_clear_y(std::array<std::array<char, MAX_COLS>, MAX_ROWS> draw_list, int x_level, int start_y, int end_y) {
|
bool is_tiles_clear_y(std::array<std::array<char, MAX_COLS>, MAX_ROWS> draw_list, int x_level, int start_y, int end_y) {
|
||||||
for (int i : rv::iota(start_y, end_y)) {
|
for (int i : rv::iota(start_y, end_y)) {
|
||||||
if (draw_list[i][x_level] == ' ')
|
if (draw_list[i][x_level] == ' ') continue;
|
||||||
continue;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::array<std::array<char, MAX_COLS>, MAX_ROWS> create_map(sf::RenderWindow &window, sf::Vector2i &local_position,
|
void load_map(std::array<std::array<Entity*, MAX_COLS>, MAX_ROWS>& wall_list, const char map_data[MAX_ROWS][MAX_COLS]) {
|
||||||
sf::Vector2i &start_mouse_pos, sf::Vector2i &end_mouse_pos,
|
|
||||||
bool &dragging, bool &prev_dragging,
|
|
||||||
Entity *wall_list[MAX_ROWS][MAX_COLS]) {
|
|
||||||
std::array<std::array<char, MAX_COLS>, MAX_ROWS> draw_list {};
|
|
||||||
|
|
||||||
for (auto &row : draw_list) {
|
|
||||||
row.fill(' ');
|
|
||||||
}
|
|
||||||
static bool vertical = false;
|
|
||||||
if (local_position.x > 0 && local_position.x < WIDTH && local_position.y > 0 && local_position.y < HEIGHT) {
|
|
||||||
if (sf::Mouse::isButtonPressed(sf::Mouse::Button::Left) && !dragging) {
|
|
||||||
dragging = true;
|
|
||||||
start_mouse_pos = local_position;
|
|
||||||
}
|
|
||||||
if (sf::Mouse::isButtonPressed(sf::Mouse::Button::Left) && dragging) {
|
|
||||||
prev_dragging = true;
|
|
||||||
end_mouse_pos = local_position;
|
|
||||||
sf::RectangleShape rect;
|
|
||||||
if (end_mouse_pos.x - start_mouse_pos.x > end_mouse_pos.y - start_mouse_pos.y) {
|
|
||||||
rect.setSize({ (float)(end_mouse_pos.x - start_mouse_pos.x), 1.0f });
|
|
||||||
rect.setPosition({ (float)start_mouse_pos.x,
|
|
||||||
(float)(std::floor(start_mouse_pos.y / 32) * TILESIZE +
|
|
||||||
((float)TILESIZE / 2)) });
|
|
||||||
vertical = false;
|
|
||||||
} else {
|
|
||||||
rect.setSize({
|
|
||||||
1.0f,
|
|
||||||
(float)(end_mouse_pos.y - start_mouse_pos.y),
|
|
||||||
});
|
|
||||||
rect.setPosition({ (float)(std::floor(start_mouse_pos.x / 32) * TILESIZE +
|
|
||||||
((float)TILESIZE / 2)),
|
|
||||||
(float)start_mouse_pos.y });
|
|
||||||
vertical = true;
|
|
||||||
}
|
|
||||||
window.draw(rect);
|
|
||||||
}
|
|
||||||
if (!sf::Mouse::isButtonPressed(sf::Mouse::Button::Left) && dragging && prev_dragging) {
|
|
||||||
sf::Vector2i start_integers = { (int)std::floor(start_mouse_pos.x / 32),
|
|
||||||
(int)std::floor(start_mouse_pos.y / 32) };
|
|
||||||
sf::Vector2i end_integers = { (int)std::floor(end_mouse_pos.x / 32),
|
|
||||||
(int)std::floor(end_mouse_pos.y / 32) };
|
|
||||||
|
|
||||||
if (!vertical) {
|
|
||||||
if (wall_list[start_integers.y][start_integers.x] == nullptr) {
|
|
||||||
wall_list[start_integers.y][start_integers.x] =
|
|
||||||
new Entity { { float(end_integers.x - start_integers.x + 1) * TILESIZE,
|
|
||||||
TILESIZE },
|
|
||||||
{ (float)(start_integers.x * TILESIZE),
|
|
||||||
(float)(start_integers.y * TILESIZE) },
|
|
||||||
{ 0, 0 },
|
|
||||||
-2.0f,
|
|
||||||
sf::Color::Black };
|
|
||||||
draw_list[start_integers.y][start_integers.x] = '1';
|
|
||||||
draw_list[end_integers.y][end_integers.x] = '2';
|
|
||||||
for (int i : rv::iota(start_integers.x, end_integers.x)) {
|
|
||||||
draw_list[start_integers.y][i] = '-';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (vertical) {
|
|
||||||
if (wall_list[start_integers.y][start_integers.x] == nullptr) {
|
|
||||||
// if(is_tiles_clear_y(draw_list, start_integers.x, start_integers.y,
|
|
||||||
// end_integers.y)) {
|
|
||||||
wall_list[start_integers.y][start_integers.x] = new Entity {
|
|
||||||
{ TILESIZE, float(end_integers.y - start_integers.y + 1) * TILESIZE },
|
|
||||||
{ (float)(start_integers.x * TILESIZE),
|
|
||||||
(float)(start_integers.y * TILESIZE) },
|
|
||||||
{ 0, 0 },
|
|
||||||
-2.0f,
|
|
||||||
sf::Color::Black
|
|
||||||
};
|
|
||||||
draw_list[start_integers.y][start_integers.x] = '1';
|
|
||||||
draw_list[end_integers.y][end_integers.x] = '2';
|
|
||||||
for (int i : rv::iota(start_integers.y, end_integers.y)) {
|
|
||||||
draw_list[i][start_integers.x] = '|';
|
|
||||||
}
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
// }
|
|
||||||
prev_dragging = false;
|
|
||||||
dragging = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return draw_list;
|
|
||||||
}
|
|
||||||
|
|
||||||
void load_map(std::array<std::array<Entity *, MAX_COLS>, MAX_ROWS> wall_list,
|
|
||||||
const std::array<std::array<char, MAX_COLS>, MAX_ROWS> map_data) {
|
|
||||||
for (auto [i, j] : rv::cartesian_product(rv::iota(0, MAX_ROWS), rv::iota(0, MAX_COLS))) {
|
for (auto [i, j] : rv::cartesian_product(rv::iota(0, MAX_ROWS), rv::iota(0, MAX_COLS))) {
|
||||||
if (map_data[i][j] == ' ')
|
if (map_data[i][j] == ' ') continue;
|
||||||
continue;
|
|
||||||
if (map_data[i][j] == '0') {
|
if (map_data[i][j] == '0') {
|
||||||
wall_list[i][j] = new Entity { { TILESIZE, TILESIZE },
|
wall_list[i][j] = new Entity { { TILESIZE, TILESIZE },
|
||||||
{ float(j * TILESIZE), float(i * TILESIZE) },
|
{ float(j * TILESIZE), float(i * TILESIZE) },
|
||||||
@@ -156,10 +65,8 @@ void load_map(std::array<std::array<Entity *, MAX_COLS>, MAX_ROWS> wall_list,
|
|||||||
}
|
}
|
||||||
if (map_data[i][j] == '1' && map_data[i][j + 1] == '-') {
|
if (map_data[i][j] == '1' && map_data[i][j + 1] == '-') {
|
||||||
int start = j, end = j;
|
int start = j, end = j;
|
||||||
while (end + 1 < MAX_COLS && map_data[i][end + 1] != '2')
|
while (end + 1 < MAX_COLS && map_data[i][end + 1] != '2') end++;
|
||||||
end++;
|
if (map_data[i][end + 1] == '2') end++;
|
||||||
if (map_data[i][end + 1] == '2')
|
|
||||||
end++;
|
|
||||||
wall_list[i][j] = new Entity { { float(end - start + 1) * TILESIZE, TILESIZE },
|
wall_list[i][j] = new Entity { { float(end - start + 1) * TILESIZE, TILESIZE },
|
||||||
{ float(j * TILESIZE), float(i * TILESIZE) },
|
{ float(j * TILESIZE), float(i * TILESIZE) },
|
||||||
{ 0, 0 },
|
{ 0, 0 },
|
||||||
@@ -168,10 +75,8 @@ void load_map(std::array<std::array<Entity *, MAX_COLS>, MAX_ROWS> wall_list,
|
|||||||
}
|
}
|
||||||
if (map_data[i][j] == '1' && map_data[i + 1][j] == '|') {
|
if (map_data[i][j] == '1' && map_data[i + 1][j] == '|') {
|
||||||
int start = i, end = i;
|
int start = i, end = i;
|
||||||
while (end + 1 < MAX_ROWS && map_data[end + 1][j] != '2')
|
while (end + 1 < MAX_ROWS && map_data[end + 1][j] != '2') end++;
|
||||||
end++;
|
if (map_data[end + 1][j] == '2') end++;
|
||||||
if (map_data[end + 1][j] == '2')
|
|
||||||
end++;
|
|
||||||
wall_list[i][j] = new Entity { { TILESIZE, float(end - start + 1) * TILESIZE },
|
wall_list[i][j] = new Entity { { TILESIZE, float(end - start + 1) * TILESIZE },
|
||||||
{ float(j * TILESIZE), float(i * TILESIZE) },
|
{ float(j * TILESIZE), float(i * TILESIZE) },
|
||||||
{ 0, 0 },
|
{ 0, 0 },
|
||||||
@@ -183,7 +88,8 @@ void load_map(std::array<std::array<Entity *, MAX_COLS>, MAX_ROWS> wall_list,
|
|||||||
|
|
||||||
Level levels[] = {
|
Level levels[] = {
|
||||||
{
|
{
|
||||||
.data = { {' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
|
.data = {
|
||||||
|
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
|
||||||
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
|
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
|
||||||
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
|
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
|
||||||
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
|
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
|
||||||
@@ -197,55 +103,73 @@ Level levels[] = {
|
|||||||
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
|
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
|
||||||
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '}, },
|
{' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '}, },
|
||||||
.name = "Empty"
|
.name = "Empty"
|
||||||
},
|
|
||||||
{
|
|
||||||
.data = { { '1', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '2' },
|
|
||||||
{ '1', '-', '-', '-', '2', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '1' },
|
|
||||||
{ '|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|' },
|
|
||||||
{ '|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|' },
|
|
||||||
{ '|', '1', '2', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|' },
|
|
||||||
{ '|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '1', '-', '-', '-', '-', '2', ' ', ' ', ' ', '|' },
|
|
||||||
{ '|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|' },
|
|
||||||
{ '|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|' },
|
|
||||||
{ '|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|' },
|
|
||||||
{ '|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|' },
|
|
||||||
{ '|', ' ', ' ', ' ', ' ', '1', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '1', ' ', ' ', ' ', ' ', '|' },
|
|
||||||
{ '2', ' ', ' ', ' ', ' ', '2', '0', ' ', ' ', ' ', ' ', ' ', ' ', '2', ' ', ' ', ' ', ' ', '2' },
|
|
||||||
{ '1', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '2' }, },
|
|
||||||
.name = "Default"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
.data = {
|
|
||||||
{ '1', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '2' },
|
|
||||||
{ '1', '-', '-', '-', '2', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '1' },
|
|
||||||
{ '|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|' },
|
|
||||||
{ '|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|' },
|
|
||||||
{ '|', '1', '-', '-', '-', '-', '2', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|' },
|
|
||||||
{ '|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '1', '-', '-', '-', '-', '2', ' ', ' ', ' ', '|' },
|
|
||||||
{ '|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|' },
|
|
||||||
{ '|', ' ', ' ', ' ', ' ', ' ', ' ', '0', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|' },
|
|
||||||
{ '|', ' ', ' ', ' ', ' ', '0', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|' },
|
|
||||||
{ '|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|' },
|
|
||||||
{ '|', ' ', ' ', ' ', ' ', '1', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '1', ' ', ' ', ' ', ' ', '|' },
|
|
||||||
{ '2', ' ', ' ', ' ', ' ', '2', '0', ' ', ' ', ' ', ' ', ' ', ' ', '2', ' ', ' ', ' ', ' ', '2' },
|
|
||||||
{ '1', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '2' }, },
|
|
||||||
.name = "1"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
.data = {
|
|
||||||
{ '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0' },
|
|
||||||
{ ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ' },
|
|
||||||
{ '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0' },
|
|
||||||
{ ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ' },
|
|
||||||
{ '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0' },
|
|
||||||
{ ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ' },
|
|
||||||
{ '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0' },
|
|
||||||
{ ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ' },
|
|
||||||
{ '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0' },
|
|
||||||
{ ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ' },
|
|
||||||
{ '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0' },
|
|
||||||
{ ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ' },
|
|
||||||
{ '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0' }, },
|
|
||||||
.name = "3"
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
// Level levels[] = {
|
||||||
|
// {
|
||||||
|
// .data = { {' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
|
||||||
|
// {' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
|
||||||
|
// {' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
|
||||||
|
// {' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
|
||||||
|
// {' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
|
||||||
|
// {' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
|
||||||
|
// {' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
|
||||||
|
// {' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
|
||||||
|
// {' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
|
||||||
|
// {' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
|
||||||
|
// {' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
|
||||||
|
// {' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
|
||||||
|
// {' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '}, },
|
||||||
|
// .name = "Empty"
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// .data = { { '1', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '2' },
|
||||||
|
// { '1', '-', '-', '-', '2', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '1' },
|
||||||
|
// { '|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|' },
|
||||||
|
// { '|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|' },
|
||||||
|
// { '|', '1', '2', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|' },
|
||||||
|
// { '|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '1', '-', '-', '-', '-', '2', ' ', ' ', ' ', '|' },
|
||||||
|
// { '|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|' },
|
||||||
|
// { '|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|' },
|
||||||
|
// { '|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|' },
|
||||||
|
// { '|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|' },
|
||||||
|
// { '|', ' ', ' ', ' ', ' ', '1', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '1', ' ', ' ', ' ', ' ', '|' },
|
||||||
|
// { '2', ' ', ' ', ' ', ' ', '2', '0', ' ', ' ', ' ', ' ', ' ', ' ', '2', ' ', ' ', ' ', ' ', '2' },
|
||||||
|
// { '1', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '2' }, },
|
||||||
|
// .name = "Default"
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// .data = {
|
||||||
|
// { '1', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '2' },
|
||||||
|
// { '1', '-', '-', '-', '2', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '1' },
|
||||||
|
// { '|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|' },
|
||||||
|
// { '|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|' },
|
||||||
|
// { '|', '1', '-', '-', '-', '-', '2', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|' },
|
||||||
|
// { '|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '1', '-', '-', '-', '-', '2', ' ', ' ', ' ', '|' },
|
||||||
|
// { '|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|' },
|
||||||
|
// { '|', ' ', ' ', ' ', ' ', ' ', ' ', '0', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|' },
|
||||||
|
// { '|', ' ', ' ', ' ', ' ', '0', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|' },
|
||||||
|
// { '|', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '|' },
|
||||||
|
// { '|', ' ', ' ', ' ', ' ', '1', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '1', ' ', ' ', ' ', ' ', '|' },
|
||||||
|
// { '2', ' ', ' ', ' ', ' ', '2', '0', ' ', ' ', ' ', ' ', ' ', ' ', '2', ' ', ' ', ' ', ' ', '2' },
|
||||||
|
// { '1', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '2' }, },
|
||||||
|
// .name = "1"
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// .data = {
|
||||||
|
// { '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0' },
|
||||||
|
// { ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ' },
|
||||||
|
// { '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0' },
|
||||||
|
// { ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ' },
|
||||||
|
// { '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0' },
|
||||||
|
// { ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ' },
|
||||||
|
// { '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0' },
|
||||||
|
// { ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ' },
|
||||||
|
// { '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0' },
|
||||||
|
// { ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ' },
|
||||||
|
// { '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0' },
|
||||||
|
// { ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ' },
|
||||||
|
// { '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0' }, },
|
||||||
|
// .name = "3"
|
||||||
|
// }
|
||||||
|
// };
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
void Timer::update_timers(bool& running, Times& times) {
|
void Timer::update_timers(bool& running, Times& times) {
|
||||||
while (running) {
|
while (running) {
|
||||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||||
|
|||||||
Reference in New Issue
Block a user