-
Notifications
You must be signed in to change notification settings - Fork 0
/
Pieces.h
127 lines (82 loc) · 3.94 KB
/
Pieces.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
127
/***********************************************************************************************
FileName: Pieces.h
Descrition: Contains all the declration and implementation for all the individual tetronimoes
and their abstract class Piece
AddDetails: Assigns pieces a location. Constructs the tetronimoe in a random direction
depeding on which direction vector (in the guise of a bit (the main component of
tetronimoes)) is passed to its pieceBuilder( bit ). The direction vector is then
passed to a singular set of instructions (involing the matrix class for multiplication)
which knows how to build a tetronimoe flipped in any direction.
FutureMods: Eventually will have a way of assigning location at random based on the size
of the Tetris field. possibly we can eventually give the bit struct a class
treatment so we can give it a set way to delete itself.
AddProgNotes: _ underscore will be used after a variable to indicate its a member variable of
a class/struct
************************************************************************************************/
#ifndef TETRIS_GAME_MANAGER_PIECESCONTAINER_PIECES
#define TETRIS_GAME_MANAGER_PIECESCONTAINER_PIECES
//INCLUSIONS
#include "Matrix.h"
#include "Bit.h"
/*****************************************************************************************
DEFINE THE DIRECTION VECTORS
AdditionalDetails:
The Unit vectors are define to a placing a
standard axis on the screen, not the axis of
up, down, left, right of the array
-----> (+) left /\ (+) up Screen Axis of Coordinate (THE USED AXIS FOR UNIT VECTOR)
||
____________________________________________
-----> (+) left || (+) down Array Axis of Coordinates (000 nbn)
\/
*******************************************************************************************/
const Bit upUnitVector(-1, 0), leftUnitVector(0, -1), downUnitVector(1, 0), rightUnitVector(0, 1);
/******************************************************************************************
DEFINE THE ROTIONAL MATRIX
AdditionalDetails:
When I feed a vector V into M(X) it essentially rotates the vector 90 degrees in towards
positive theta in the system of the Array Axis for Coordinates
*******************************************************************************************/
//RATHER THAN CREATE A CONSTRUCTOR THAT FILLS MY MATRIX PROPERLY...I use this...ugh
/********************************************************************************************
ClassName: Piece
Qualities: Abstract--partially, I come in and define some methods that other pieces
will no doubt, have no need for redefinition. They will prove useful.
Purpose: Sets a map of qualities for all the tetronimoes
FutureNeeds: -Needs a funtion to shift the tetronimoes until they fall within the
playing field.
-A way to store direction and recall it, so that eventually we can
use this to flip while in game.
-Check need for globality of Y_START
Possible Changes: - Add global variables header file
********************************************************************************************/
class Piece
{
public:
Piece();
Piece(Bit direction, Bit startLocation);
Piece(const Piece& p);
Bit& operator [] (int n);
Piece& operator = (const Piece& p);
char getType() {return type_;}
int getColor() const;
void changeColor(const int amount = 1);
/*
if move calls flip and it can't, it needs to know
so that it won't exhaust an iteration of move
without performing an action
*/
bool deleteBit(int n = 0);
protected:
virtual void pieceBuilder( Bit direction, Bit startLocation);
//NEED TO WRITE A FUNCTION THAT MOVES THE BITS DOWN
//UNTIL THEY FALL IN BOUND OF THE FIELD
//A PIECE'S GUTS
Bit bits_[4];
Bit direction_;
char type_;
int color_;
//FRIEND FUNCTION
friend Piece* giveFlipped(const Piece &p);
};
#endif