-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.cpp
48 lines (36 loc) · 1.23 KB
/
example.cpp
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
#include "tetris.h"
#include <iostream>
#include <string>
int main() // Example code -- you move pieces manually
{
srand(time(0));
TetrisGame game;
// for (auto i : game.bag) std::cout << i.toString() << "\n";
char line;
game.spawnPiece();
// CONTROLS - S to move down, X to slam, E to rotate clockwise, A/D to move sideways.
while (std::cin >> line) { // Each time you input the piece moves down and possibly in another direction
if (line >= 'A' && line <= 'Z') line = line + 'a' - 'A';
if (line == 'x') {
while (game.movePieceDown());
game.spawnPiece();
std::cout << game.clearLines() << " LINES CLEARED\n";
}
else if (line == 's') {
}
else if (line == 'e') {
game.rotatePieceClockwise();
}
else if (line == 'a') game.movePiece({-1, 0});
else if (line == 'd') game.movePiece({1, 0});
bool a = game.movePieceDown();
if (!a) {
game.spawnPiece();
std::cout << game.clearLines() << " LINES CLEARED\n";
}
game.disp();
if (game.endgame) break;
}
std::cout << "END\n";
return 0;
}