-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgames.h
126 lines (114 loc) · 3.22 KB
/
games.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#ifndef GAMES_H
#define GAMES_H
#include "element.h"
#include <string>
#include <QDebug>
#include <queue>
using namespace std;
class Game
{
public:
Game(int row, int col, int length);
~Game();
public:
int ROW;
int COL;
int LENGTH;
double axis_row;
double axis_col;
int score;
bool gameover;
bool isLast;
bool bfsState;
bool initPuyo;
bool moved = false;
string pastShape;
string** board;
string* next;
int** boardInt;
Points* points;
// 통합된 가상 메서드
virtual int move(Points*, int, int) = 0;
virtual void xz(Points*, int) = 0;
virtual Point* getPoint1() = 0;
virtual Point* getPoint2() = 0;
virtual Point* getPoint3() = 0;
virtual Point* getPoint4() = 0;
virtual int bfs() = 0;
virtual int gravity() = 0;
virtual void lastPang() = 0;
void rotateClockwise(Points* points,Point* pivot) {
for (int i = 0; i < points->size(); ++i) {
Point* p = points->getPoint(i);
double tempX = (double)p->x -pivot->x;
double tempY = (double)p->y - pivot->y;
p->x = pivot->x - tempY;
p->y = pivot->y + tempX;
}
}
void rotateCounterClockwise(Points* points,Point* pivot) {
for (int i = 0; i < points->size(); ++i) {
Point* p = points->getPoint(i);
double tempX = (double)p->x -pivot->x;
double tempY = (double)p->y - pivot->y;
p->x = pivot->x + tempY;
p->y = pivot->y - tempX;
}
}
};
class PuyopuyoGame : public Game
{
public:
Point *p1;
Point *p2;
virtual int move(Points*, int, int) override;
virtual void xz(Points*, int) override;
virtual Point* getPoint1() override { return p1; }
virtual Point* getPoint2() override { return p2; }
virtual Point* getPoint3() override { return nullptr; }
virtual Point* getPoint4() override { return nullptr; }
virtual int bfs() override;
virtual int gravity() override;
virtual void lastPang() override;
PuyopuyoGame();
~PuyopuyoGame();
};
class TetrisGame : public Game
{
public:
Point *p1;
Point *p2;
Point *p3;
Point *p4;
virtual int move(Points*, int, int) override;
virtual void xz(Points*, int) override;
virtual Point* getPoint1() override { return p1; }
virtual Point* getPoint2() override { return p2; }
virtual Point* getPoint3() override { return nullptr; }
virtual Point* getPoint4() override { return nullptr; }
virtual int bfs() override;
virtual int gravity() override;
virtual void lastPang() override;
TetrisGame();
~TetrisGame();
};
class PuyopuyoTetrisGame : public Game
{
public:
Point *p1;
Point *p2;
Point *p3;
Point *p4;
virtual int move(Points*, int, int) override;
virtual void xz(Points*, int) override;
virtual Point* getPoint1() override { return p1; }
virtual Point* getPoint2() override { return p2; }
virtual Point* getPoint3() override { return nullptr; }
virtual Point* getPoint4() override { return nullptr; }
virtual int bfs() override;
virtual int gravity() override;
virtual void lastPang() override;
PuyopuyoTetrisGame();
~PuyopuyoTetrisGame();
};
#endif // GAMES_H