-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGameOver.cpp
156 lines (126 loc) · 3.41 KB
/
GameOver.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
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
//
// GameOver.cpp
// battleeee
//
// Created by Ingy on 2/23/15.
// Copyright (c) 2015 Ingy. All rights reserved.
//
#include "GameOver.h"
#include <fstream>
#include <iostream>
#include "ResourcePath.hpp"
GameOver :: GameOver (RenderWindow * w, Settings * S, bool won)
{
name= w;
this->S=S;
if(won)
{
if (S->language=="English")
textSource=resourcePath()+"GameOverTextWonE.txt";
else if (S->language=="French")
textSource=resourcePath()+"GameOverTextWonF.txt";
// else if (S->language=="Arabic")
// textSource=resourcePath()+"GameOverTextWonA.txt";
}
else{
if (S->language=="English")
textSource=resourcePath()+"GameOverTextLostE.txt";
else if (S->language=="French")
textSource=resourcePath()+"GameOverTextLostF.txt";
// else if (S->language=="Arabic")
// textSource=resourcePath()+"GameOverTextWonA.txt";
}
initialize();
gameloop();
}
GameOver :: ~ GameOver()
{
}
void GameOver :: initialize()
{
// read settings from file / music/ theme/ difficulty
string back = resourcePath()+"background7.png";
string curs = resourcePath()+"cursor2.png";
backTexture.loadFromFile(back);
backImage.setTexture(backTexture);
ifstream in;
pageFont=S->overallFont;
string temp;
if (S->language== "English")
{
// open english
in.open(textSource.c_str());
getline (in, temp);
backText.setString("BACK");
}
else if(S->language== "French")
{
in.open(textSource.c_str());
getline (in, temp);
backText.setString("REVENIR");
}
title.setFont(pageFont);
title.setCharacterSize(50);
title.setString(temp);
title.setPosition((name->getSize().x)/2-180, 100);
title.setColor(Color(10,15,80));
backText.setPosition(90,50);
backText.setColor(Color(10,15,80));
backText.setFont(pageFont);
backText.setCharacterSize(40);
in.close();
// cursorTexture=this->S->cursorTexture;
// cursor.setTexture(cursorTexture);
// cursor.setPosition(50,backText.getPosition().y+5);
// cursor.setScale(0.42, 0.38);
// cursorXpos = cursor.getPosition().x;
// cursorYpos =cursor.getPosition().y; // text +5
}
void GameOver :: gameloop()
{
bool flag =true;
while (name->isOpen() && flag)
{
flag=handleEvents();
update();
renderScreen();
}
}
void GameOver:: renderScreen()
{
this->name->clear();
// pictures
name->draw(backImage);
//Text
name->draw(title);
name->draw(backText);
//cursor
// name->draw(cursor);
this->name->display();
}
bool GameOver :: handleEvents()
{
bool flag =true; Event event;
while (name -> pollEvent(event) && flag)
{
switch(event.type)
{
case Event::Closed:
name->close();
flag=false;
break;
case Event::KeyPressed:
if (event.key.code == Keyboard::Escape)
{
flag=false;
}
break;
// case ....
}
}
return flag;
}
void GameOver :: update()
{
// animations not linked to the user
}