72 lines
1.5 KiB
C++
72 lines
1.5 KiB
C++
#pragma once
|
|
|
|
#include <iostream>
|
|
#include <fstream>
|
|
#include <array>
|
|
#include <vector>
|
|
#include <deque>
|
|
#include <string>
|
|
#include <raylib.h>
|
|
|
|
using std::deque;
|
|
using std::string;
|
|
using std::array;
|
|
using std::vector;
|
|
|
|
using std::cin;
|
|
using std::cout;
|
|
|
|
#define FPS 15
|
|
#define SCREEN 800
|
|
#define LINE_W 2
|
|
|
|
#define IMG_COUNT 2
|
|
|
|
enum tile {empty = 0, p1 = 1, p2 = 2, tie = 3};
|
|
#define OKAY -1
|
|
#define CHANGE -2
|
|
|
|
|
|
tile act(int t);
|
|
tile pas(int t);
|
|
Color col(int t);
|
|
|
|
struct Block {
|
|
tile t = empty;
|
|
int depth;
|
|
Rectangle place;
|
|
array<Block*, 9> sons;
|
|
|
|
Block() {}
|
|
Block(int _depth, Rectangle trg);
|
|
Rectangle get_son_rectangle(int son);
|
|
int set(tile pl);
|
|
bool playable(deque<int> v);
|
|
int play(deque<int> v, tile pl);
|
|
bool check_tie();
|
|
tile update();
|
|
Rectangle getRect(deque<int> v);
|
|
void updateRect(Rectangle trg);
|
|
|
|
void save(vector<tile> *r);
|
|
void load_state(vector<tile> state, int pos);
|
|
void undo(deque<int> &prev);
|
|
};
|
|
|
|
void update(int &time, deque<int> &turn, Block* root, Rectangle &dst);
|
|
void undo(Block *root, deque<int> &prev, Rectangle &dst, int &time);
|
|
bool valid(Block* root, Rectangle &dst, deque<int> &turn);
|
|
|
|
class Renderer {
|
|
array<Texture2D, IMG_COUNT> textures;
|
|
Block *root;
|
|
|
|
void prepareTextures();
|
|
|
|
public:
|
|
void renderImage(tile t, Rectangle dst, Color color = WHITE);
|
|
void render_all(Block* root, int time, Rectangle play_area, deque<int> highlight = {});
|
|
void render_block(Block *b);
|
|
int update_board_size(int depth);
|
|
void prepare_screen(Block* root, int time, Rectangle dst);
|
|
};
|