refactored drawing method

This commit is contained in:
DarthMooMancer
2025-11-12 12:29:17 -05:00
parent 09c2ff32e1
commit f424ee3d61
3 changed files with 52 additions and 63 deletions
+8 -12
View File
@@ -7,17 +7,13 @@
constexpr int ROW = 15;
constexpr int COL = 31;
constexpr int SIZE { 5 };
enum class Direction {
NONE, UP, DOWN
};
constexpr int SIZE { 3 };
struct vec2 {
int a, b;
vec2() : b(0), a(0) {};
vec2(int x, int y) : a(x), b(y) {};
void set(int a1, int b1) { a = a1; b = b1; };
int x, y;
vec2() : y(0), x(0) {};
vec2(int x, int y) : x(x), y(y) {};
void set(int a1, int b1) { x = a1; y = b1; };
auto operator <=> (const vec2&) const = default;
};
@@ -25,14 +21,14 @@ struct Paddle {
Paddle(const vec2 init_pos);
std::array<vec2, SIZE> nodes;
const char symbol { '|' };
enum Direction dir = Direction::NONE;
enum class Dir { NONE, UP, DOWN } dir;
void move();
};
struct Window {
std::array<std::array<char, COL>, ROW> view = {};
void clear_display();
void draw_display();
void draw_display() const;
void update_display(const vec2 &ball, const Paddle &p1, const Paddle &p2);
};
@@ -49,7 +45,7 @@ private:
vec2 ball { (COL / 2), (ROW / 2) };
vec2 ball_direction { 1, 1 };
Paddle p1 { { 1, (ROW / 2) - (SIZE / 2) } };
Paddle p2 { { COL - 2, (ROW / 2) - (SIZE / 2) } };
Paddle p2 { { COL - 2, (ROW / 2) - (SIZE / 2) - 1 } };
std::chrono::steady_clock::time_point last_clock_update;
bool exit_process();