refactor: renaming functions and removing old functions

This commit is contained in:
DarthMooMancer
2025-08-30 01:23:38 -04:00
parent 96e5eb9930
commit b0393c65f2
3 changed files with 6 additions and 7 deletions
+2 -3
View File
@@ -21,10 +21,9 @@ struct Body {
std::vector<Tail> m_body;
int m_score;
bool m_collision;
void clear(std::array<std::array<char, COL>, ROW> &arr);
void add_tail();
void check_new_tail();
void check_collision(Head &head);
void get_new_points(Head &head);
void collision(Head &head);
};
struct Fruit {
+2 -2
View File
@@ -39,7 +39,7 @@ Body::Body() {
m_collision = false;
}
void Body::collision(Head &head) {
void Body::check_collision(Head &head) {
for(int i = 0; i < m_body.size(); i++) {
if(m_body.at(i).m_tail_pos.m_row == head.m_head.m_row) {
if(m_body.at(i).m_tail_pos.m_col == head.m_head.m_col) {
@@ -49,7 +49,7 @@ void Body::collision(Head &head) {
}
}
void Body::add_tail() {
void Body::check_new_tail() {
if(m_score >= 1) {
m_score = 0;
m_body.push_back(Tail{});
+2 -2
View File
@@ -18,8 +18,8 @@ int main () {
std::ref(running));
while (running) {
body.collision(head);
body.add_tail();
body.check_collision(head);
body.check_new_tail();
if(body.m_body.size() >= (ROW * COL)) {
std::cout << "You win! Score: " + std::to_string(body.m_body.size()) << std::endl;
running = false;