-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgameboard.h
79 lines (61 loc) · 1.59 KB
/
gameboard.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#ifndef GAMEBOARD_H
#define GAMEBOARD_H
#include <QWidget>
#include <QTimer>
#include "language.h"
namespace Ui {
class GameBoard;
}
class GameBoard : public QWidget
{
Q_OBJECT
public:
explicit GameBoard(QWidget *parent = nullptr);
~GameBoard();
enum results
{
draw = 0,
win,
lost
};
void setColorPieces(QColor color);
protected:
void paintEvent(QPaintEvent *event) override;
void mousePressEvent(QMouseEvent *event) override;
void mouseMoveEvent(QMouseEvent *event) override;
private:
Ui::GameBoard *ui;
int rows;
int cols;
int cellSize;
int currentPlayer;
int column_selected = 0;
QVector<QVector<int>> grid;
bool dropDisc(int column, int &row);
bool canDropDisc(int column, int &row);
bool checkWin(int row, int col);
bool checkFullGrid();
void resetBoard();
// Variables para la animación
bool isAnimating;
int animColumn;
int animTargetRow;
double animY; // Posición Y actual de la ficha en la animación
int animPlayer; // Jugador que está animando
QTimer animationTimer;
void startAnimation(int column, int player);
bool cpu_on{true};
enum states{
disable=0,
player1,
player2
};
states curr_state{disable};
QColor p1, p2;
public slots:
void receive_current_players(int num);
signals:
void emit_result(results data);
void turnChanged(int currentPlayerIndex); // Señal para indicar el cambio de turno
};
#endif // GAMEBOARD_H