-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDemo_Main.cpp
More file actions
123 lines (107 loc) · 3.3 KB
/
Demo_Main.cpp
File metadata and controls
123 lines (107 loc) · 3.3 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
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
#include "Battle.h"
#include "GUI\GUI.h"
#include <fstream>
#include <sstream>
int main()
{
Battle* pGameBattle = new Battle;
GUI * pGUI = new GUI;
Point p;
pGUI->PrintMessage("Please Enter the inputfile name and its format for example: input.txt");
pGameBattle->LoadFile(pGUI);//loading the data from the input file
pGUI->ClearStatusBar();
pGUI->PrintMessage("Please choose your mode from the menu bar");
pGameBattle->DrawEnemies(pGUI);//Drawing the enemies whose arrival time is zero
int ChosenMode = -1;
while(ChosenMode == -1)
{
pGUI->GetPointClicked(p);
if(p.y > 0 && p.y < 50)
{
if(p.x > 0 && p.x < 1*80)
{
pGUI->ClearStatusBar();
pGUI->PrintMessage("Your Now in active Mode !! click anywhere to start the game");
ChosenMode = 0;
break;
}
if(p.x > 1*80 && p.x < 2*80)
{
pGUI->ClearStatusBar();
pGUI->PrintMessage("Your Now in Step By Step Mode !! the game will start automatically");
ChosenMode = 1;
Sleep(2000);
break;
}
if(p.x > 2*80 && p.x < 3*80)
{
pGUI->ClearStatusBar();
pGUI->PrintMessage("Your Now in Silent Mode !! the game results will be in the output file , Check it!!!!!");
Sleep(2000);
ChosenMode = 2;
break;
}
else
{
pGUI->ClearStatusBar();
pGUI->PrintMessage("you have clicked on a wrong area plz select one of the 3 modes in the menu bar");
}
}
else
{
pGUI->ClearStatusBar();
pGUI->PrintMessage("you have clicked on a wrong area plz select one of the 3 modes in the menu bar");
}
}
while(!pGameBattle->IsAllEnemiesDead() && !pGameBattle->IsAllTowersDestroyed())
{
if(ChosenMode == 0)
pGUI->GetPointClicked(p);
// Clear for redrawing
if(ChosenMode != 2)
{
// Clear for redrawing
pGUI->ClearStatusBar();
pGUI->ClearBattleArea();
pGUI->DrawUnpaved(pGameBattle->GetX(0),pGameBattle->GetX(1),pGameBattle->GetX(2),pGameBattle->GetX(3));
pGUI->DrawCastle();
pGUI->IntializingWidth();
pGUI->ResetTextHeight();
pGUI->PrintMessage(" TowerHealth NoOfActiveEnems Unpaved Dis NoOfKilledEnems ");
pGUI->ResetTextWidth();
}
pGameBattle->SimpleSimulator();//Updateing the List
// Redraw the enemies
if(ChosenMode != 2)
{
pGUI->ClearStatusBar();
pGUI->ClearBattleArea();
pGUI->DrawUnpaved(pGameBattle->GetX(0),pGameBattle->GetX(1),pGameBattle->GetX(2),pGameBattle->GetX(3));
pGUI->DrawCastle();
pGameBattle->DrawEnemies(pGUI);
pGUI->IntializingWidth();
pGUI->PrintMessage(" TowerHealth NoOfActiveEnems Unpaved Dis NoOfKilledEnems ");
pGUI->ResetTextWidth();
pGameBattle->GetCastle()->PrintInfo(pGUI);
}
if(ChosenMode == 1)
Sleep(1000);
}
pGUI->ResetTextWidth();
pGUI->ResetTextHeight();
pGUI->ClearStatusBar();
pGameBattle->DisplaySound();
if(pGameBattle->IsAllEnemiesDead())
{
pGUI->PrintMessage("Victoryyyyy!!!!!Congratulations !!! you have won,Click any where to continue");
}
if(!pGameBattle->IsAllEnemiesDead())
{
pGUI->PrintMessage("unfortunately you have Lost,Click any where to continue");
}
pGUI->GetPointClicked(p);
delete pGUI;
pGameBattle->OutputFile();
delete pGameBattle;
return 0;
}