removed the input thread and integrated it to the SnakeGame engine itself

This commit is contained in:
DarthMooMancer
2025-11-04 23:31:23 -05:00
parent 183be3c24a
commit e87094ce13
8 changed files with 59 additions and 67 deletions
+9 -5
View File
@@ -4,6 +4,8 @@
#include <vector>
#include "globals.hpp"
class Window;
enum Direction {
UP, DOWN, LEFT, RIGHT
};
@@ -19,19 +21,21 @@ struct Vector2i {
class SnakeGame {
public:
SnakeGame();
// ~SnakeGame();
// Vector2i* buf[MAX_LEN] = {};
~SnakeGame();
void run();
private:
std::vector<Vector2i> buf;
bool running = true;
enum Direction m_dir;
int m_score = 0;
Window* win;
void process_input();
void determine_index_zero_pos();
void move_tail_indicies();
void on_fruit_eaten(Vector2i (*board)[COL]);
bool segment_overlap();
bool exit_summary();
private:
int m_score = 0;
// int m_snake_size = 3;
};
#endif // ELEMENT_HPP
-7
View File
@@ -1,7 +0,0 @@
#ifndef INPUT_HPP
#define INPUT_HPP
#include "element.hpp"
void get_input(enum Direction &dir, bool &r);
#endif // INPUT_HPP
+1 -1
View File
@@ -7,7 +7,7 @@
struct Window {
Vector2i board[ROW][COL] = {};
void clear_display();
void draw_display(int milliseconds);
void draw_display();
void update_display(std::vector<Vector2i> &buf);
};