starting an upgrade to move everything to just use ptrs and simplify the code a little

This commit is contained in:
DarthMooMancer
2025-09-24 14:25:03 -04:00
parent 626d7261d4
commit 0d47de8a7a
5 changed files with 73 additions and 48 deletions
+11 -5
View File
@@ -4,25 +4,31 @@
#include <vector>
#include "globals.hpp"
struct Point {
int m_row;
int m_col;
Point() {}
Point(int x, int y) : m_row(x), m_col(y) {}
char m_symbol;
int m_direction;
Point() : m_row(0), m_col(0), m_symbol(' ') {}
Point(int x, int y, char s) : m_row(x), m_col(y), m_symbol(s) {}
Point(int x, int y, char s, int d) : m_row(x), m_col(y), m_symbol(s), m_direction(d) {}
void set_new_point(int row, int col);
void set_new_point(Point &point);
};
void get_new_pos(Point* (*board)[COL], Point** segments);
struct Head {
Head() : m_direction(2) {};
Point m_head {5, 5};
Point m_head {5, 5, '*'};
Point m_previous_head;
int m_direction;
void get_new_pos();
};
struct Tail {
Point m_tail_pos;
Point m_tail_pos {0, 0, '@'};
Point m_previous_tail_pos;
};
@@ -35,7 +41,7 @@ struct Body {
struct Fruit {
Fruit();
Point m_point;
Point m_point {0, 0, 'o'};
void get_new_pos(char (&board)[ROW][COL], Head &head);
};
+3 -2
View File
@@ -5,8 +5,9 @@
#include "element.hpp"
struct Window {
char m_board[ROW][COL] = {};
void update_display(Fruit &fruit, Head &head, Body &body);
Point* m_board[ROW][COL] = {};
void draw_display();
void update_display(Point* segments[]);
};
#endif // WINDOW_HPP