-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLeftSlant.cpp
72 lines (64 loc) · 1.48 KB
/
LeftSlant.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include <iostream>
#include "LeftSlant.h"
#include "Constants.h"
/*
* LeftSlant is the piece that looks like this
*
* ####
* ####
*
* This piece is also known as "Z", "N", "skew", or "Snake".
*
* See: http://tetris.wikia.com/wiki/Nintendo_Rotation_System
*
*/
using namespace std;
LeftSlant::LeftSlant()
: Shape ()
{
string leftslant0[3] =
{ " ",
"## ",
" ##" };
string leftslant1[3] =
{ " #",
" ##",
" # " };
// TODO: Somewhat broken. Why "1"s in the first parameter? It's the rotatation number, no?
// The code ROTATES in the direction specified by the first argument. The "1" means rotate
// rotate 'right'. SIGH!
init_shape(1,3,leftslant0);
init_shape(1,3,leftslant1);
init_shape(1,3,leftslant0);
init_shape(1,3,leftslant1);
}
void LeftSlant::rotate_left()
{
rotate(-1);
}
void LeftSlant::rotate_right()
{
rotate(1);
}
void LeftSlant::draw()
{
// The "3" is the height and width of the shape 'square'
for (int row = 0; row < 3; row++) {
for (int col = 0; col < 3; col++) {
cout << shapedata(row, col);
}
cout << endl;
}
}
int LeftSlant::get_piece_type()
{
return(LEFT_SLANT); // This is the constant for a LeftSlant
}
void LeftSlant::init_shape(int rotation, int square_size, string in_shape_data[]) {
rotate(rotation);
height() = square_size;
width() = square_size;
for (int i = 0; i < square_size; i++) {
shapedata() += in_shape_data[i];
}
}