-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRotatingGear.cpp
More file actions
77 lines (62 loc) · 1.63 KB
/
Copy pathRotatingGear.cpp
File metadata and controls
77 lines (62 loc) · 1.63 KB
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
#include "RotatingGear.h"
RotatingGear::RotatingGear(const CellPosition & gearposition,bool clockwise) : GameObject(gearposition)
{
isClockWise = clockwise;
}
void RotatingGear::Draw(Output* pOut) const
{
pOut->DrawRotatingGear(position, isClockWise);
}
void RotatingGear::Apply(Grid* pGrid, Player* pPlayer)
{
Output* pOut = pGrid->GetOutput();
Input* pIn = pGrid->GetInput();
if (isClockWise)
pOut->PrintMessage("You have reached a rotating gear, you will rotate clockwise. Click to continue ...");
else
pOut->PrintMessage("You have reached a rotating gear, you will rotate counterclockwise. Click to continue ...");
int x, y;
pIn->GetPointClicked(x, y);
if (isClockWise)
pPlayer->RotateRight();
else
pPlayer->RotateLeft();
pOut->ClearStatusBar();
}
void RotatingGear::Save(ofstream& OutFile, type Type, int n)
{
string clockwise="CounterClockWise";
if (isClockWise == 1)
{
clockwise = "ClockWise";
}
if (Type == rotatinggears)
{
OutFile << "RotatingGear n" << n << " cell = " << position.GetCellNumFromPosition(position) <<"\t" << "Rotating Gear n" << n << " rotation direction :" << clockwise << "\n";
}
}
void RotatingGear::Load(ifstream& Infile)
{
string skipping;
int gearcell;
string geardir;
Infile >> gearcell; //get the cell number of saved rotating gear
getline(Infile, skipping,':');
Infile >> geardir; //get the direction of saved rotating gear
position = position.GetCellPositionFromNum(gearcell);
if (geardir == "ClockWise")
{
isClockWise = true;
}
else
{
isClockWise = false;
}
}
bool RotatingGear::GetisClockWise() const
{
return isClockWise;
}
RotatingGear::~RotatingGear()
{
}