#pragma once #include #include #include constexpr int ROW = 11; constexpr int COL = 11; enum class Direction { UP, DOWN, LEFT, RIGHT }; struct vec2 { int x, y; vec2(int x, int y) : x(x), y(y) {} void set(int _x, int _y) { x = _x; y = _y; } auto operator <=> (const vec2&) const = default; }; struct Window { std::array, ROW> view; void draw_display(); void update_display(vec2 &head, vec2 &fruit, std::deque &buf); }; class Engine { public: Engine(); ~Engine(); void run(); private: Window win; std::deque tail; std::string status; vec2 head { COL / 2, ROW / 2 }; vec2 fruit { rand() % COL, rand() % ROW }; vec2 prev_head { head.x, head.y }; Direction dir = Direction::RIGHT; unsigned int m_score = 0; bool process_input(); void determine_index_zero_pos(); void move_tail_indicies(); void add_tail_and_respawn_fruit(); bool exit_summary(); };