This commit is contained in:
DarthMooMancer
2025-11-06 17:34:42 -05:00
parent 0a07d776ce
commit fccc07600a
11 changed files with 193 additions and 205 deletions
+23 -13
View File
@@ -1,24 +1,34 @@
#ifndef ELEMENTS_HPP
#define ELEMENTS_HPP
struct Point;
struct Player;
void cleanup(Point** buffer, int buffer_size);
void allocate_points(Point** buffer, char symbol);
Player* get_current_player(Player* current_player, Player* player_one, Player* player_two);
#include <memory>
struct Point {
Point(int row, int col, char symbol) : m_row(row), m_col(col), m_symbol(symbol) {};
int m_row;
int m_col;
char m_symbol;
};
class Window;
struct Player {
Player(char symbol, bool turn, int id) : m_symbol(symbol), m_id(id) {};
Player(char symbol, int id) : m_symbol(symbol), m_id(id) {};
char m_symbol;
int m_id;
bool on_line(Point** buffer);
bool on_line();
};
class Engine {
public:
Engine();
~Engine();
void run();
private:
std::unique_ptr<Window> win;
struct GameState {
Player player1;
Player player2;
Player *temp;
GameState() : player1('x', 1), player2('o', 2), temp { &player1 } {};
} state;
void get_current_player();
bool process_input();
bool exit_code();
};
#endif
-1
View File
@@ -2,6 +2,5 @@
#define GLOBALS_HPP
#define ROW 5
#define COL 5
#define FMPS 16
#endif
-10
View File
@@ -1,10 +0,0 @@
#ifndef INPUT_HPP
#define INPUT_HPP
#include "elements.hpp"
struct Input {
int _getch = 0;
void get_input(bool &running, Point** buffer, Player *&current_player, Player *player_one, Player *player_two);
};
#endif
+5 -7
View File
@@ -1,16 +1,14 @@
#ifndef WINDOW_HPP
#define WINDOW_HPP
#include "globals.hpp"
#include "elements.hpp"
#include <globals.hpp>
#include <array>
struct Window {
Point* m_board[ROW][COL] = {};
// void terminate(Tile (&tile_list)[9], bool &running);
Window();
std::array<std::array<char, COL>, ROW> view;
void clear_display();
void update_display(Point** buffer);
void draw_display(int fps);
void draw_display();
};
#endif