-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBit.h
96 lines (68 loc) · 1.79 KB
/
Bit.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
/*************************************************************************************
FileName: Bit.h
Descrition: Contains all the most basically used elements of the matrix class
including exceptions it uses to throw and the basic struct Bit,
the essential building block of tetronimoes.
FutureNeeds:
**************************************************************************************/
#ifndef TETRIS_BITS_COMPONENTS
#define TETRIS_BITS_COMPONENTS
//INCLUSIONS
#include <exception>
#include <cstdlib>
#include <memory>
#include <windows.h>
#include <MMsystem.h>
#include "HeaderStuff.h"
//NAMESPACE
using namespace std;
/*********************************************
The BIT (direction vectors)
They are the components of all the tetronimoes
PossibleChanges: If setting a Bit to NULL
does not work to keep it
unactive, then we might
need each Bit to contain
the member varibale active
**********************************************/
struct Bit
{
//Stores a location for each bit
int r_, c_;
bool active_;
//Stores a color for each block
int color_;
//Simplified Bit Constructor
Bit(int r = 0, int c = 0, bool active = true)
{
r_ = r;
c_ = c;
color_ = 0;
active_ = active;
}
const Bit operator + (const Bit& other) const
{
Bit newBit;
newBit.r_ = this->r_ + other.r_;
newBit.c_ = this->c_ + other.c_;
return newBit;
}
const Bit operator * (int num) const
{
Bit newBit;
newBit.r_ = this->r_ * num;
newBit.c_ = this->c_ * num;
return newBit;
}
bool operator == (const Bit& other) const
{
bool equals = true;
if(r_ != other.r_)
equals = false;
if(c_ != other.c_)
equals = false;
//Return
return equals;
}
};
#endif