fix: collision mostly works and game is functional. Some bugs I think I need to work out but good enough to come back to later. The game is playable now

This commit is contained in:
DarthMooMancer
2025-09-18 22:46:51 -04:00
parent 28bd852531
commit f7cb337d8f
7 changed files with 94 additions and 110 deletions
+7 -17
View File
@@ -1,30 +1,20 @@
#ifndef ELEMENTS_HPP
#define ELEMENTS_HPP
#include <vector>
#include <string>
#include "globals.hpp"
struct Point;
void move(Point* board[ROW][COL]);
void create_point_on_board(Point* board[ROW][COL]);
struct Point {
Point() : m_row(0), m_col(0), m_symbol(2), m_direction('n') {};
Point(int row, int col) : m_row(row), m_col(col), m_symbol(2), m_direction('n') {};
char m_direction;
Point(int row, int col) : m_row(row), m_col(col), m_symbol(2), m_direction(' '), m_collide(false) {};
int m_row;
int m_col;
char m_direction;
int m_symbol;
void assign();
void assign(int row, int col);
std::string to_string();
bool m_collide;
};
struct PointCollection {
std::vector<Point> m_point_list;
void collide_with_adjacent(Point* board[ROW][COL]);
void set_direction(char direction, Point* board[ROW][COL]);
};
void move_points(Point* board[ROW][COL]);
void create_point_on_board(Point* board[ROW][COL]);
void collide_with_adjacent_point(Point* board[ROW][COL]);
void set_direction(char direction, Point* board[ROW][COL]);
#endif
+1 -1
View File
@@ -6,7 +6,7 @@
struct Input {
int _getch;
void get_input(bool &running, PointCollection &collection, Point* board[ROW][COL]);
void get_input(bool &running, Point* board[ROW][COL]);
};
#endif
+2 -3
View File
@@ -3,12 +3,11 @@
#include "globals.hpp"
#include "elements.hpp"
#include <array>
struct Window {
// std::array<std::array<int, COL>, ROW> m_board = {};
Point* m_board[ROW][COL] = { nullptr };
void draw_window(PointCollection &collection);
void draw_window();
void tick(int milliseconds);
};
#endif