Je ne suis pas sur de comprendre, mais j'ai bien défini au tout début du code, avant même int main() avec un sf::Event event; ainsi qu'un sf::Keyboard key; et visual studio que j'utilise ne me donne aucune erreur et me propose les termes à chaque fois donc je pense qu'au niveau du code on est bon. Si vous le souhaitez, je vous donne mon code complet juste en dessous, mais j'imagine bien que vous n'allez pas vous mettre à lire 2000 ligne de code. Je le met au cas ou...
#include "shape.h"
#pragma region Variables
sf::RenderWindow window;
sf::Texture texture_perso;
sf::Sprite sprite_perso;
sf::Texture texture_btnsound;
sf::Sprite sprite_btnsound;
sf::Texture texture_btnparametre;
sf::Sprite sprite_btnparametre;
enum Dir {jsp1_Up, jsp1_Left, jsp1_Down, jsp1_Right, jsp2_Up, jsp2_Left, jsp2_Down, jsp2_Right, Walk_Up, Walk_Left, Walk_Down, Walk_Right};
sf::Vector2i anim(1, Walk_Down);
sf::Vector2i anim_zombie1(1, Walk_Down);
sf::Vector2i anim_zombie2(1, Walk_Down);
sf::Vector2i anim_zombie3(1, Walk_Down);
sf::Vector2i anim_zombie4(1, Walk_Down);
sf::Vector2i anim_zombie5(1, Walk_Down);
bool updateanim_perso = true;
bool updateanim_zombie1 = true;
bool updateanim_zombie2 = true;
bool updateanim_zombie3 = true;
bool updateanim_zombie4 = true;
bool updateanim_zombie5 = true;
bool play = false;
bool choosename = false;
bool sound;
bool parametre = false;
bool parametre_fps = false;
bool parametre_windowmode = false;
bool lvl1 = false;
bool lvl2 = false;
bool lvl3 = false;
bool lvl4 = false;
bool lvl5 = false;
bool setpos = true;
sf::View view;
sf::RectangleShape putname;
sf::CircleShape btnPlay;
sf::CircleShape cercle_btnsound;
sf::Clock temps;
sf::Clock temps_zombie1;
sf::Clock temps_zombie2;
sf::Clock temps_zombie3;
sf::Clock temps_zombie4;
sf::Clock temps_zombie5;
sf::Font font;
sf::Text txt;
sf::Text pseudo;
sf::Mouse souris;
sf::Event event;
std::string name;
std::string fps1;
int fps2;
std::string sound1;
std::string namePlayer;
sf::ContextSettings settings;
sf::RectangleShape no_btnsound;
sf::CircleShape cercle_btnparametre;
sf::RectangleShape box_fps;
sf::RectangleShape box_windowmode;
sf::RectangleShape box_fps30;
sf::RectangleShape box_fps60;
sf::RectangleShape box_fps120;
sf::RectangleShape box_fps144;
sf::RectangleShape box_fps165;
sf::RectangleShape box_fps240;
sf::RectangleShape box_fps360;
sf::Text txtfps;
sf::Text txtwindowmode;
sf::Text txtfps30;
sf::Text txtfps60;
sf::Text txtfps120;
sf::Text txtfps144;
sf::Text txtfps165;
sf::Text txtfps240;
sf::Text txtfps360;
sf::CircleShape cercle_btnfleche;
sf::Texture texture_btnfleche;
sf::Sprite sprite_btnfleche;
sf::Keyboard key;
sf::Texture texture_zombie;
sf::Sprite sprite_zombie1;
sf::Sprite sprite_zombie2;
sf::Sprite sprite_zombie3;
sf::Sprite sprite_zombie4;
sf::Sprite sprite_zombie5;
std::random_device rd;
std::default_random_engine eng(rd());
std::uniform_int_distribution<int> distr1(1, 2);
std::uniform_int_distribution<int> distr2(1, 5);
int paszombie1 = distr2(eng),
paszombie2 = distr2(eng),
paszombie3 = distr2(eng),
paszombie4 = distr2(eng),
paszombie5 = distr2(eng),
i1 = 0,
i2 = 0,
i3 = 0,
i4 = 0,
i5 = 0,
dirzombie1 = distr1(eng),
dirzombie2 = distr1(eng),
dirzombie3 = distr1(eng),
dirzombie4 = distr1(eng),
dirzombie5 = distr1(eng);
sf::Texture texture_map1;
sf::Sprite sprite_map1;
#pragma endregion
#pragma region Fonctions
void mouvement()
{
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Up))
{
anim.y = Walk_Up;
sprite_perso.move(0, (-speed) * 144 / fps2);
pseudo.move(0, (-speed) * 144 / fps2);
updateanim_perso = true;
}
else if (sf::Keyboard::isKeyPressed(sf::Keyboard::Down))
{
anim.y = Walk_Down;
sprite_perso.move(0, speed * 144 / fps2);
pseudo.move(0, speed * 144 / fps2);
updateanim_perso = true;
}
else if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left))
{
anim.y = Walk_Left;
sprite_perso.move((-speed) * 144 / fps2, 0);
pseudo.move((-speed) * 144 / fps2, 0);
updateanim_perso = true;
}
else if (sf::Keyboard::isKeyPressed(sf::Keyboard::Right))
{
anim.y = Walk_Right;
sprite_perso.move(speed * 144 / fps2, 0);
pseudo.move(speed * 144 / fps2, 0);
updateanim_perso = true;
}
if (sprite_perso.getPosition().x <= 0)
sprite_perso.setPosition(sf::Vector2f(0, sprite_perso.getPosition().y));
if (pseudo.getPosition().x <= 32 - (pseudo.getGlobalBounds().getSize().x / 2))
pseudo.setPosition(sf::Vector2f(32 - (pseudo.getGlobalBounds().getSize().x / 2), pseudo.getPosition().y));
if (sprite_perso.getPosition().y <= 0)
sprite_perso.setPosition(sf::Vector2f(sprite_perso.getPosition().x, 0));
if (pseudo.getPosition().y <= 0)
pseudo.setPosition(sf::Vector2f(pseudo.getPosition().x, 0));
}
void animation()
{
if (updateanim_perso)
{
if (temps.getElapsedTime().asMilliseconds() >= 50)
{
anim.x++;
if (anim.x * 64 >= 560)
anim.x = 0;
temps.restart();
updateanim_perso = false;
}
}
}
void animation_zombie()
{
if (updateanim_zombie1)
{
if (temps_zombie1.getElapsedTime().asMilliseconds() >= 50)
{
anim_zombie1.x++;
if (anim_zombie1.x * 64 >= 560)
anim_zombie1.x = 0;
temps_zombie1.restart();
updateanim_zombie1 = false;
}
}
if (updateanim_zombie2)
{
if (temps_zombie2.getElapsedTime().asMilliseconds() >= 50)
{
anim_zombie2.x++;
if (anim_zombie2.x * 64 >= 560)
anim_zombie2.x = 0;
temps_zombie2.restart();
updateanim_zombie2 = false;
}
}
if (updateanim_zombie3)
{
if (temps_zombie3.getElapsedTime().asMilliseconds() >= 50)
{
anim_zombie3.x++;
if (anim_zombie3.x * 64 >= 560)
anim_zombie3.x = 0;
temps_zombie3.restart();
updateanim_zombie3 = false;
}
}
if (updateanim_zombie4)
{
if (temps_zombie4.getElapsedTime().asMilliseconds() >= 50)
{
anim_zombie4.x++;
if (anim_zombie4.x * 64 >= 560)
anim_zombie4.x = 0;
temps_zombie4.restart();
updateanim_zombie4 = false;
}
}
if (updateanim_zombie5)
{
if (temps_zombie5.getElapsedTime().asMilliseconds() >= 50)
{
anim_zombie5.x++;
if (anim_zombie5.x * 64 >= 560)
anim_zombie5.x = 0;
temps_zombie5.restart();
updateanim_zombie5 = false;
}
}
}
void mouvementIA()
{
#pragma region Mouvement zombie 1
if (paszombie1 * fps2 - i1 > 0)
{
i1 += 4;
if (dirzombie1 == 1)
{
if (sprite_perso.getPosition().x > sprite_zombie1.getPosition().x - 0)
{
sprite_zombie1.move(speed_zombie * 144 / fps2, 0);
anim_zombie1.y = Walk_Right;
updateanim_zombie1 = true;
}
else if (sprite_perso.getPosition().x < sprite_zombie1.getPosition().x - 0)
{
sprite_zombie1.move((-speed_zombie) * 144 / fps2, 0);
anim_zombie1.y = Walk_Left;
updateanim_zombie1 = true;
}
}
else
{
if (sprite_perso.getPosition().y > sprite_zombie1.getPosition().y - 0)
{
sprite_zombie1.move(0, speed_zombie * 144 / fps2);
anim_zombie1.y = Walk_Down;
updateanim_zombie1 = true;
}
else if (sprite_perso.getPosition().y < sprite_zombie1.getPosition().y - 0)
{
sprite_zombie1.move(0, (-speed_zombie) * 144 / fps2);
anim_zombie1.y = Walk_Up;
updateanim_zombie1 = true;
}
}
}
else
{
paszombie1 = distr2(eng);
dirzombie1 = distr1(eng);
i1 = 0;
}
#pragma endregion
#pragma region Mouvement zombie 2
if (paszombie2 * fps2 - i2 > 0)
{
i2 += 4;
if (dirzombie2 == 1)
{
if (sprite_perso.getPosition().x > sprite_zombie2.getPosition().x - 0)
{
sprite_zombie2.move(speed_zombie * 144 / fps2, 0);
anim_zombie2.y = Walk_Right;
updateanim_zombie2 = true;
}
else if (sprite_perso.getPosition().x < sprite_zombie2.getPosition().x - 0)
{
sprite_zombie2.move((-speed_zombie) * 144 / fps2, 0);
anim_zombie2.y = Walk_Left;
updateanim_zombie2 = true;
}
}
else
{
if (sprite_perso.getPosition().y > sprite_zombie2.getPosition().y - 0)
{
sprite_zombie2.move(0, speed_zombie * 144 / fps2);
anim_zombie2.y = Walk_Down;
updateanim_zombie2 = true;
}
else if (sprite_perso.getPosition().y < sprite_zombie2.getPosition().y - 0)
{
sprite_zombie2.move(0, (-speed_zombie) * 144 / fps2);
anim_zombie2.y = Walk_Up;
updateanim_zombie2 = true;
}
}
}
else
{
paszombie2 = distr2(eng);
dirzombie2 = distr1(eng);
i2 = 0;
}
#pragma endregion
#pragma region Mouvement zombie 3
if (paszombie3 * fps2 - i3 > 0)
{
i3 += 4;
if (dirzombie3 == 1)
{
if (sprite_perso.getPosition().x > sprite_zombie3.getPosition().x - 0)
{
sprite_zombie3.move(speed_zombie * 144 / fps2, 0);
anim_zombie3.y = Walk_Right;
updateanim_zombie3 = true;
}
else if (sprite_perso.getPosition().x < sprite_zombie3.getPosition().x - 0)
{
sprite_zombie3.move((-speed_zombie) * 144 / fps2, 0);
anim_zombie3.y = Walk_Left;
updateanim_zombie3 = true;
}
}
else
{
if (sprite_perso.getPosition().y > sprite_zombie3.getPosition().y - 0)
{
sprite_zombie3.move(0, speed_zombie * 144 / fps2);
anim_zombie3.y = Walk_Down;
updateanim_zombie3 = true;
}
else if (sprite_perso.getPosition().y < sprite_zombie3.getPosition().y - 0)
{
sprite_zombie3.move(0, (-speed_zombie) * 144 / fps2);
anim_zombie3.y = Walk_Up;
updateanim_zombie3 = true;
}
}
}
else
{
paszombie3 = distr2(eng);
dirzombie3 = distr1(eng);
i3 = 0;
}
#pragma endregion
#pragma region Mouvement zombie 4
if (paszombie4 * fps2 - i4 > 0)
{
i4 += 4;
if (dirzombie4 == 1)
{
if (sprite_perso.getPosition().x > sprite_zombie4.getPosition().x - 0)
{
sprite_zombie4.move(speed_zombie * 144 / fps2, 0);
anim_zombie4.y = Walk_Right;
updateanim_zombie4 = true;
}
else if (sprite_perso.getPosition().x < sprite_zombie4.getPosition().x - 0)
{
sprite_zombie4.move((-speed_zombie) * 144 / fps2, 0);
anim_zombie4.y = Walk_Left;
updateanim_zombie4 = true;
}
}
else
{
if (sprite_perso.getPosition().y > sprite_zombie4.getPosition().y - 0)
{
sprite_zombie4.move(0, speed_zombie * 144 / fps2);
anim_zombie4.y = Walk_Down;
updateanim_zombie4 = true;
}
else if (sprite_perso.getPosition().y < sprite_zombie4.getPosition().y - 0)
{
sprite_zombie4.move(0, (-speed_zombie) * 144 / fps2);
anim_zombie4.y = Walk_Up;
updateanim_zombie4 = true;
}
}
}
else
{
paszombie4 = distr2(eng);
dirzombie4 = distr1(eng);
i4 = 0;
}
#pragma endregion
#pragma region Mouvement zombie 5
if (paszombie5 * fps2 - i5 > 0)
{
i5 += 4;
if (dirzombie5 == 1)
{
if (sprite_perso.getPosition().x > sprite_zombie5.getPosition().x - 0)
{
sprite_zombie5.move(speed_zombie * 144 / fps2, 0);
anim_zombie5.y = Walk_Right;
updateanim_zombie5 = true;
}
else if (sprite_perso.getPosition().x < sprite_zombie5.getPosition().x - 0)
{
sprite_zombie5.move((-speed_zombie) * 144 / fps2, 0);
anim_zombie5.y = Walk_Left;
updateanim_zombie5 = true;
}
}
else
{
if (sprite_perso.getPosition().y > sprite_zombie5.getPosition().y - 0)
{
sprite_zombie5.move(0, speed_zombie * 144 / fps2);
anim_zombie5.y = Walk_Down;
updateanim_zombie5 = true;
}
else if (sprite_perso.getPosition().y < sprite_zombie5.getPosition().y - 0)
{
sprite_zombie5.move(0, (-speed_zombie) * 144 / fps2);
anim_zombie5.y = Walk_Up;
updateanim_zombie5 = true;
}
}
}
else
{
paszombie5 = distr2(eng);
dirzombie5 = distr1(eng);
i5 = 0;
}
#pragma endregion
}
void blockage()
{
if (lvl1)
{
if (sprite_perso.getPosition().y <= 100)
{
sprite_perso.setPosition(sf::Vector2f(sprite_perso.getPosition().x, 100));
pseudo.setPosition(sf::Vector2f(pseudo.getPosition().x, 100));
}
else if (sprite_perso.getPosition().y >= 910)
{
sprite_perso.setPosition(sf::Vector2f(sprite_perso.getPosition().x, 910));
pseudo.setPosition(sf::Vector2f(pseudo.getPosition().x, 910));
}
else if ((sprite_perso.getPosition().y <= 450) && (sprite_perso.getPosition().x <= 140))
{
sprite_perso.setPosition(sf::Vector2f(sprite_perso.getPosition().x, 450));
pseudo.setPosition(sf::Vector2f(pseudo.getPosition().x, 450));
}
else if ((sprite_perso.getPosition().y <= 450) && (sprite_perso.getPosition().x >= 1730))
{
sprite_perso.setPosition(sf::Vector2f(sprite_perso.getPosition().x, 450));
pseudo.setPosition(sf::Vector2f(pseudo.getPosition().x, 450));
}
else if ((sprite_perso.getPosition().y >= 560) && (sprite_perso.getPosition().x <= 140))
{
sprite_perso.setPosition(sf::Vector2f(sprite_perso.getPosition().x, 560));
pseudo.setPosition(sf::Vector2f(pseudo.getPosition().x, 560));
}
else if ((sprite_perso.getPosition().y >= 560) && (sprite_perso.getPosition().x >= 1730))
{
sprite_perso.setPosition(sf::Vector2f(sprite_perso.getPosition().x, 560));
pseudo.setPosition(sf::Vector2f(pseudo.getPosition().x, 560));
}
else if ((sprite_perso.getPosition().y >= 330) && (sprite_perso.getPosition().y <= 360) && (sprite_perso.getPosition().x >= 780) && (sprite_perso.getPosition().x <= 1080))
{
sprite_perso.setPosition(sf::Vector2f(sprite_perso.getPosition().x, 330));
pseudo.setPosition(sf::Vector2f(pseudo.getPosition().x, 330));
}
else if ((sprite_perso.getPosition().y <= 680) && (sprite_perso.getPosition().y >= 650) && (sprite_perso.getPosition().x >= 790) && (sprite_perso.getPosition().x <= 1080))
{
sprite_perso.setPosition(sf::Vector2f(sprite_perso.getPosition().x, 680));
pseudo.setPosition(sf::Vector2f(pseudo.getPosition().x, 680));
}
else if ((sprite_perso.getPosition().y >= 340) && (sprite_perso.getPosition().y <= 680) && (sprite_perso.getPosition().x >= 770) && (sprite_perso.getPosition().x <= 920))
{
sprite_perso.setPosition(sf::Vector2f(770, sprite_perso.getPosition().y));
pseudo.setPosition(sf::Vector2f(802 - (pseudo.getGlobalBounds().getSize().x / 2), pseudo.getPosition().y));
}
else if ((sprite_perso.getPosition().y >= 330) && (sprite_perso.getPosition().y <= 670) && (sprite_perso.getPosition().x >= 1000) && (sprite_perso.getPosition().x <= 1090))
{
sprite_perso.setPosition(sf::Vector2f(1090, sprite_perso.getPosition().y));
pseudo.setPosition(sf::Vector2f(1122 - (pseudo.getGlobalBounds().getSize().x / 2), pseudo.getPosition().y));
}
if ((sprite_perso.getPosition().y <= 440) && (sprite_perso.getPosition().x <= 160))
{
sprite_perso.setPosition(sf::Vector2f(160, sprite_perso.getPosition().y));
pseudo.setPosition(192 - (pseudo.getGlobalBounds().getSize().x / 2), pseudo.getPosition().y);
}
if ((sprite_perso.getPosition().y <= 440) && (sprite_perso.getPosition().x >= 1700))
{
sprite_perso.setPosition(sf::Vector2f(1700, sprite_perso.getPosition().y));
pseudo.setPosition(1732 - (pseudo.getGlobalBounds().getSize().x / 2), pseudo.getPosition().y);
}
if ((sprite_perso.getPosition().y >= 570) && (sprite_perso.getPosition().x <= 160))
{
sprite_perso.setPosition(sf::Vector2f(160, sprite_perso.getPosition().y));
pseudo.setPosition(192 - (pseudo.getGlobalBounds().getSize().x / 2), pseudo.getPosition().y);
}
if ((sprite_perso.getPosition().y >= 570) && (sprite_perso.getPosition().x >= 1700))
{
sprite_perso.setPosition(sf::Vector2f(1700, sprite_perso.getPosition().y));
pseudo.setPosition(1732 - (pseudo.getGlobalBounds().getSize().x / 2), pseudo.getPosition().y);
}
if (sprite_zombie1.getPosition().y <= 100)
{
sprite_zombie1.setPosition(sf::Vector2f(sprite_zombie1.getPosition().x, 100));
}
else if (sprite_zombie1.getPosition().y >= 910)
{
sprite_zombie1.setPosition(sf::Vector2f(sprite_zombie1.getPosition().x, 910));
}
else if ((sprite_zombie1.getPosition().y <= 450) && (sprite_zombie1.getPosition().x <= 140))
{
sprite_zombie1.setPosition(sf::Vector2f(sprite_zombie1.getPosition().x, 450));
}
else if ((sprite_zombie1.getPosition().y <= 450) && (sprite_zombie1.getPosition().x >= 1730))
{
sprite_zombie1.setPosition(sf::Vector2f(sprite_zombie1.getPosition().x, 450));
}
else if ((sprite_zombie1.getPosition().y >= 560) && (sprite_zombie1.getPosition().x <= 140))
{
sprite_zombie1.setPosition(sf::Vector2f(sprite_zombie1.getPosition().x, 560));
}
else if ((sprite_zombie1.getPosition().y >= 560) && (sprite_zombie1.getPosition().x >= 1730))
{
sprite_zombie1.setPosition(sf::Vector2f(sprite_zombie1.getPosition().x, 560));
}
else if ((sprite_zombie1.getPosition().y >= 330) && (sprite_zombie1.getPosition().y <= 360) && (sprite_zombie1.getPosition().x >= 780) && (sprite_zombie1.getPosition().x <= 1080))
{
sprite_zombie1.setPosition(sf::Vector2f(sprite_zombie1.getPosition().x, 330));
}
else if ((sprite_zombie1.getPosition().y <= 680) && (sprite_zombie1.getPosition().y >= 650) && (sprite_zombie1.getPosition().x >= 790) && (sprite_zombie1.getPosition().x <= 1080))
{
sprite_zombie1.setPosition(sf::Vector2f(sprite_zombie1.getPosition().x, 680));
}
else if ((sprite_zombie1.getPosition().y >= 340) && (sprite_zombie1.getPosition().y <= 680) && (sprite_zombie1.getPosition().x >= 770) && (sprite_zombie1.getPosition().x <= 920))
{
sprite_zombie1.setPosition(sf::Vector2f(770, sprite_zombie1.getPosition().y));
}
else if ((sprite_zombie1.getPosition().y >= 330) && (sprite_zombie1.getPosition().y <= 670) && (sprite_zombie1.getPosition().x >= 1000) && (sprite_zombie1.getPosition().x <= 1090))
{
sprite_zombie1.setPosition(sf::Vector2f(1090, sprite_zombie1.getPosition().y));
}
if ((sprite_zombie1.getPosition().y <= 440) && (sprite_zombie1.getPosition().x <= 160))
{
sprite_zombie1.setPosition(sf::Vector2f(160, sprite_zombie1.getPosition().y));
}
if ((sprite_zombie1.getPosition().y <= 440) && (sprite_zombie1.getPosition().x >= 1700))
{
sprite_zombie1.setPosition(sf::Vector2f(1700, sprite_zombie1.getPosition().y));
}
if ((sprite_zombie1.getPosition().y >= 570) && (sprite_zombie1.getPosition().x <= 160))
{
sprite_zombie1.setPosition(sf::Vector2f(160, sprite_zombie1.getPosition().y));
}
if ((sprite_zombie1.getPosition().y >= 570) && (sprite_zombie1.getPosition().x >= 1700))
{
sprite_zombie1.setPosition(sf::Vector2f(1700, sprite_zombie1.getPosition().y));
}
if (sprite_zombie2.getPosition().y <= 100)
{
sprite_zombie2.setPosition(sf::Vector2f(sprite_zombie2.getPosition().x, 100));
}
else if (sprite_zombie2.getPosition().y >= 910)
{
sprite_zombie2.setPosition(sf::Vector2f(sprite_zombie2.getPosition().x, 910));
}
else if ((sprite_zombie2.getPosition().y <= 450) && (sprite_zombie2.getPosition().x <= 140))
{
sprite_zombie2.setPosition(sf::Vector2f(sprite_zombie2.getPosition().x, 450));
}
else if ((sprite_zombie2.getPosition().y <= 450) && (sprite_zombie2.getPosition().x >= 1730))
{
sprite_zombie2.setPosition(sf::Vector2f(sprite_zombie2.getPosition().x, 450));
}
else if ((sprite_zombie2.getPosition().y >= 560) && (sprite_zombie2.getPosition().x <= 140))
{
sprite_zombie2.setPosition(sf::Vector2f(sprite_zombie2.getPosition().x, 560));
}
else if ((sprite_zombie2.getPosition().y >= 560) && (sprite_zombie2.getPosition().x >= 1730))
{
sprite_zombie2.setPosition(sf::Vector2f(sprite_zombie2.getPosition().x, 560));
}
else if ((sprite_zombie2.getPosition().y >= 330) && (sprite_zombie2.getPosition().y <= 360) && (sprite_zombie2.getPosition().x >= 780) && (sprite_zombie2.getPosition().x <= 1080))
{
sprite_zombie2.setPosition(sf::Vector2f(sprite_zombie2.getPosition().x, 330));
}
else if ((sprite_zombie2.getPosition().y <= 680) && (sprite_zombie2.getPosition().y >= 650) && (sprite_zombie2.getPosition().x >= 790) && (sprite_zombie2.getPosition().x <= 1080))
{
sprite_zombie2.setPosition(sf::Vector2f(sprite_zombie2.getPosition().x, 680));
}
else if ((sprite_zombie2.getPosition().y >= 340) && (sprite_zombie2.getPosition().y <= 680) && (sprite_zombie2.getPosition().x >= 770) && (sprite_zombie2.getPosition().x <= 920))
{
sprite_zombie2.setPosition(sf::Vector2f(770, sprite_zombie2.getPosition().y));
}
else if ((sprite_zombie2.getPosition().y >= 330) && (sprite_zombie2.getPosition().y <= 670) && (sprite_zombie2.getPosition().x >= 1000) && (sprite_zombie2.getPosition().x <= 1090))
{
sprite_zombie2.setPosition(sf::Vector2f(1090, sprite_zombie2.getPosition().y));
}
if ((sprite_zombie2.getPosition().y <= 440) && (sprite_zombie2.getPosition().x <= 160))
{
sprite_zombie2.setPosition(sf::Vector2f(160, sprite_zombie2.getPosition().y));
}
if ((sprite_zombie2.getPosition().y <= 440) && (sprite_zombie2.getPosition().x >= 1700))
{
sprite_zombie2.setPosition(sf::Vector2f(1700, sprite_zombie2.getPosition().y));
}
if ((sprite_zombie2.getPosition().y >= 570) && (sprite_zombie2.getPosition().x <= 160))
{
sprite_zombie2.setPosition(sf::Vector2f(160, sprite_zombie2.getPosition().y));
}
if ((sprite_zombie2.getPosition().y >= 570) && (sprite_zombie2.getPosition().x >= 1700))
{
sprite_zombie2.setPosition(sf::Vector2f(1700, sprite_zombie2.getPosition().y));
}
if (sprite_zombie3.getPosition().y <= 100)
{
sprite_zombie3.setPosition(sf::Vector2f(sprite_zombie3.getPosition().x, 100));
}
else if (sprite_zombie3.getPosition().y >= 910)
{
sprite_zombie3.setPosition(sf::Vector2f(sprite_zombie3.getPosition().x, 910));
}
else if ((sprite_zombie3.getPosition().y <= 450) && (sprite_zombie3.getPosition().x <= 140))
{
sprite_zombie3.setPosition(sf::Vector2f(sprite_zombie3.getPosition().x, 450));
}
else if ((sprite_zombie3.getPosition().y <= 450) && (sprite_zombie3.getPosition().x >= 1730))
{
sprite_zombie3.setPosition(sf::Vector2f(sprite_zombie3.getPosition().x, 450));
}
else if ((sprite_zombie3.getPosition().y >= 560) && (sprite_zombie3.getPosition().x <= 140))
{
sprite_zombie3.setPosition(sf::Vector2f(sprite_zombie3.getPosition().x, 560));
}
else if ((sprite_zombie3.getPosition().y >= 560) && (sprite_zombie3.getPosition().x >= 1730))
{
sprite_zombie3.setPosition(sf::Vector2f(sprite_zombie3.getPosition().x, 560));
}
else if ((sprite_zombie3.getPosition().y >= 330) && (sprite_zombie3.getPosition().y <= 360) && (sprite_zombie3.getPosition().x >= 780) && (sprite_zombie3.getPosition().x <= 1080))
{
sprite_zombie3.setPosition(sf::Vector2f(sprite_zombie3.getPosition().x, 330));
}
else if ((sprite_zombie3.getPosition().y <= 680) && (sprite_zombie3.getPosition().y >= 650) && (sprite_zombie3.getPosition().x >= 790) && (sprite_zombie3.getPosition().x <= 1080))
{
sprite_zombie3.setPosition(sf::Vector2f(sprite_zombie3.getPosition().x, 680));
}
else if ((sprite_zombie3.getPosition().y >= 340) && (sprite_zombie3.getPosition().y <= 680) && (sprite_zombie3.getPosition().x >= 770) && (sprite_zombie3.getPosition().x <= 920))
{
sprite_zombie3.setPosition(sf::Vector2f(770, sprite_zombie3.getPosition().y));
}
else if ((sprite_zombie3.getPosition().y >= 330) && (sprite_zombie3.getPosition().y <= 670) && (sprite_zombie3.getPosition().x >= 1000) && (sprite_zombie3.getPosition().x <= 1090))
{
sprite_zombie3.setPosition(sf::Vector2f(1090, sprite_zombie3.getPosition().y));
}
if ((sprite_zombie3.getPosition().y <= 440) && (sprite_zombie3.getPosition().x <= 160))
{
sprite_zombie3.setPosition(sf::Vector2f(160, sprite_zombie3.getPosition().y));
}
if ((sprite_zombie3.getPosition().y <= 440) && (sprite_zombie3.getPosition().x >= 1700))
{
sprite_zombie3.setPosition(sf::Vector2f(1700, sprite_zombie3.getPosition().y));
}
if ((sprite_zombie3.getPosition().y >= 570) && (sprite_zombie3.getPosition().x <= 160))
{
sprite_zombie3.setPosition(sf::Vector2f(160, sprite_zombie3.getPosition().y));
}
if ((sprite_zombie3.getPosition().y >= 570) && (sprite_zombie3.getPosition().x >= 1700))
{
sprite_zombie3.setPosition(sf::Vector2f(1700, sprite_zombie3.getPosition().y));
}
if (sprite_zombie4.getPosition().y <= 100)
{
sprite_zombie4.setPosition(sf::Vector2f(sprite_zombie4.getPosition().x, 100));
}
else if (sprite_zombie4.getPosition().y >= 910)
{
sprite_zombie4.setPosition(sf::Vector2f(sprite_zombie4.getPosition().x, 910));
}
else if ((sprite_zombie4.getPosition().y <= 450) && (sprite_zombie4.getPosition().x <= 140))
{
sprite_zombie4.setPosition(sf::Vector2f(sprite_zombie4.getPosition().x, 450));
}
else if ((sprite_zombie4.getPosition().y <= 450) && (sprite_zombie4.getPosition().x >= 1730))
{
sprite_zombie4.setPosition(sf::Vector2f(sprite_zombie4.getPosition().x, 450));
}
else if ((sprite_zombie4.getPosition().y >= 560) && (sprite_zombie4.getPosition().x <= 140))
{
sprite_zombie4.setPosition(sf::Vector2f(sprite_zombie4.getPosition().x, 560));
}
else if ((sprite_zombie4.getPosition().y >= 560) && (sprite_zombie4.getPosition().x >= 1730))
{
sprite_zombie4.setPosition(sf::Vector2f(sprite_zombie4.getPosition().x, 560));
}
else if ((sprite_zombie4.getPosition().y >= 330) && (sprite_zombie4.getPosition().y <= 360) && (sprite_zombie4.getPosition().x >= 780) && (sprite_zombie4.getPosition().x <= 1080))
{
sprite_zombie4.setPosition(sf::Vector2f(sprite_zombie4.getPosition().x, 330));
}
else if ((sprite_zombie4.getPosition().y <= 680) && (sprite_zombie4.getPosition().y >= 650) && (sprite_zombie4.getPosition().x >= 790) && (sprite_zombie4.getPosition().x <= 1080))
{
sprite_zombie4.setPosition(sf::Vector2f(sprite_zombie4.getPosition().x, 680));
}
else if ((sprite_zombie4.getPosition().y >= 340) && (sprite_zombie4.getPosition().y <= 680) && (sprite_zombie4.getPosition().x >= 770) && (sprite_zombie4.getPosition().x <= 920))
{
sprite_zombie4.setPosition(sf::Vector2f(770, sprite_zombie4.getPosition().y));
}
else if ((sprite_zombie4.getPosition().y >= 330) && (sprite_zombie4.getPosition().y <= 670) && (sprite_zombie4.getPosition().x >= 1000) && (sprite_zombie4.getPosition().x <= 1090))
{
sprite_zombie4.setPosition(sf::Vector2f(1090, sprite_zombie4.getPosition().y));
}
if ((sprite_zombie4.getPosition().y <= 440) && (sprite_zombie4.getPosition().x <= 160))
{
sprite_zombie4.setPosition(sf::Vector2f(160, sprite_zombie4.getPosition().y));
}
if ((sprite_zombie4.getPosition().y <= 440) && (sprite_zombie4.getPosition().x >= 1700))
{
sprite_zombie4.setPosition(sf::Vector2f(1700, sprite_zombie4.getPosition().y));
}
if ((sprite_zombie4.getPosition().y >= 570) && (sprite_zombie4.getPosition().x <= 160))
{
sprite_zombie4.setPosition(sf::Vector2f(160, sprite_zombie4.getPosition().y));
}
if ((sprite_zombie4.getPosition().y >= 570) && (sprite_zombie4.getPosition().x >= 1700))
{
sprite_zombie4.setPosition(sf::Vector2f(1700, sprite_zombie4.getPosition().y));
}
if (sprite_zombie5.getPosition().y <= 100)
{
sprite_zombie5.setPosition(sf::Vector2f(sprite_zombie5.getPosition().x, 100));
}
else if (sprite_zombie5.getPosition().y >= 910)
{
sprite_zombie5.setPosition(sf::Vector2f(sprite_zombie5.getPosition().x, 910));
}
else if ((sprite_zombie5.getPosition().y <= 450) && (sprite_zombie5.getPosition().x <= 140))
{
sprite_zombie5.setPosition(sf::Vector2f(sprite_zombie5.getPosition().x, 450));
}
else if ((sprite_zombie5.getPosition().y <= 450) && (sprite_zombie5.getPosition().x >= 1730))
{
sprite_zombie5.setPosition(sf::Vector2f(sprite_zombie5.getPosition().x, 450));
}
else if ((sprite_zombie5.getPosition().y >= 560) && (sprite_zombie5.getPosition().x <= 140))
{
sprite_zombie5.setPosition(sf::Vector2f(sprite_zombie5.getPosition().x, 560));
}
else if ((sprite_zombie5.getPosition().y >= 560) && (sprite_zombie5.getPosition().x >= 1730))
{
sprite_zombie5.setPosition(sf::Vector2f(sprite_zombie5.getPosition().x, 560));
}
else if ((sprite_zombie5.getPosition().y >= 330) && (sprite_zombie5.getPosition().y <= 360) && (sprite_zombie5.getPosition().x >= 780) && (sprite_zombie5.getPosition().x <= 1080))
{
sprite_zombie5.setPosition(sf::Vector2f(sprite_zombie5.getPosition().x, 330));
}
else if ((sprite_zombie5.getPosition().y <= 680) && (sprite_zombie5.getPosition().y >= 650) && (sprite_zombie5.getPosition().x >= 790) && (sprite_zombie5.getPosition().x <= 1080))
{
sprite_zombie5.setPosition(sf::Vector2f(sprite_zombie5.getPosition().x, 680));
}
else if ((sprite_zombie5.getPosition().y >= 340) && (sprite_zombie5.getPosition().y <= 680) && (sprite_zombie5.getPosition().x >= 770) && (sprite_zombie5.getPosition().x <= 920))
{
sprite_zombie5.setPosition(sf::Vector2f(770, sprite_zombie5.getPosition().y));
}
else if ((sprite_zombie5.getPosition().y >= 330) && (sprite_zombie5.getPosition().y <= 670) && (sprite_zombie5.getPosition().x >= 1000) && (sprite_zombie5.getPosition().x <= 1090))
{
sprite_zombie5.setPosition(sf::Vector2f(1090, sprite_zombie5.getPosition().y));
}
if ((sprite_zombie5.getPosition().y <= 440) && (sprite_zombie5.getPosition().x <= 160))
{
sprite_zombie5.setPosition(sf::Vector2f(160, sprite_zombie5.getPosition().y));
}
if ((sprite_zombie5.getPosition().y <= 440) && (sprite_zombie5.getPosition().x >= 1700))
{
sprite_zombie5.setPosition(sf::Vector2f(1700, sprite_zombie5.getPosition().y));
}
if ((sprite_zombie5.getPosition().y >= 570) && (sprite_zombie5.getPosition().x <= 160))
{
sprite_zombie5.setPosition(sf::Vector2f(160, sprite_zombie5.getPosition().y));
}
if ((sprite_zombie5.getPosition().y >= 570) && (sprite_zombie5.getPosition().x >= 1700))
{
sprite_zombie5.setPosition(sf::Vector2f(1700, sprite_zombie5.getPosition().y));
}
}
}
#pragma endregion
int main()
{
#pragma region Chargement jeu
#pragma region Chargement de la sauvegarde
std::cout << "Chargement de la sauvevegarde..." << std::endl;
std::ifstream fichierSauvegarde("usersettings.txt");
if (fichierSauvegarde)
std::cout << "Chargement de la sauvegarde reussie" << std::endl;
else
std::cout << "Erreur de chargement de la sauvegarde" << std::endl;
fichierSauvegarde.seekg(9, std::ios::beg);
std::getline(fichierSauvegarde, name);
fichierSauvegarde.seekg(6, std::ios::cur);
std::getline(fichierSauvegarde, fps1);
std::istringstream iss2(fps1);
iss2 >> fps2;
fichierSauvegarde.seekg(8, std::ios::cur);
std::getline(fichierSauvegarde, sound1);
if (sound1.compare("true") == 0)
sound = true;
else
sound = false;
lvl1 = true;
fichierSauvegarde.close();
#pragma endregion
#pragma region Parametrage de la fenetre
std::cout << "Parametrage de la fenetre..." << std::endl;
settings.antialiasingLevel = 16;
settings.depthBits = 24;
settings.stencilBits = 8;
window.create(sf::VideoMode(screenW, screenH), "Jeu vidéo", sf::Style::Fullscreen, settings);
window.setFramerateLimit(fps2);
window.setKeyRepeatEnabled(false);
#pragma endregion
#pragma region Parametrage des objets
std::cout << "Parametrage des objets..." << std::endl;
putname = PB_Rect((screenW / 2) - 350, 180, 700, 100, 0, 0, 0);
putname.setOutlineColor(sf::Color::White);
putname.setOutlineThickness(4);
btnPlay = PB_Circle((screenW / 2) + 50, (screenH / 2), 50, 3, 255, 0, 0);
btnPlay.setRotation(90);
box_fps = PB_Rect(0, 0, 400, 80, 0, 0, 0);
box_fps.setOutlineColor(sf::Color::White);
box_fps.setOutlineThickness(4);
box_fps.setPosition(sf::Vector2f((screenW / 2) - (box_fps.getGlobalBounds().getSize().x / 2), 300));
box_windowmode = PB_Rect(0, 0, 400, 80, 0, 0, 0);
box_windowmode.setOutlineColor(sf::Color::White);
box_windowmode.setOutlineThickness(4);
box_windowmode.setPosition(sf::Vector2f((screenW / 2) - (box_windowmode.getGlobalBounds().getSize().x / 2), 400));
box_fps30 = PB_Rect(0, 0, 400, 80, 0, 0, 0);
box_fps30.setOutlineColor(sf::Color::White);
box_fps30.setOutlineThickness(4);
box_fps30.setPosition(sf::Vector2f((screenW / 2) - (box_fps30.getGlobalBounds().getSize().x / 2), 200));
box_fps60 = PB_Rect(0, 0, 400, 80, 0, 0, 0);
box_fps60.setOutlineColor(sf::Color::White);
box_fps60.setOutlineThickness(4);
box_fps60.setPosition(sf::Vector2f((screenW / 2) - (box_fps60.getGlobalBounds().getSize().x / 2), 300));
box_fps120 = PB_Rect(0, 0, 400, 80, 0, 0, 0);
box_fps120.setOutlineColor(sf::Color::White);
box_fps120.setOutlineThickness(4);
box_fps120.setPosition(sf::Vector2f((screenW / 2) - (box_fps120.getGlobalBounds().getSize().x / 2), 400));
box_fps144 = PB_Rect(0, 0, 400, 80, 0, 0, 0);
box_fps144.setOutlineColor(sf::Color::White);
box_fps144.setOutlineThickness(4);
box_fps144.setPosition(sf::Vector2f((screenW / 2) - (box_fps144.getGlobalBounds().getSize().x / 2), 500));
box_fps165 = PB_Rect(0, 0, 400, 80, 0, 0, 0);
box_fps165.setOutlineColor(sf::Color::White);
box_fps165.setOutlineThickness(4);
box_fps165.setPosition(sf::Vector2f((screenW / 2) - (box_fps165.getGlobalBounds().getSize().x / 2), 600));
box_fps240 = PB_Rect(0, 0, 400, 80, 0, 0, 0);
box_fps240.setOutlineColor(sf::Color::White);
box_fps240.setOutlineThickness(4);
box_fps240.setPosition(sf::Vector2f((screenW / 2) - (box_fps240.getGlobalBounds().getSize().x / 2), 700));
box_fps360 = PB_Rect(0, 0, 400, 80, 0, 0, 0);
box_fps360.setOutlineColor(sf::Color::White);
box_fps360.setOutlineThickness(4);
box_fps360.setPosition(sf::Vector2f((screenW / 2) - (box_fps360.getGlobalBounds().getSize().x / 2), 800));
#pragma endregion
#pragma region Chargement des textures
std::cout << "Chargement des textures..." << std::endl;
if (!texture_perso.loadFromFile("graph/image_perso.png"))
std::cout << "Erreur du chargement du personnage" << std::endl;
else
std::cout << "Chargement du personnage reussie" << std::endl;
if (!texture_zombie.loadFromFile("graph/image_zombie.png"))
std::cout << "Erreur du chargement du zombie" << std::endl;
else
std::cout << "Chargement du zombie reussie" << std::endl;
if (!texture_btnsound.loadFromFile("graph/btnsound.png"))
std::cout << "Erreur du chargement du boutton son" << std::endl;
else
std::cout << "Chargement du boutton son reussie" << std::endl;
if (!texture_btnparametre.loadFromFile("graph/btnparametre.png"))
std::cout << "Erreur du chargement du boutton parametre" << std::endl;
else
std::cout << "Chargement du boutton parametre reussie" << std::endl;
if (!texture_btnfleche.loadFromFile("graph/btnfleche.png"))
std::cout << "Ereur du chargement du boutton retour" << std::endl;
else
std::cout << "Chargement du boutton retour reussie" << std::endl;
if (!texture_map1.loadFromFile("graph/map_lvl1.png"))
std::cout << "Erreur du chargement de la map lvl 1" << std::endl;
else
std::cout << "Chargement de la map lvl 1 reussie" << std::endl;
#pragma endregion
#pragma region Parametrage des textures
std::cout << "Parametrage des textures..." << std::endl;
texture_perso.setSmooth(true);
sprite_perso.setTexture(texture_perso);
texture_zombie.setSmooth(true);
sprite_zombie1.setTexture(texture_zombie);
sprite_zombie2.setTexture(texture_zombie);
sprite_zombie3.setTexture(texture_zombie);
sprite_zombie4.setTexture(texture_zombie);
sprite_zombie5.setTexture(texture_zombie);
cercle_btnparametre = PB_Circle(0, 0, 40, 100, 0, 0, 0);
cercle_btnparametre.setOutlineColor(sf::Color::White);
cercle_btnparametre.setOutlineThickness(3);
cercle_btnparametre.setPosition(sf::Vector2f(screenW - cercle_btnparametre.getGlobalBounds().getSize().x - cercle_btnparametre.getOutlineThickness() - marge, 100));
texture_btnparametre.setSmooth(true);
sprite_btnparametre.setTexture(texture_btnparametre);
sprite_btnparametre.setScale(sf::Vector2f(0.058, 0.058));
sprite_btnparametre.setPosition(sf::Vector2f(cercle_btnparametre.getPosition().x + (cercle_btnparametre.getGlobalBounds().getSize().x / 2) - (sprite_btnparametre.getGlobalBounds().getSize().x / 2) - 2, cercle_btnparametre.getPosition().y + (cercle_btnparametre.getGlobalBounds().getSize().y / 2) - (sprite_btnparametre.getGlobalBounds().getSize().y / 2) - 3));
cercle_btnsound = PB_Circle(0, 0, 40, 100, 0, 0, 0);
cercle_btnsound.setOutlineColor(sf::Color::White);
cercle_btnsound.setOutlineThickness(3);
cercle_btnsound.setPosition(sf::Vector2f(screenW - cercle_btnsound.getGlobalBounds().getSize().x - cercle_btnsound.getOutlineThickness() - marge, 200));
texture_btnsound.setSmooth(true);
sprite_btnsound.setTexture(texture_btnsound);
sprite_btnsound.setScale(sf::Vector2f(0.1, 0.1));
sprite_btnsound.setPosition(sf::Vector2f(cercle_btnsound.getPosition().x + (cercle_btnsound.getGlobalBounds().getSize().x / 2) - (sprite_btnsound.getGlobalBounds().getSize().x / 2) - 2, cercle_btnsound.getPosition().y + (cercle_btnsound.getGlobalBounds().getSize().y / 2) - (sprite_btnsound.getGlobalBounds().getSize().y / 2) - 3));
no_btnsound = PB_Rect(sprite_btnsound.getPosition().x + 3, sprite_btnsound.getPosition().y - 11, 80, 4, 255, 255, 255);
no_btnsound.setRotation(60);
cercle_btnfleche = PB_Circle(marge, 100, 40, 100, 0, 0, 0);
cercle_btnfleche.setOutlineColor(sf::Color::White);
cercle_btnfleche.setOutlineThickness(3);
texture_btnfleche.setSmooth(true);
sprite_btnfleche.setTexture(texture_btnfleche);
sprite_btnfleche.setScale(sf::Vector2f(0.1, 0.1));
sprite_btnfleche.setPosition(sf::Vector2f(cercle_btnfleche.getPosition().x + (cercle_btnfleche.getGlobalBounds().getSize().x / 2) - (sprite_btnfleche.getGlobalBounds().getSize().x / 2) - 3, cercle_btnfleche.getPosition().y + (cercle_btnfleche.getGlobalBounds().getSize().y / 2) - (sprite_btnfleche.getGlobalBounds().getSize().y / 2) - 5));
texture_map1.setSmooth(true);
sprite_map1.setTexture(texture_map1);
#pragma endregion
#pragma region Chargement de la police
std::cout << "Chargement de la police..." << std::endl;
if (!font.loadFromFile("font/Poppins-Regular.ttf"))
std::cout << "Erreur de chargement de la police" << std::endl;
else
std::cout << "Chargement de la police reussie" << std::endl;
#pragma endregion
#pragma region Parametrage de la police
std::cout << "Parametrage de la police..." << std::endl;
txt.setFont(font);
txt.setString(name);
txt.setCharacterSize(30);
txt.setFillColor(sf::Color::White);
txt.setPosition(sf::Vector2f((screenW / 2) - (txt.getGlobalBounds().getSize().x / 2), 210));
pseudo.setFont(font);
pseudo.setString(name);
pseudo.setCharacterSize(10);
pseudo.setFillColor(sf::Color::White);
pseudo.setPosition(sf::Vector2f(sprite_perso.getPosition().x + 32 - (pseudo.getGlobalBounds().getSize().x / 2), sprite_perso.getPosition().y));
txtfps.setFont(font);
txtfps.setString("FramerateLimite");
txtfps.setCharacterSize(30);
txtfps.setFillColor(sf::Color::White);
txtfps.setPosition(sf::Vector2f(box_fps.getPosition().x + (box_fps.getGlobalBounds().getSize().x / 2) - (txtfps.getGlobalBounds().getSize().x / 2), 320));
txtwindowmode.setFont(font);
txtwindowmode.setString("Window mode");
txtwindowmode.setCharacterSize(30);
txtwindowmode.setFillColor(sf::Color::White);
txtwindowmode.setPosition(sf::Vector2f(box_windowmode.getPosition().x + (box_windowmode.getGlobalBounds().getSize().x / 2) - (txtwindowmode.getGlobalBounds().getSize().x / 2), 420));
txtfps30.setFont(font);
txtfps30.setString("30");
txtfps30.setCharacterSize(30);
txtfps30.setFillColor(sf::Color::White);
txtfps30.setPosition(sf::Vector2f(box_fps30.getPosition().x + (box_fps30.getGlobalBounds().getSize().x / 2) - (txtfps30.getGlobalBounds().getSize().x / 2), 220));
txtfps60.setFont(font);
txtfps60.setString("60");
txtfps60.setCharacterSize(30);
txtfps60.setFillColor(sf::Color::White);
txtfps60.setPosition(sf::Vector2f(box_fps60.getPosition().x + (box_fps60.getGlobalBounds().getSize().x / 2) - (txtfps60.getGlobalBounds().getSize().x / 2), 320));
txtfps120.setFont(font);
txtfps120.setString("120");
txtfps120.setCharacterSize(30);
txtfps120.setFillColor(sf::Color::White);
txtfps120.setPosition(sf::Vector2f(box_fps120.getPosition().x + (box_fps120.getGlobalBounds().getSize().x / 2) - (txtfps120.getGlobalBounds().getSize().x / 2), 420));
txtfps144.setFont(font);
txtfps144.setString("144");
txtfps144.setCharacterSize(30);
txtfps144.setFillColor(sf::Color::White);
txtfps144.setPosition(sf::Vector2f(box_fps144.getPosition().x + (box_fps144.getGlobalBounds().getSize().x / 2) - (txtfps144.getGlobalBounds().getSize().x / 2), 520));
txtfps165.setFont(font);
txtfps165.setString("165");
txtfps165.setCharacterSize(30);
txtfps165.setFillColor(sf::Color::White);
txtfps165.setPosition(sf::Vector2f(box_fps165.getPosition().x + (box_fps165.getGlobalBounds().getSize().x / 2) - (txtfps165.getGlobalBounds().getSize().x / 2), 620));
txtfps240.setFont(font);
txtfps240.setString("240");
txtfps240.setCharacterSize(30);
txtfps240.setFillColor(sf::Color::White);
txtfps240.setPosition(sf::Vector2f(box_fps240.getPosition().x + (box_fps240.getGlobalBounds().getSize().x / 2) - (txtfps240.getGlobalBounds().getSize().x / 2), 720));
txtfps360.setFont(font);
txtfps360.setString("360");
txtfps360.setCharacterSize(30);
txtfps360.setFillColor(sf::Color::White);
txtfps360.setPosition(sf::Vector2f(box_fps360.getPosition().x + (box_fps360.getGlobalBounds().getSize().x / 2) - (txtfps360.getGlobalBounds().getSize().x / 2), 820));
#pragma endregion
std::cout << "Parametrage terminer" << std::endl;
std::cout << "Lancement du jeu !" << std::endl;
#pragma endregion
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
{
namePlayer = txt.getString();
std::ofstream fichierSauvegarde("userSettings.txt");
if (!fichierSauvegarde)
{
std::cout << "Impossible de sauvegarder" << std::endl;
}
else
{
if (namePlayer != "Entrer votre nom...")
fichierSauvegarde << "Pseudo = " << namePlayer << std::endl;
else
fichierSauvegarde << "Pseudo = Entrer votre nom..." << std::endl;
fichierSauvegarde << "FPS = " << fps2 << std::endl;
if (sound)
fichierSauvegarde << "Sound = true" << std::endl;
if (!sound)
fichierSauvegarde << "Sound = false" << std::endl;
}
window.close();
}
}
if (!play)
{
if ((!parametre) && (!parametre_fps) && (!parametre_windowmode))
{
window.draw(putname);
window.draw(txt);
window.draw(btnPlay);
window.draw(cercle_btnparametre);
window.draw(sprite_btnparametre);
window.draw(cercle_btnsound);
window.draw(sprite_btnsound);
if (!sound)
window.draw(no_btnsound);
if (sf::Mouse::isButtonPressed(sf::Mouse::Left))
{
if ((souris.getPosition(window).x > (screenW / 2) - 350) && (souris.getPosition(window).x < (screenW / 2) + 350) && (souris.getPosition(window).y > 180) && (souris.getPosition(window).y < 280))
{
choosename = true;
txt.setString("");
}
else if ((souris.getPosition(window).x > btnPlay.getPosition().x - 80) && (souris.getPosition(window).x < btnPlay.getPosition().x + (btnPlay.getRadius() * 2) - 80) && (souris.getPosition(window).y > btnPlay.getPosition().y) && (souris.getPosition(window).y < btnPlay.getPosition().y + (btnPlay.getRadius() * 2)))
{
play = true;
choosename = false;
if (txt.getString() != "Entrer votre nom...")
namePlayer = txt.getString();
else
namePlayer = "Bob";
pseudo.setString(namePlayer);
pseudo.setPosition(sf::Vector2f(sprite_perso.getPosition().x + 32 - (pseudo.getGlobalBounds().getSize().x / 2), sprite_perso.getPosition().y));
}
else if ((souris.getPosition(window).x > cercle_btnsound.getPosition().x) && (souris.getPosition(window).x < cercle_btnsound.getPosition().x + cercle_btnsound.getGlobalBounds().getSize().x) && (souris.getPosition(window).y > cercle_btnsound.getPosition().y) && (souris.getPosition(window).y < cercle_btnsound.getPosition().y + cercle_btnsound.getGlobalBounds().getSize().y))
{
if (sound)
sound = false;
else
sound = true;
sf::sleep(sf::milliseconds(pauseFrappe));
}
else if ((souris.getPosition(window).x > cercle_btnparametre.getPosition().x) && (souris.getPosition(window).x < cercle_btnparametre.getPosition().x + cercle_btnparametre.getGlobalBounds().getSize().x) && (souris.getPosition(window).y > cercle_btnparametre.getPosition().y) && (souris.getPosition(window).y < cercle_btnparametre.getPosition().y + cercle_btnparametre.getGlobalBounds().getSize().y))
{
sf::sleep(sf::milliseconds(pauseFrappe));
parametre = true;
}
}
if ((choosename))
{
if (event.type == sf::Event::TextEntered)
{
if (event.key.code == 8)
{
if (txt.getString().getSize() < 11)
txt.setString("");
}
else if (event.key.code == 32)
{
if (txt.getString().getSize() < 11)
txt.setString(txt.getString() + " ");
}
else if (event.key.code == 45)
{
if (txt.getString().getSize() < 11)
txt.setString(txt.getString() + "-");
}
else if (event.key.code == 48)
{
if (txt.getString().getSize() < 11)
txt.setString(txt.getString() + "0");
}
else if (event.key.code == 49)
{
if (txt.getString().getSize() < 11)
txt.setString(txt.getString() + "1");
}
else if (event.key.code == 50)
{
if (txt.getString().getSize() < 11)
txt.setString(txt.getString() + "2");
}
else if (event.key.code == 51)
{
if (txt.getString().getSize() < 11)
txt.setString(txt.getString() + "3");
}
else if (event.key.code == 52)
{
if (txt.getString().getSize() < 11)
txt.setString(txt.getString() + "4");
}
else if (event.key.code == 53)
{
if (txt.getString().getSize() < 11)
txt.setString(txt.getString() + "5");
}
else if (event.key.code == 54)
{
if (txt.getString().getSize() < 11)
txt.setString(txt.getString() + "6");
}
else if (event.key.code == 55)
{
if (txt.getString().getSize() < 11)
txt.setString(txt.getString() + "7");
}
else if (event.key.code == 56)
{
if (txt.getString().getSize() < 11)
txt.setString(txt.getString() + "8");
}
else if (event.key.code == 57)
{
if (txt.getString().getSize() < 11)
txt.setString(txt.getString() + "9");
}
else if (event.key.code == 65)
{
if (txt.getString().getSize() < 11)
txt.setString(txt.getString() + "A");
}
else if (event.key.code == 66)
{
if (txt.getString().getSize() < 11)
txt.setString(txt.getString() + "B");
}
else if (event.key.code == 67)
{
if (txt.getString().getSize() < 11)
txt.setString(txt.getString() + "C");
}
else if (event.key.code == 68)
{
if (txt.getString().getSize() < 11)
txt.setString(txt.getString() + "D");
}
else if (event.key.code == 69)
{
if (txt.getString().getSize() < 11)
txt.setString(txt.getString() + "E");
}
else if (event.key.code == 70)
{
if (txt.getString().getSize() < 11)
txt.setString(txt.getString() + "F");
}
else if (event.key.code == 71)
{
if (txt.getString().getSize() < 11)
txt.setString(txt.getString() + "G");
}
else if (event.key.code == 72)
{
if (txt.getString().getSize() < 11)
txt.setString(txt.getString() + "H");
}
else if (event.key.code == 73)
{
if (txt.getString().getSize() < 11)
txt.setString(txt.getString() + "I");
}
else if (event.key.code == 74)
{
if (txt.getString().getSize() < 11)
txt.setString(txt.getString() + "J");
}
else if (event.key.code == 75)
{
if (txt.getString().getSize() < 11)
txt.setString(txt.getString() + "K");
}
else if (event.key.code == 76)
{
if (txt.getString().getSize() < 11)
txt.setString(txt.getString() + "L");
}
else if (event.key.code == 77)
{
if (txt.getString().getSize() < 11)
txt.setString(txt.getString() + "M");
}
else if (event.key.code == 78)
{
if (txt.getString().getSize() < 11)
txt.setString(txt.getString() + "N");
}
else if (event.key.code == 79)
{
if (txt.getString().getSize() < 11)
txt.setString(txt.getString() + "O");
}
else if (event.key.code == 80)
{
if (txt.getString().getSize() < 11)
txt.setString(txt.getString() + "P");
}
else if (event.key.code == 81)
{
if (txt.getString().getSize() < 11)
txt.setString(txt.getString() + "Q");
}
else if (event.key.code == 82)
{
if (txt.getString().getSize() < 11)
txt.setString(txt.getString() + "R");
}
else if (event.key.code == 83)
{
if (txt.getString().getSize() < 11)
txt.setString(txt.getString() + "S");
}
else if (event.key.code == 84)
{
if (txt.getString().getSize() < 11)
txt.setString(txt.getString() + "T");
}
else if (event.key.code == 85)
{
if (txt.getString().getSize() < 11)
txt.setString(txt.getString() + "U");
}
else if (event.key.code == 86)
{
if (txt.getString().getSize() < 11)
txt.setString(txt.getString() + "V");
}
else if (event.key.code == 87)
{
if (txt.getString().getSize() < 11)
txt.setString(txt.getString() + "W");
}
else if (event.key.code == 88)
{
if (txt.getString().getSize() < 11)
txt.setString(txt.getString() + "X");
}
else if (event.key.code == 89)
{
if (txt.getString().getSize() < 11)
txt.setString(txt.getString() + "Y");
}
else if (event.key.code == 90)
{
if (txt.getString().getSize() < 11)
txt.setString(txt.getString() + "Z");
}
else if (event.key.code == 95)
{
if (txt.getString().getSize() < 11)
txt.setString(txt.getString() + "_");
}
else if (event.key.code == 97)
{
if (txt.getString().getSize() < 11)
txt.setString(txt.getString() + "a");
}
else if (event.key.code == 98)
{
if (txt.getString().getSize() < 11)
txt.setString(txt.getString() + "b");
}
else if (event.key.code == 99)
{
if (txt.getString().getSize() < 11)
txt.setString(txt.getString() + "c");
}
else if (event.key.code == 100)
{
if (txt.getString().getSize() < 11)
txt.setString(txt.getString() + "d");
}
else if (event.key.code == 101)
{
if (txt.getString().getSize() < 11)
txt.setString(txt.getString() + "e");
}
else if (event.key.code == 102)
{
if (txt.getString().getSize() < 11)
txt.setString(txt.getString() + "f");
}
else if (event.key.code == 103)
{
if (txt.getString().getSize() < 11)
txt.setString(txt.getString() + "g");
}
else if (event.key.code == 104)
{
if (txt.getString().getSize() < 11)
txt.setString(txt.getString() + "h");
}
else if (event.key.code == 105)
{
if (txt.getString().getSize() < 11)
txt.setString(txt.getString() + "i");
}
else if (event.key.code == 106)
{
if (txt.getString().getSize() < 11)
txt.setString(txt.getString() + "j");
}
else if (event.key.code == 107)
{
if (txt.getString().getSize() < 11)
txt.setString(txt.getString() + "k");
}
else if (event.key.code == 108)
{
if (txt.getString().getSize() < 11)
txt.setString(txt.getString() + "l");
}
else if (event.key.code == 109)
{
if (txt.getString().getSize() < 11)
txt.setString(txt.getString() + "m");
}
else if (event.key.code == 110)
{
if (txt.getString().getSize() < 11)
txt.setString(txt.getString() + "n");
}
else if (event.key.code == 111)
{
if (txt.getString().getSize() < 11)
txt.setString(txt.getString() + "o");
}
else if (event.key.code == 112)
{
if (txt.getString().getSize() < 11)
txt.setString(txt.getString() + "p");
}
else if (event.key.code == 113)
{
if (txt.getString().getSize() < 11)
txt.setString(txt.getString() + "q");
}
else if (event.key.code == 114)
{
if (txt.getString().getSize() < 11)
txt.setString(txt.getString() + "r");
}
else if (event.key.code == 115)
{
if (txt.getString().getSize() < 11)
txt.setString(txt.getString() + "s");
}
else if (event.key.code == 116)
{
if (txt.getString().getSize() < 11)
txt.setString(txt.getString() + "t");
}
else if (event.key.code == 117)
{
if (txt.getString().getSize() < 11)
txt.setString(txt.getString() + "u");
}
else if (event.key.code == 118)
{
if (txt.getString().getSize() < 11)
txt.setString(txt.getString() + "v");
}
else if (event.key.code == 119)
{
if (txt.getString().getSize() < 11)
txt.setString(txt.getString() + "w");
}
else if (event.key.code == 120)
{
if (txt.getString().getSize() < 11)
txt.setString(txt.getString() + "x");
}
else if (event.key.code == 121)
{
if (txt.getString().getSize() < 11)
txt.setString(txt.getString() + "y");
}
else if (event.key.code == 122)
{
if (txt.getString().getSize() < 11)
txt.setString(txt.getString() + "z");
}
else if (event.key.code == 124)
{
if (txt.getString().getSize() < 11)
txt.setString(txt.getString() + "|");
}
txt.setPosition(sf::Vector2f((screenW / 2) - (txt.getGlobalBounds().getSize().x / 2), 210));
window.draw(putname);
window.draw(txt);
window.draw(btnPlay);
window.draw(cercle_btnsound);
window.draw(sprite_btnsound);
if (sound)
window.draw(no_btnsound);
sf::sleep(sf::milliseconds(pauseFrappe));
}
}
}
else if (parametre)
{
window.draw(cercle_btnparametre);
window.draw(sprite_btnparametre);
window.draw(box_fps);
window.draw(box_windowmode);
window.draw(txtfps);
window.draw(txtwindowmode);
window.draw(cercle_btnfleche);
window.draw(sprite_btnfleche);
if (sf::Mouse::isButtonPressed(sf::Mouse::Left))
{
if ((souris.getPosition(window).x > cercle_btnparametre.getPosition().x) && (souris.getPosition(window).x < cercle_btnparametre.getPosition().x + cercle_btnparametre.getGlobalBounds().getSize().x) && (souris.getPosition(window).y > cercle_btnparametre.getPosition().y) && (souris.getPosition(window).y < cercle_btnparametre.getPosition().y + cercle_btnparametre.getGlobalBounds().getSize().y))
{
sf::sleep(sf::milliseconds(pauseFrappe));
parametre = false;
parametre_fps = false;
parametre_windowmode = false;
}
if ((souris.getPosition(window).x > box_fps.getPosition().x) && (souris.getPosition(window).x < box_fps.getPosition().x + box_fps.getGlobalBounds().getSize().x) && (souris.getPosition(window).y > box_fps.getPosition().y) && (souris.getPosition(window).y < box_fps.getPosition().y + box_fps.getGlobalBounds().getSize().y))
{
sf::sleep(sf::milliseconds(pauseFrappe));
parametre = false;
parametre_fps = true;
}
if ((souris.getPosition(window).x > box_windowmode.getPosition().x) && (souris.getPosition(window).x < box_windowmode.getPosition().x + box_windowmode.getGlobalBounds().getSize().x) && (souris.getPosition(window).y > box_windowmode.getPosition().y) && (souris.getPosition(window).y < box_windowmode.getPosition().y + box_windowmode.getGlobalBounds().getSize().y))
{
sf::sleep(sf::milliseconds(pauseFrappe));
parametre = false;
parametre_windowmode = true;
}
if ((souris.getPosition(window).x > cercle_btnfleche.getPosition().x) && (souris.getPosition(window).x < cercle_btnfleche.getPosition().x + cercle_btnfleche.getGlobalBounds().getSize().x) && (souris.getPosition(window).y > cercle_btnfleche.getPosition().y) && (souris.getPosition(window).y < cercle_btnfleche.getPosition().y + cercle_btnfleche.getGlobalBounds().getSize().y))
{
sf::sleep(sf::milliseconds(pauseFrappe));
parametre = false;
}
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Escape))
{
sf::sleep(sf::milliseconds(pauseFrappe));
parametre = false;
}
}
else if (parametre_fps)
{
window.draw(box_fps30);
window.draw(box_fps60);
window.draw(box_fps120);
window.draw(box_fps144);
window.draw(box_fps165);
window.draw(box_fps240);
window.draw(box_fps360);
window.draw(txtfps30);
window.draw(txtfps60);
window.draw(txtfps120);
window.draw(txtfps144);
window.draw(txtfps165);
window.draw(txtfps240);
window.draw(txtfps360);
window.draw(cercle_btnparametre);
window.draw(sprite_btnparametre);
window.draw(cercle_btnfleche);
window.draw(sprite_btnfleche);
if (sf::Mouse::isButtonPressed(sf::Mouse::Left))
{
if ((souris.getPosition(window).x > cercle_btnparametre.getPosition().x) && (souris.getPosition(window).x < cercle_btnparametre.getPosition().x + cercle_btnparametre.getGlobalBounds().getSize().x) && (souris.getPosition(window).y > cercle_btnparametre.getPosition().y) && (souris.getPosition(window).y < cercle_btnparametre.getPosition().y + cercle_btnparametre.getGlobalBounds().getSize().y))
{
sf::sleep(sf::milliseconds(pauseFrappe));
parametre = false;
parametre_fps = false;
parametre_windowmode = false;
}
if ((souris.getPosition(window).x > box_fps30.getPosition().x) && (souris.getPosition().x < box_fps30.getPosition().x + box_fps30.getGlobalBounds().getSize().x) && (souris.getPosition().y > box_fps30.getPosition().y) && (souris.getPosition().y < box_fps30.getPosition().y + box_fps30.getGlobalBounds().getSize().y))
{
sf::sleep(sf::milliseconds(pauseFrappe));
window.setFramerateLimit(30);
fps2 = 30;
parametre = true;
parametre_fps = false;
}
if ((souris.getPosition(window).x > box_fps60.getPosition().x) && (souris.getPosition().x < box_fps60.getPosition().x + box_fps60.getGlobalBounds().getSize().x) && (souris.getPosition().y > box_fps60.getPosition().y) && (souris.getPosition().y < box_fps60.getPosition().y + box_fps60.getGlobalBounds().getSize().y))
{
sf::sleep(sf::milliseconds(pauseFrappe));
window.setFramerateLimit(60);
fps2 = 60;
parametre = true;
parametre_fps = false;
}
if ((souris.getPosition(window).x > box_fps120.getPosition().x) && (souris.getPosition().x < box_fps120.getPosition().x + box_fps120.getGlobalBounds().getSize().x) && (souris.getPosition().y > box_fps120.getPosition().y) && (souris.getPosition().y < box_fps120.getPosition().y + box_fps120.getGlobalBounds().getSize().y))
{
sf::sleep(sf::milliseconds(pauseFrappe));
window.setFramerateLimit(120);
fps2 = 120;
parametre = true;
parametre_fps = false;
}
if ((souris.getPosition(window).x > box_fps144.getPosition().x) && (souris.getPosition().x < box_fps144.getPosition().x + box_fps144.getGlobalBounds().getSize().x) && (souris.getPosition().y > box_fps144.getPosition().y) && (souris.getPosition().y < box_fps144.getPosition().y + box_fps144.getGlobalBounds().getSize().y))
{
sf::sleep(sf::milliseconds(pauseFrappe));
window.setFramerateLimit(144);
fps2 = 144;
parametre = true;
parametre_fps = false;
}
if ((souris.getPosition(window).x > box_fps165.getPosition().x) && (souris.getPosition().x < box_fps165.getPosition().x + box_fps165.getGlobalBounds().getSize().x) && (souris.getPosition().y > box_fps165.getPosition().y) && (souris.getPosition().y < box_fps165.getPosition().y + box_fps165.getGlobalBounds().getSize().y))
{
sf::sleep(sf::milliseconds(pauseFrappe));
window.setFramerateLimit(165);
fps2 = 165;
parametre = true;
parametre_fps = false;
}
if ((souris.getPosition(window).x > box_fps240.getPosition().x) && (souris.getPosition().x < box_fps240.getPosition().x + box_fps240.getGlobalBounds().getSize().x) && (souris.getPosition().y > box_fps240.getPosition().y) && (souris.getPosition().y < box_fps240.getPosition().y + box_fps240.getGlobalBounds().getSize().y))
{
sf::sleep(sf::milliseconds(pauseFrappe));
window.setFramerateLimit(240);
fps2 = 240;
parametre = true;
parametre_fps = false;
}
if ((souris.getPosition(window).x > box_fps360.getPosition().x) && (souris.getPosition().x < box_fps360.getPosition().x + box_fps360.getGlobalBounds().getSize().x) && (souris.getPosition().y > box_fps360.getPosition().y) && (souris.getPosition().y < box_fps360.getPosition().y + box_fps360.getGlobalBounds().getSize().y))
{
sf::sleep(sf::milliseconds(pauseFrappe));
window.setFramerateLimit(360);
fps2 = 360;
parametre = true;
parametre_fps = false;
}
if ((souris.getPosition(window).x > cercle_btnfleche.getPosition().x) && (souris.getPosition(window).x < cercle_btnfleche.getPosition().x + cercle_btnfleche.getGlobalBounds().getSize().x) && (souris.getPosition(window).y > cercle_btnfleche.getPosition().y) && (souris.getPosition(window).y < cercle_btnfleche.getPosition().y + cercle_btnfleche.getGlobalBounds().getSize().y))
{
sf::sleep(sf::milliseconds(pauseFrappe));
parametre = true;
parametre_fps = false;
}
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Escape))
{
sf::sleep(sf::milliseconds(pauseFrappe));
parametre = true;
parametre_fps = false;
}
}
else if (parametre_windowmode)
{
window.draw(cercle_btnparametre);
window.draw(sprite_btnparametre);
window.draw(cercle_btnfleche);
window.draw(sprite_btnfleche);
if (sf::Mouse::isButtonPressed(sf::Mouse::Left))
{
if ((souris.getPosition(window).x > cercle_btnparametre.getPosition().x) && (souris.getPosition(window).x < cercle_btnparametre.getPosition().x + cercle_btnparametre.getGlobalBounds().getSize().x) && (souris.getPosition(window).y > cercle_btnparametre.getPosition().y) && (souris.getPosition(window).y < cercle_btnparametre.getPosition().y + cercle_btnparametre.getGlobalBounds().getSize().y))
{
sf::sleep(sf::milliseconds(pauseFrappe));
parametre = false;
parametre_fps = false;
parametre_windowmode = false;
}
if ((souris.getPosition(window).x > cercle_btnfleche.getPosition().x) && (souris.getPosition(window).x < cercle_btnfleche.getPosition().x + cercle_btnfleche.getGlobalBounds().getSize().x) && (souris.getPosition(window).y > cercle_btnfleche.getPosition().y) && (souris.getPosition(window).y < cercle_btnfleche.getPosition().y + cercle_btnfleche.getGlobalBounds().getSize().y))
{
sf::sleep(sf::milliseconds(pauseFrappe));
parametre = true;
parametre_windowmode = false;
}
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Escape))
{
sf::sleep(sf::milliseconds(pauseFrappe));
parametre = true;
parametre_windowmode = false;
}
}
}
if (play)
{
if (lvl1)
{
if (setpos)
{
setpos = false;
sprite_perso.setPosition(sf::Vector2f(0, screenH / 2));
pseudo.setPosition(sf::Vector2f(0, screenH / 2));
sprite_zombie1.setPosition(sf::Vector2f(1680, 420));
sprite_zombie2.setPosition(sf::Vector2f(1680, 480));
sprite_zombie3.setPosition(sf::Vector2f(1680, 540));
sprite_zombie4.setPosition(sf::Vector2f(1680, 600));
sprite_zombie5.setPosition(sf::Vector2f(1680, 660));
}
sprite_perso.setTextureRect(sf::IntRect(anim.x * 64, anim.y * 64, 64, 64));
sprite_zombie1.setTextureRect(sf::IntRect(anim_zombie1.x * 64, anim_zombie1.y * 64, 64, 64));
sprite_zombie2.setTextureRect(sf::IntRect(anim_zombie2.x * 64, anim_zombie2.y * 64, 64, 64));
sprite_zombie3.setTextureRect(sf::IntRect(anim_zombie3.x * 64, anim_zombie3.y * 64, 64, 64));
sprite_zombie4.setTextureRect(sf::IntRect(anim_zombie4.x * 64, anim_zombie4.y * 64, 64, 64));
sprite_zombie5.setTextureRect(sf::IntRect(anim_zombie5.x * 64, anim_zombie5.y * 64, 64, 64));
window.setView(view);
window.draw(sprite_map1);
window.draw(sprite_perso);
window.draw(sprite_zombie1);
window.draw(sprite_zombie2);
window.draw(sprite_zombie3);
window.draw(sprite_zombie4);
window.draw(sprite_zombie5);
window.draw(pseudo);
mouvement();
animation();
mouvementIA();
animation_zombie();
blockage();
view.reset(sf::FloatRect(0, 0, screenW, screenH));
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Escape))
{
play = false;
}
}
}
window.display();
window.clear();
}
return 0;
}