starting refactoring

This commit is contained in:
DarthMooMancer
2025-11-18 23:53:53 -05:00
parent a955f2d067
commit 46a975f90e
2 changed files with 20 additions and 35 deletions
+11 -11
View File
@@ -1,6 +1,7 @@
#pragma once
#include "globals.hpp"
#include <array>
struct vec2;
struct Paddle;
@@ -17,19 +18,19 @@ bool is_block_buffer_empty(Block** block_buffer, int block_buffer_size);
enum Direction { LEFT, RIGHT, NONE };
struct vec2 {
vec2() : y(0), x(0) {};
vec2(int row, int col, char symbol) : y(row), x(col), m_symbol(symbol) {};
vec2() : x(0), y(0) {};
vec2(int x, int y) : x(x), y(y) {};
vec2(int x, int y, char symbol) : x(x), y(y), m_symbol(symbol) {};
int x, y;
char m_symbol;
void assign(int row, int col);
void set(int x, int y);
auto operator <=> (const vec2&) const = default;
};
struct Ball {
Ball(int default_vx, int default_vy) : vx(default_vx), vy(default_vy) {};
~Ball();
vec2* m_origin;
int vx;
int vy;
Ball();
vec2 m_origin { COL / 2, ROW - 5, '*' };
vec2 vel { 1, -1 };
void determine_new_position(int &paddle_lives, int reset_ball_x, int reset_ball_y);
void change_velocity(char d);
};
@@ -47,10 +48,9 @@ struct Paddle {
struct Block {
Block();
Block(int size, int row, int col, char symbol);
Block(vec2 pos, char symbol);
~Block();
int _size;
vec2** m_nodes;
std::array<vec2, 3> m_nodes = {};
bool check_collision(Ball &ball);
};