Advertisement
Astaa001

complete game

Jun 18th, 2019
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 168.57 KB | None | 0 0
  1. #include"pch.h"
  2. #include<SFML/Graphics.hpp>
  3. #include<SFML/Window.hpp>
  4. #include<SFML/OpenGL.hpp>
  5. #include<SFML/Audio.hpp>
  6. #include<SFML/Config.hpp>
  7. #include<SFML/System.hpp>
  8. #include<iostream>
  9. #include<algorithm>
  10. #include<vector>
  11. #include<queue>
  12. #include<functional>
  13. #include<ctime>
  14. #include<time.h>
  15. using namespace sf;
  16. using namespace std;
  17.  
  18.  
  19. void mainmenu();
  20.  
  21.  
  22.  
  23. struct leftmovement {
  24.     int i, j;
  25. };
  26. struct rightmovement {
  27.     int i, j;
  28. };
  29. struct upmovement {
  30.     int i, j;
  31. };
  32. struct downmovement {
  33.     int i, j;
  34. };
  35. struct BFS_Movement {
  36.     int i, j;
  37. }Smart_Skeleton_Movement, Red_Robot_Movement;
  38. struct status {
  39.     int lives = 3;
  40.     int range = 3;
  41.  
  42. }player_status;
  43. //////////////////////////////////////////////////////////
  44. //Bomb struct
  45. struct bomb {
  46.     bool bomb_placed = 0;
  47.     bool bomb_exploded = 0;
  48.     vector <Sprite>range_right;
  49.     vector <Sprite>range_left;
  50.     vector <Sprite>range_up;
  51.     vector <Sprite>range_down;
  52.     Sprite sprt;
  53.     Time bomb_time, start_explosion, explosion_time;
  54.     Clock bomb_clock, start_clock, explosion_clock;
  55.     int x_pos, y_pos, x_index, y_index;
  56.     int exp_animation_x = 1, exp_animation_y = 0, bomb_animation_y = 0, bomb_animation_x = 0;
  57.     bool flag_range_up = 1, flag_range_down = 1, flag_range_right = 1, flag_range_left = 1;
  58. };
  59. int pos_x = 1, pos_y = 0, pos = 0, a, b, i, j;
  60. bool explosion = false, ispressed = false, flag = 0, flag1 = 0;
  61. /////////////////////////////////////////////////////////
  62. //General stuff
  63. const int length = 12, width = 17;
  64. float Smart_Monsters_Speed = 0.3;
  65. int Random_Monsters_Speed = 1;
  66.  
  67. // Menu stuff
  68. #define MAX_NUMBER_OF_ITEMS 4
  69. int selectedItemIndex = 0;
  70. Font font; Text menu[MAX_NUMBER_OF_ITEMS];
  71. void setmenustatus(float width, float height) {
  72.     if (!font.loadFromFile("Chocolate Bar Demo.otf"))
  73.     {
  74.         // handle error
  75.         cout << "SHIIIIT" << endl;
  76.     }
  77.  
  78.     for (int i = 0; i < MAX_NUMBER_OF_ITEMS; i++)
  79.     {
  80.         menu[i].setFont(font);
  81.         if (i == 0) {
  82.             menu[i].setFillColor(Color::Red);
  83.             menu[i].setString("Single player");
  84.             menu[i].setPosition(sf::Vector2f(width / 2.5, height / (MAX_NUMBER_OF_ITEMS + 1) * 2.35));
  85.         }
  86.         else if (i == 1) {
  87.             menu[i].setFillColor(Color::White);
  88.             menu[i].setString("Multiplayer");
  89.             menu[i].setPosition(sf::Vector2f(width / 2.5, height / (MAX_NUMBER_OF_ITEMS + 1) * 3.1));
  90.  
  91.         }
  92.         else if (i == 2)
  93.         {
  94.             menu[i].setFillColor(Color::White);
  95.             menu[i].setString("About us");
  96.             menu[i].setPosition(sf::Vector2f(width / 2.4, height / (MAX_NUMBER_OF_ITEMS + 1) * 3.75));
  97.         }
  98.         else {
  99.             menu[3].setFillColor(Color::White);
  100.             menu[3].setString("Exit");
  101.             menu[3].setPosition(sf::Vector2f(width / 2.25, height / (MAX_NUMBER_OF_ITEMS + 1) * 4.5));
  102.         }
  103.  
  104.     }
  105. }
  106.  
  107. bool visted[100][100];
  108. // Levels_Menu stuff
  109. #define MAX_NUMBER_OF_levels 4
  110. int selectedlevelIndex = 0;
  111. Font levelsfont; Text levels[MAX_NUMBER_OF_levels];
  112.  
  113. void setlevelsstatus(float width, float height) {
  114.     if (!levelsfont.loadFromFile("Chocolate Bar Demo.otf"))
  115.     {
  116.         // handle error
  117.         cout << "font error" << endl;
  118.     }
  119.  
  120.     for (int i = 0; i < MAX_NUMBER_OF_levels; i++)
  121.     {
  122.         levels[i].setFont(levelsfont);
  123.         if (i == 0) {
  124.             levels[i].setFillColor(Color::Red);
  125.             levels[i].setString("Beginner");
  126.             levels[i].setPosition(sf::Vector2f(width / 2.4, height / (MAX_NUMBER_OF_ITEMS + 1) * 2.35));
  127.         }
  128.         else if (i == 1) {
  129.             levels[i].setFillColor(Color::White);
  130.             levels[i].setString("Advanced");
  131.             levels[i].setPosition(sf::Vector2f(width / 2.4, height / (MAX_NUMBER_OF_ITEMS + 1) * 3.1));
  132.  
  133.         }
  134.         else if (i == 2) {
  135.  
  136.             levels[i].setFillColor(Color::White);
  137.             levels[i].setString("Legendary");
  138.             levels[i].setPosition(sf::Vector2f(width / 2.4, height / (MAX_NUMBER_OF_ITEMS + 1) * 3.75));
  139.  
  140.         }
  141.         else if (i == 3)
  142.         {
  143.             levels[i].setFillColor(Color::White);
  144.             levels[i].setString("Back");
  145.             levels[i].setPosition(sf::Vector2f(width / 2.4, height / (MAX_NUMBER_OF_ITEMS + 1) * 4.45));
  146.  
  147.         }
  148.     }
  149. }
  150.  
  151. void drawmenu(RenderWindow& window)
  152. {
  153.     for (int i = 0; i < MAX_NUMBER_OF_ITEMS; i++)
  154.     {
  155.         window.draw(menu[i]);
  156.  
  157.     }
  158. }
  159. void drawlev(RenderWindow& window)
  160. {
  161.     for (int i = 0; i < MAX_NUMBER_OF_levels; i++)
  162.     {
  163.         window.draw(levels[i]);
  164.  
  165.     }
  166. }
  167. void MoveUp()
  168. {
  169.     if (selectedItemIndex - 1 >= 0)
  170.     {
  171.         menu[selectedItemIndex].setFillColor(Color::White);
  172.         selectedItemIndex--;
  173.         menu[selectedItemIndex].setFillColor(Color::Red);
  174.     }
  175. }
  176. void MoveUplev()
  177. {
  178.     if (selectedlevelIndex - 1 >= 0)
  179.     {
  180.         levels[selectedlevelIndex].setFillColor(Color::White);
  181.         selectedlevelIndex--;
  182.         levels[selectedlevelIndex].setFillColor(Color::Red);
  183.     }
  184. }
  185. void MoveDown()
  186. {
  187.     if (selectedItemIndex + 1 < MAX_NUMBER_OF_ITEMS)
  188.     {
  189.         menu[selectedItemIndex].setFillColor(Color::White);
  190.         selectedItemIndex++;
  191.         menu[selectedItemIndex].setFillColor(Color::Red);
  192.     }
  193. }
  194. void MoveDownlev()
  195. {
  196.     if (selectedlevelIndex + 1 < MAX_NUMBER_OF_levels)
  197.     {
  198.         levels[selectedlevelIndex].setFillColor(Color::White);
  199.         selectedlevelIndex++;
  200.         levels[selectedlevelIndex].setFillColor(Color::Red);
  201.     }
  202. }
  203. int GetPressedItem() {
  204.     return selectedItemIndex;
  205. }
  206. int GetPressedlevel() {
  207.     return selectedlevelIndex;
  208. }
  209.  
  210. int GetXindx(float a)
  211. {
  212.     return (a - 183) / 53 + 2;
  213. }
  214. int GetYindx(float a)
  215. {
  216.     return (a - 74) / 48 + 2;
  217. }
  218. int GetXpostion(int a)
  219. {
  220.     return ((a - 2) * 53) + 198;
  221. }
  222. int GetYpostion(int a)
  223. {
  224.     return ((a - 2) * 48) + 89;
  225. }
  226. void destroy_breakable_walls(int Xindx, int Yindx, Sprite Grid[][13], Texture& ground, Texture& ground2)
  227. {
  228.  
  229.     if (Xindx % 2 == Yindx % 2) { Grid[Xindx][Yindx].setTexture(ground); }
  230.     else { Grid[Xindx][Yindx].setTexture(ground2); }
  231.  
  232.     Grid[Xindx][Yindx].setPosition((Xindx + 2) * 53, (Yindx + 0.8) * 48);
  233.     Grid[Xindx][Yindx].setScale(0.1009, 0.101);
  234.  
  235.  
  236. }
  237. void destroy_breakable_walls(int Xindx, int Yindx, Sprite Grid[][10], Texture& ground, Texture& ground2)
  238. {
  239.  
  240.     if (Xindx % 2 == Yindx % 2) { Grid[Xindx][Yindx].setTexture(ground); }
  241.     else { Grid[Xindx][Yindx].setTexture(ground2); }
  242.  
  243.     Grid[Xindx][Yindx].setPosition((Xindx + 2) * 53, (Yindx + 0.8) * 48);
  244.     Grid[Xindx][Yindx].setScale(0.1009, 0.101);
  245.  
  246.  
  247. }
  248.  
  249. bool vis[20][20];
  250. int dx[] = { 0,  0, 1, -1 };
  251. int dy[] = { 1, -1, 0,  0 };
  252. bool valid(int i, int j, Sprite arr[][length + 1], Texture& g1, Texture& g2)
  253. {
  254.     return i >= 2 and j >= 2 and i < width + 1 and j < length + 1 and !vis[i][j] and (arr[i][j].getTexture() == &g1 || arr[i][j].getTexture() == &g2);
  255. }
  256. void BFS(int srcX, int srcY, int distX, int distY, Sprite arr[][length + 1], Texture& g1, Texture& g2)
  257. {
  258.     memset(vis, 0, sizeof vis);
  259.     queue <pair<int, int> > Q;
  260.     vis[srcX][srcY] = 1;
  261.     Q.push({ srcX, srcY });
  262.     while (!Q.empty())
  263.     {
  264.         int nodeX = Q.front().first;
  265.         int nodeY = Q.front().second;
  266.         //cout << nodeY << endl;
  267.         if ((nodeX == distX && nodeY + 1 == distY)) {
  268.             Smart_Skeleton_Movement.i = nodeX;
  269.             Smart_Skeleton_Movement.j = nodeY;
  270.             Red_Robot_Movement.i = nodeX;
  271.             Red_Robot_Movement.j = nodeY;
  272.             break;
  273.         }
  274.         else if (nodeX == distX && nodeY - 1 == distY) {
  275.             Smart_Skeleton_Movement.i = nodeX;
  276.             Smart_Skeleton_Movement.j = nodeY;
  277.             Red_Robot_Movement.i = nodeX;
  278.             Red_Robot_Movement.j = nodeY;
  279.             break;
  280.         }
  281.         else if (nodeX + 1 == distX && nodeY == distY) {
  282.             Smart_Skeleton_Movement.i = nodeX;
  283.             Smart_Skeleton_Movement.j = nodeY;
  284.             Red_Robot_Movement.i = nodeX;
  285.             Red_Robot_Movement.j = nodeY;
  286.             break;
  287.         }
  288.         else if (nodeX - 1 == distX && nodeY == distY) {
  289.             Smart_Skeleton_Movement.i = nodeX;
  290.             Smart_Skeleton_Movement.j = nodeY;
  291.             Red_Robot_Movement.i = nodeX;
  292.             Red_Robot_Movement.j = nodeY;
  293.             break;
  294.         }
  295.  
  296.         Q.pop();
  297.         for (int k = 0; k < 4; k++)
  298.         {
  299.             int newNodeX = nodeX + dx[k];
  300.             int newNodeY = nodeY + dy[k];
  301.             if (valid(newNodeX, newNodeY, arr, g1, g2))
  302.             {
  303.                 vis[newNodeX][newNodeY] = 1;
  304.                 Q.push({ newNodeX, newNodeY });
  305.             }
  306.         }
  307.     }
  308. }
  309.  
  310. void Generate_Charcter(RectangleShape& charcter, Texture& charcter_texture, Vector2u& charcter_size, string filename, int X_Postion, int Y_Postion) {
  311.     X_Postion = GetXpostion(X_Postion); Y_Postion = GetYpostion(Y_Postion);
  312.     charcter.setPosition(X_Postion, Y_Postion);
  313.     charcter.setScale(0.8, 0.8);
  314.     charcter_texture.loadFromFile(filename);
  315.     charcter.setTexture(&charcter_texture);
  316.     charcter_size = charcter_texture.getSize();
  317.     charcter_size.x /= 9;
  318.     charcter_size.y /= 4;
  319.     charcter.setTextureRect(IntRect(charcter_size.x * 0, charcter_size.y * 2, charcter_size.x, charcter_size.y));
  320. }
  321. void Movement_Upward(RectangleShape& character, Time& Monster_time, Clock& Monster_clock, float& Monster_position, Vector2u& Monster_text_size, float Monster_speed)
  322. {
  323.     character.move(0.0, -Monster_speed);
  324.     Monster_time = Monster_clock.getElapsedTime();
  325.     if (Monster_time.asSeconds() >= 0.1) {
  326.         Monster_clock.restart();
  327.         Monster_position++;
  328.         if (Monster_position > 8)
  329.             Monster_position -= 8;
  330.     }
  331.     character.setTextureRect(IntRect(Monster_text_size.x * Monster_position, Monster_text_size.y * 0, Monster_text_size.x, Monster_text_size.y));
  332. }
  333. void Movement_Downward(RectangleShape& character, Time& Monster_time, Clock& Monster_clock, float& Monster_position, Vector2u& Monster_text_size, float Monster_speed)
  334. {
  335.     character.move(0.0, Monster_speed);
  336.     Monster_time = Monster_clock.getElapsedTime();
  337.     if (Monster_time.asSeconds() >= 0.1) {
  338.         Monster_clock.restart();
  339.         Monster_position++;
  340.         if (Monster_position > 8)
  341.             Monster_position -= 8;
  342.     }
  343.     character.setTextureRect(IntRect(Monster_text_size.x * Monster_position, Monster_text_size.y * 2, Monster_text_size.x, Monster_text_size.y));
  344. }
  345. void Movement_Right(RectangleShape& character, Time& Monster_time, Clock& Monster_clock, float& Monster_position, Vector2u& Monster_text_size, float Monster_speed)
  346. {
  347.     character.move(Monster_speed, 0.0);
  348.     Monster_time = Monster_clock.getElapsedTime();
  349.     if (Monster_time.asSeconds() >= 0.1) {
  350.         Monster_clock.restart();
  351.         Monster_position++;
  352.         if (Monster_position > 8)
  353.             Monster_position -= 8;
  354.     }
  355.     character.setTextureRect(IntRect(Monster_text_size.x * Monster_position, Monster_text_size.y * 3, Monster_text_size.x, Monster_text_size.y));
  356. }
  357. void Movement_Left(RectangleShape& character, Time& Monster_time, Clock& Monster_clock, float& Monster_position, Vector2u& Monster_text_size, float Monster_speed)
  358. {
  359.     character.move(-Monster_speed, 0.0);
  360.     Monster_time = Monster_clock.getElapsedTime();
  361.     if (Monster_time.asSeconds() >= 0.1) {
  362.         Monster_clock.restart();
  363.         Monster_position++;
  364.         if (Monster_position > 8)
  365.             Monster_position -= 8;
  366.     }
  367.     character.setTextureRect(IntRect(Monster_text_size.x * Monster_position, Monster_text_size.y * 1, Monster_text_size.x, Monster_text_size.y));
  368. }
  369. bool Die, playsong = 1;;
  370. void Beginner_Mode()
  371. {
  372.     int big_pos_x = 1, big_pos_y = 0; //بيتعرف فوق
  373.     Texture big_exp_text;
  374.     big_exp_text.loadFromFile("exp.png");
  375.     Sprite big_exp;
  376.     big_exp.setTexture(big_exp_text);
  377.     Vector2u text_size_big_exp = big_exp_text.getSize();
  378.     text_size_big_exp.x /= 3;
  379.     text_size_big_exp.y /= 3;
  380.     big_exp.setScale(3, 3);
  381.     Clock start_clock, timer_clock, clock_shutdown;
  382.     Time start_timer, timer, timer_shutdown;
  383.     int display_timer, minutes = 1;
  384.     Text txt;
  385.     Texture death_texture;
  386.     death_texture.loadFromFile("death.png");
  387.     Font dis_time;
  388.     if (!dis_time.loadFromFile("Chocolate Bar Demo.otf"))
  389.     {
  390.         cout << "error font";
  391.     }
  392.  
  393.     Time elaps = seconds(200);
  394.     int elapsed = elaps.asSeconds();
  395.     //###############################################################################
  396.                     // Load Songs
  397.     Music ingame, lost;
  398.     if (!ingame.openFromFile("ingame.wav"))             // ingame
  399.         cout << "error to load ingame " << endl;
  400.     if (!lost.openFromFile("For the Damaged Coda.wav"))     // End_Game
  401.         cout << "error to load The damgae of coda";
  402.     ingame.play();
  403.     ingame.setLoop(1);
  404.  
  405.     if (Joystick::isConnected(0))
  406.     {
  407.         cout << "1 is connect" << endl;
  408.     }
  409.     if (Joystick::isConnected(1))
  410.     {
  411.         cout << "2 is connect" << endl;
  412.     }
  413.     //###############################################################################
  414.     // Making of Player
  415.     RectangleShape player(Vector2f(100, 120));
  416.     Texture player_texture;
  417.     Vector2u player_size;
  418.     Clock player_clock;
  419.     Time player_time;
  420.     float player_position = 0;
  421.     const int player_speed = 2;
  422.     Generate_Charcter(player, player_texture, player_size, "mainplayer.png", 2, 2);
  423.     //###############################################################################
  424.  
  425.     //###############################################################################
  426.     // Making of Yellow_Robot
  427.     RectangleShape Yellow_Robot(Vector2f(100, 120));
  428.     Texture Yellow_Robot_texture;
  429.     Vector2u Yellow_Robot_size;
  430.     Clock Yellow_Robot_clock;
  431.     Time Yellow_Robot_time;
  432.     float Yellow_Robot_speed = 1;
  433.     float Yellow_Robot_position = 0;
  434.     int Yellow_Robot_Counter = 0;
  435.     int Yellow_Robot_Rand_motion = rand() % 4 + 1;
  436.     Generate_Charcter(Yellow_Robot, Yellow_Robot_texture, Yellow_Robot_size, "yellow_robot.png", 15, 2);
  437.     //###############################################################################
  438.  
  439.     //###############################################################################
  440.     // Making of Skeleton
  441.     RectangleShape Skeleton(Vector2f(100, 120));
  442.     Texture Skeleton_texture;
  443.     Vector2u Skeleton_size;
  444.     Clock Skeleton_clock;
  445.     Time Skeleton_time;
  446.     int Skeleton_Rand_motion = rand() % 4 + 1;
  447.     int Skeleton_counter = 0;
  448.     float Skeleton_position = 0;
  449.     Generate_Charcter(Skeleton, Skeleton_texture, Skeleton_size, "monster (5).png", 7, 8);
  450.     //###############################################################################
  451.  
  452.  
  453.     //###############################################################################
  454.     // Making of White_Robot
  455.     RectangleShape White_Robot(Vector2f(100, 120));
  456.     Texture White_Robot_texture;
  457.     Vector2u White_Robot_size;
  458.     Clock White_Robot_clock;
  459.     Time White_Robot_time;
  460.     int White_Robot_Rand_motion = rand() % 4 + 1;
  461.     int White_Robot_counter = 0;
  462.     float White_Robot_position = 0;
  463.     Generate_Charcter(White_Robot, White_Robot_texture, White_Robot_size, "white_robot.png", 14, 8);
  464.     //###############################################################################
  465.  
  466.     //###############################################################################
  467.     // Movement stuff
  468.     leftmovement left; rightmovement right; upmovement up; downmovement down;
  469.     int Player_xindx = 0, Player_yindx = 0, White_Robot_xindx = 0, White_Robot_yindx = 0, Skeleton_xindx = 0, Skeleton_yindx = 0, Robot_xindx = 0, Robot_yindx = 0;
  470.     //###############################################################################
  471.                         // Making of MAP //
  472.     //###############################################################################
  473.                         // Making of Grid //
  474.     Texture wall, ground, wallpaper, ground2, breakable, hurt, choice;
  475.     if (!breakable.loadFromFile("breakable.png"))
  476.     {
  477.         cout << "error loading breakable wall pic";
  478.     }
  479.     if (!wallpaper.loadFromFile("wallpaper.jpg"))
  480.     {
  481.         cout << "error loading wallpaper pic";
  482.     }
  483.     if (!wall.loadFromFile("3d wall.png"))
  484.     {
  485.         cout << "error loading wall pic";
  486.     }
  487.  
  488.     if (!ground.loadFromFile("ground 1.png"))
  489.     {
  490.         cout << "error loading ground pic";
  491.     }
  492.     if (!ground2.loadFromFile("grass.png"))
  493.     {
  494.         cout << "error loading grass pic";
  495.     }
  496.  
  497.     if (!hurt.loadFromFile("hurt.png"))
  498.     {
  499.         cout << "error loading  hurt pic";
  500.     }
  501.     hurt.setSmooth(1);
  502.     //###############################################################################
  503.  
  504.                 // Distribution of wall , brekable & ground on the Grid //
  505.  
  506.     Sprite Grid[width + 1][length + 1], Hurt, Wallpaper;
  507.  
  508.     for (int i = 1; i <= width; i++)                // Distribution of wall and ground on the Grid //
  509.     {
  510.         for (int j = 1; j <= length; j++)
  511.         {
  512.             if (i % 2 != 0 && j % 2 != 0)
  513.             {
  514.  
  515.                 Grid[i][j].setTexture(wall);
  516.                 Grid[i][j].setPosition((i + 1.97) * 53.15, (j + 0.255) * 48);
  517.                 Grid[i][j].setScale(Vector2f(0.1009, 0.165));
  518.  
  519.             }
  520.  
  521.             else if (i == 1 || i == width)
  522.             {
  523.                 Grid[i][j].setTexture(wall);
  524.                 Grid[i][j].setPosition((i + 1.97) * 53.15, (j + 0.255) * 48);
  525.                 Grid[i][j].setScale(Vector2f(0.1009, 0.165));
  526.             }
  527.             else if (j == 1 || j == length)
  528.             {
  529.                 Grid[i][j].setTexture(wall);
  530.                 Grid[i][j].setPosition((i + 1.97) * 53.15, (j + 0.255) * 48);
  531.                 Grid[i][j].setScale(Vector2f(0.1009, 0.165));
  532.             }
  533.             else
  534.             {
  535.                 if (i % 2 == j % 2) { Grid[i][j].setTexture(ground); }
  536.                 else { Grid[i][j].setTexture(ground2); }
  537.                 Grid[i][j].setPosition((i + 2) * 53, (j + 0.8) * 48);
  538.                 Grid[i][j].setScale(0.1, 0.101);
  539.             }
  540.         }
  541.     }
  542.  
  543.  
  544.     for (int i = 1; i <= 30; i++)                   // Distribution of Brekable on the Grid //
  545.     {
  546.         int x = rand() % 15 + 2, y = rand() % 9 + 2;
  547.         if (x % 2 != 0 && y % 2 != 0)
  548.         {
  549.             x++;
  550.         }
  551.         Grid[x][y].setTexture(breakable);
  552.         Grid[x][y].setPosition((x + 1.97) * 53.15, (y + 0.255) * 48);
  553.         Grid[x][y].setScale(Vector2f(0.1009, 0.165));
  554.     }
  555.  
  556.  
  557.  
  558.     //###############################################################################
  559.  
  560.  
  561.     //###############################################################################
  562.                             // Player Abilities and Features //
  563.     Texture  life, bomb_frame, range, tomb, Rip, healskill, speedskill, rangeskill, bombskill;
  564.     Hurt.setTexture(hurt);
  565.     Wallpaper.setTexture(wallpaper);
  566.     if (!life.loadFromFile("flife.png"))
  567.     {
  568.         cout << "error loading life pic";
  569.     }
  570.     if (!range.loadFromFile("frange.png"))
  571.     {
  572.         cout << "error loading range pic";
  573.     }
  574.     if (!bomb_frame.loadFromFile("fbomb.png"))
  575.     {
  576.         cout << "error loading bomb pic";
  577.     }
  578.     if (!tomb.loadFromFile("RIP.png"))
  579.     {
  580.         cout << "error loading tomb pic";
  581.     }
  582.     if (!healskill.loadFromFile("Heal .png"))
  583.     {
  584.         cout << "error to loading Heal skill" << endl;
  585.     }
  586.  
  587.     if (!rangeskill.loadFromFile("Range skill.png"))
  588.     {
  589.         cout << "error to loading Range skill " << endl;
  590.     }
  591.     if (!bombskill.loadFromFile("bomb skill .png"))
  592.     {
  593.         cout << "error to loading Range skill " << endl;
  594.     }
  595.  
  596.  
  597.  
  598.     //###############################################################################
  599.     // Player Abilities
  600.     Sprite SuperPowers[14];
  601.  
  602.     for (int i = 0; i < 5; i++)
  603.     {
  604.  
  605.         SuperPowers[i].setTexture(bombskill);           // Rand_Choice 1 => Bombing
  606.         SuperPowers[i].setScale(0.5, 0.3);
  607.  
  608.     }
  609.     for (int i = 5; i < 8; i++)
  610.     {
  611.         SuperPowers[i].setTexture(healskill);       // Rand_Choice 2 => Health
  612.         SuperPowers[i].setScale(0.5, 0.3);
  613.     }
  614.  
  615.     for (int i = 8; i < 13; i++)
  616.     {
  617.         SuperPowers[i].setTexture(rangeskill);              // Rand_Choice 3 => Range
  618.         SuperPowers[i].setScale(0.5, 0.3);
  619.     }
  620.     Texture timebomb;
  621.     timebomb.loadFromFile("time-bomb.png");
  622.     Sprite timebombS;
  623.     SuperPowers[13].setTexture(timebomb);               // Rand_Choice 3 => Range
  624.     SuperPowers[13].setScale(0.05, 0.05);
  625.  
  626.  
  627.  
  628.     SuperPowers[0].setPosition(GetXpostion(6) + 20, GetYpostion(5));
  629.     SuperPowers[1].setPosition(GetXpostion(12) + 20, GetYpostion(11));
  630.     SuperPowers[2].setPosition(GetXpostion(8) + 20, GetYpostion(5));
  631.     SuperPowers[3].setPosition(GetXpostion(14) + 20, GetYpostion(10));
  632.     SuperPowers[4].setPosition(GetXpostion(4) + 20, GetYpostion(6));
  633.     SuperPowers[5].setPosition(GetXpostion(8) + 20, GetYpostion(8));
  634.     SuperPowers[6].setPosition(GetXpostion(6) + 20, GetYpostion(10));
  635.     SuperPowers[7].setPosition(GetXpostion(14) + 20, GetYpostion(6));
  636.     SuperPowers[8].setPosition(GetXpostion(12) + 20, GetYpostion(8));
  637.     SuperPowers[9].setPosition(GetXpostion(8) + 20, GetYpostion(10));
  638.     SuperPowers[10].setPosition(GetXpostion(6) + 20, GetYpostion(6));
  639.     SuperPowers[11].setPosition(GetXpostion(16) + 20, GetYpostion(6));
  640.     SuperPowers[12].setPosition(GetXpostion(16) + 20, GetYpostion(8));
  641.     SuperPowers[13].setPosition(GetXpostion(16) + 20, GetYpostion(11));
  642.  
  643.  
  644.  
  645.     //###############################################################################
  646.     Texture Complete;
  647.     Complete.loadFromFile("level-completed.png");
  648.     Sprite lifeS, bombS, rangeS, Tomb, RIP_Photo, Level_complete;
  649.     Level_complete.setTexture(Complete);
  650.     lifeS.setTexture(life);
  651.     lifeS.setPosition(0, 250);
  652.     lifeS.setScale(0.4, 0.4);
  653.  
  654.     rangeS.setTexture(range);
  655.     rangeS.setPosition(0, 180);
  656.     rangeS.setScale(0.4, 0.4);
  657.  
  658.     bombS.setTexture(bomb_frame);
  659.     bombS.setPosition(0, 330);
  660.     bombS.setScale(0.4, 0.4);
  661.  
  662.     Tomb.setTexture(tomb);
  663.     Tomb.setScale(0.1, 0.1);
  664.  
  665.     RIP_Photo.setTexture(death_texture);
  666.     Clock Clock_Damgae, SuperPowers_clock;
  667.     Time SuperPowers_time;
  668.  
  669.     //###############################################################################
  670.  
  671.  
  672.     //###############################################################################
  673.                 //Player Bomb stuff //
  674.     Sprite bombing, exp;
  675.     bombing.setScale(0.2f, 0.2f);
  676.     exp.setScale(0.25, 0.25);
  677.     Texture playertext, player2text, bombtext, exptext;
  678.     playertext.loadFromFile("mainplayer.png");
  679.     player2text.loadFromFile("blue.png");
  680.     bombtext.loadFromFile("BOOM.png");
  681.     exptext.loadFromFile("exp.png");
  682.     bombing.setTexture(bombtext);
  683.     exp.setTexture(exptext);
  684.     Vector2u text_size_bomb = bombtext.getSize();
  685.     Vector2u text_size_exp = exptext.getSize();
  686.     text_size_bomb.y /= 4;
  687.     text_size_exp.x /= 3;
  688.     text_size_exp.y /= 3;
  689.     Time times2, times, t, ti, bomb_timer;
  690.     Clock clocks2, c, cs, clocks, clock_timer;
  691.  
  692.     bomb bomb_template;
  693.     bomb_template.sprt.setTexture(bombtext);
  694.     bomb_template.sprt.setScale(0.15f, 0.15f);
  695.     vector<bomb>bombs;
  696.     int lives = 3;
  697.     int boombs = 1;
  698.     Clock counter;
  699.     int number_of_bombs = 0, range_of_bomb = 1, bomb_placement_timer = 0, superpower_of_bomb = 2, counter_placed_bombs = 0;
  700.     //bombs.push_back(bomb_template);
  701.     //###############################################################################
  702.     int death_time_dur = 0;
  703.     bool death_flag = 0;
  704.     bool Yellow_Robot_death = 0, White_Robot_death = 0, Skeleton_death = 0;
  705.     //###############################################################################
  706.                             // Game Window //
  707.     int temp_range_of_bomb = 1;
  708.     bool isbomb = 0;
  709.     RenderWindow Level_1(VideoMode(1280, 768), "Fcis in Danger ");
  710.     while (Level_1.isOpen())
  711.     {
  712.         // dead
  713.         /////////////////////////////////////
  714.         timer = timer_clock.getElapsedTime();
  715.         display_timer = timer.asSeconds();
  716.         string s1, s2;
  717.         s1 = to_string(59 - (display_timer));
  718.         s2 = to_string(minutes);
  719.         s2 += ":";
  720.         txt.setFont(dis_time);
  721.         txt.setString(s2 + s1);
  722.         txt.setPosition(512, 22);
  723.         if (display_timer > 59 && minutes > 0)
  724.         {
  725.             minutes--;
  726.             timer_clock.restart();
  727.         }
  728.         if (minutes == 0 && display_timer == 59) {
  729.             Die = 1;
  730.             ispressed = 1;
  731.         }
  732.         if (ispressed) {
  733.             start_timer = start_clock.getElapsedTime();
  734.             if (start_timer.asSeconds() >= 0.2) {
  735.                 start_clock.restart();
  736.                 big_exp.setPosition((Level_1.getPosition().x / 2) - 25, (Level_1.getPosition().y / 2) - 210);
  737.                 big_exp.setTextureRect(IntRect(text_size_big_exp.x * big_pos_x, text_size_big_exp.y * big_pos_y, text_size_big_exp.x, text_size_big_exp.y));
  738.  
  739.                 big_pos_x++;
  740.                 if (big_pos_x == 3) {
  741.                     big_pos_x = 0, big_pos_y++;
  742.                     if (big_pos_y == 2 && big_pos_x == 2) {
  743.                         ispressed = 0;
  744.                         timer_shutdown = clock_shutdown.getElapsedTime();
  745.                         death_time_dur = timer_shutdown.asSeconds();
  746.                         big_exp.setColor(Color::Transparent);
  747.                     }
  748.                 }
  749.             }
  750.         }
  751.  
  752.  
  753.         /////////////////////////////////////
  754.  
  755.         string ss = to_string(temp_range_of_bomb);
  756.  
  757.         Text noofranges;
  758.         noofranges.setFont(font);
  759.         noofranges.setString(ss);
  760.         noofranges.setCharacterSize(45);
  761.         noofranges.setPosition(90, 195);
  762.  
  763.         string sss = to_string(boombs);
  764.  
  765.         Text noofbombs;
  766.         noofbombs.setFont(font);
  767.         noofbombs.setString(sss);
  768.         noofbombs.setCharacterSize(45);
  769.         noofbombs.setPosition(90, 335);
  770.  
  771.         string ssl = to_string(lives);
  772.  
  773.         Text nooflives;
  774.         nooflives.setFont(font);
  775.         nooflives.setString(ssl);
  776.         nooflives.setCharacterSize(45);
  777.         nooflives.setPosition(90, 270);
  778.  
  779.         // Robot 1 movement
  780.         Robot_xindx = (float)((float)(Yellow_Robot.getPosition().x - 183) / 53 + 2);
  781.         Robot_yindx = (float)((float)(Yellow_Robot.getPosition().y - 74) / 48 + 2);
  782.         right.i = GetXindx(Yellow_Robot.getPosition().x + 20); right.j = Robot_yindx;
  783.         left.i = GetXindx(Yellow_Robot.getPosition().x - 20); left.j = Robot_yindx;
  784.         up.i = Robot_xindx; up.j = GetYindx(Yellow_Robot.getPosition().y - 7);
  785.         down.i = Robot_xindx; down.j = GetYindx(Yellow_Robot.getPosition().y + 7);
  786.         //######################################################################################################
  787.                                     // Robot Movement //
  788.         if (Yellow_Robot_Counter >= 250)
  789.         {
  790.             Yellow_Robot_Rand_motion = rand() % 4 + 1;
  791.             Yellow_Robot_Counter = 0;
  792.         }
  793.  
  794.         if (Yellow_Robot_Rand_motion == 1)                                          // Moving UP => Rand_motion == 1
  795.         {
  796.             Yellow_Robot_Counter++;
  797.             if (Grid[GetXindx(Yellow_Robot.getPosition().x + 25)][up.j].getTexture() == &ground || Grid[up.i][up.j].getTexture() == &ground2)
  798.             {
  799.  
  800.                 Movement_Upward(Yellow_Robot, Yellow_Robot_time, Yellow_Robot_clock, Yellow_Robot_position, Yellow_Robot_size, Yellow_Robot_speed);
  801.  
  802.             }
  803.             else
  804.             {
  805.                 Yellow_Robot_Counter = 250;
  806.             }
  807.  
  808.         }
  809.  
  810.  
  811.         else if (Yellow_Robot_Rand_motion == 2)                                 // Moving Down => Rand_motion == 2
  812.         {
  813.             Yellow_Robot_Counter++;
  814.             if (Grid[GetXindx(Yellow_Robot.getPosition().x + 25)][down.j].getTexture() == &ground || Grid[down.i][down.j].getTexture() == &ground2)
  815.             {
  816.                 Movement_Downward(Yellow_Robot, Yellow_Robot_time, Yellow_Robot_clock, Yellow_Robot_position, Yellow_Robot_size, Yellow_Robot_speed);
  817.             }
  818.  
  819.             else
  820.             {
  821.                 Yellow_Robot_Counter = 250;
  822.             }
  823.         }
  824.  
  825.  
  826.         else if (Yellow_Robot_Rand_motion == 3)                                 // Moving Right => Rand_motion == 3
  827.         {
  828.             Yellow_Robot_Counter++;
  829.             if (Grid[right.i][right.j].getTexture() == &ground || Grid[right.i][right.j].getTexture() == &ground2)
  830.             {
  831.                 Movement_Right(Yellow_Robot, Yellow_Robot_time, Yellow_Robot_clock, Yellow_Robot_position, Yellow_Robot_size, Yellow_Robot_speed);
  832.             }
  833.             else
  834.             {
  835.                 Yellow_Robot_Counter = 250;
  836.             }
  837.         }
  838.  
  839.  
  840.         else if (Yellow_Robot_Rand_motion == 4)                                 // Moving Left => Rand_motion == 4
  841.         {
  842.             Yellow_Robot_Counter++;
  843.             if (Grid[left.i][left.j].getTexture() == &ground || Grid[left.i][left.j].getTexture() == &ground2)
  844.             {
  845.                 Movement_Left(Yellow_Robot, Yellow_Robot_time, Yellow_Robot_clock, Yellow_Robot_position, Yellow_Robot_size, Yellow_Robot_speed);
  846.             }
  847.             else
  848.             {
  849.                 Yellow_Robot_Counter = 250;
  850.             }
  851.  
  852.         }
  853.  
  854.         // Skeleton movement
  855.         Skeleton_xindx = (float)((float)(Skeleton.getPosition().x - 183) / 53 + 2);
  856.         Skeleton_yindx = (float)((float)(Skeleton.getPosition().y - 74) / 48 + 2);
  857.         right.i = GetXindx(Skeleton.getPosition().x + 20); right.j = Skeleton_yindx;
  858.         left.i = GetXindx(Skeleton.getPosition().x - 20); left.j = Skeleton_yindx;
  859.         up.i = Skeleton_xindx; up.j = GetYindx(Skeleton.getPosition().y - 7);
  860.         down.i = Skeleton_xindx; down.j = GetYindx(Skeleton.getPosition().y + 7);
  861.  
  862.         // Skeleton Movement
  863.         if (Skeleton_counter >= 250)
  864.         {
  865.             Skeleton_Rand_motion = rand() % 4 + 1;
  866.             Skeleton_counter = 0;
  867.         }
  868.  
  869.         if (Skeleton_Rand_motion == 1)                                          // Moving UP => Rand_motion == 1
  870.         {
  871.             Skeleton_counter++;
  872.             if (Grid[GetXindx(Skeleton.getPosition().x + 25)][up.j].getTexture() == &ground || Grid[up.i][up.j].getTexture() == &ground2)
  873.             {
  874.                 Movement_Upward(Skeleton, Skeleton_time, Skeleton_clock, Skeleton_position, Skeleton_size, Random_Monsters_Speed);
  875.             }
  876.             else
  877.             {
  878.                 Skeleton_counter = 250;
  879.             }
  880.  
  881.         }
  882.  
  883.  
  884.         else if (Skeleton_Rand_motion == 2)                                 // Moving Down => Rand_motion == 2
  885.         {
  886.             Skeleton_counter++;
  887.             if (Grid[GetXindx(Skeleton.getPosition().x + 25)][down.j].getTexture() == &ground || Grid[down.i][down.j].getTexture() == &ground2)
  888.             {
  889.                 Movement_Downward(Skeleton, Skeleton_time, Skeleton_clock, Skeleton_position, Skeleton_size, Random_Monsters_Speed);
  890.             }
  891.  
  892.             else
  893.             {
  894.                 Skeleton_counter = 250;
  895.             }
  896.         }
  897.  
  898.  
  899.         else if (Skeleton_Rand_motion == 3)                                 // Moving Right => Rand_motion == 3
  900.         {
  901.             Skeleton_counter++;
  902.             if (Grid[right.i][right.j].getTexture() == &ground || Grid[right.i][right.j].getTexture() == &ground2)
  903.             {
  904.                 Movement_Right(Skeleton, Skeleton_time, Skeleton_clock, Skeleton_position, Skeleton_size, Random_Monsters_Speed);
  905.  
  906.  
  907.             }
  908.             else
  909.             {
  910.                 Skeleton_counter = 250;
  911.             }
  912.         }
  913.  
  914.  
  915.         else if (Skeleton_Rand_motion == 4)                                 // Moving Left => Rand_motion == 4
  916.         {
  917.             Skeleton_counter++;
  918.             if (Grid[left.i][left.j].getTexture() == &ground || Grid[left.i][left.j].getTexture() == &ground2)
  919.             {
  920.  
  921.                 Movement_Left(Skeleton, Skeleton_time, Skeleton_clock, Skeleton_position, Skeleton_size, Random_Monsters_Speed);
  922.  
  923.             }
  924.             else
  925.             {
  926.                 Skeleton_counter = 250;
  927.             }
  928.  
  929.         }
  930.  
  931.         //######################################################################################################
  932.         // White_Robot movement
  933.         White_Robot_xindx = (float)((float)(White_Robot.getPosition().x - 183) / 53 + 2);
  934.         White_Robot_yindx = (float)((float)(White_Robot.getPosition().y - 74) / 48 + 2);
  935.         right.i = GetXindx(White_Robot.getPosition().x + 20); right.j = White_Robot_yindx;
  936.         left.i = GetXindx(White_Robot.getPosition().x - 20); left.j = White_Robot_yindx;
  937.         up.i = White_Robot_xindx; up.j = GetYindx(White_Robot.getPosition().y - 7);
  938.         down.i = White_Robot_xindx; down.j = GetYindx(White_Robot.getPosition().y + 7);
  939.         //######################################################################################################
  940.  
  941.         //######################################################################################################
  942.         // White_Robot Movement
  943.         if (White_Robot_counter >= 250)
  944.         {
  945.             White_Robot_Rand_motion = rand() % 4 + 1;
  946.             White_Robot_counter = 0;
  947.         }
  948.  
  949.         if (White_Robot_Rand_motion == 1)                                           // Moving UP => Rand_motion == 1
  950.         {
  951.             White_Robot_counter++;
  952.             if (Grid[GetXindx(White_Robot.getPosition().x + 25)][up.j].getTexture() == &ground || Grid[up.i][up.j].getTexture() == &ground2)
  953.             {
  954.                 Movement_Upward(White_Robot, White_Robot_time, White_Robot_clock, White_Robot_position, White_Robot_size, Random_Monsters_Speed);
  955.             }
  956.             else
  957.             {
  958.                 White_Robot_counter = 250;
  959.             }
  960.  
  961.         }
  962.  
  963.  
  964.         else if (White_Robot_Rand_motion == 2)                                  // Moving Down => Rand_motion == 2
  965.         {
  966.             White_Robot_counter++;
  967.             if (Grid[GetXindx(White_Robot.getPosition().x + 25)][down.j].getTexture() == &ground || Grid[down.i][down.j].getTexture() == &ground2)
  968.             {
  969.                 Movement_Downward(White_Robot, White_Robot_time, White_Robot_clock, White_Robot_position, White_Robot_size, Random_Monsters_Speed);
  970.             }
  971.  
  972.             else
  973.             {
  974.                 White_Robot_counter = 250;
  975.             }
  976.         }
  977.  
  978.  
  979.         else if (White_Robot_Rand_motion == 3)                                  // Moving Right => Rand_motion == 3
  980.         {
  981.             White_Robot_counter++;
  982.             if (Grid[right.i][right.j].getTexture() == &ground || Grid[right.i][right.j].getTexture() == &ground2)
  983.             {
  984.                 Movement_Right(White_Robot, White_Robot_time, White_Robot_clock, White_Robot_position, White_Robot_size, Random_Monsters_Speed);
  985.  
  986.             }
  987.             else
  988.             {
  989.                 White_Robot_counter = 250;
  990.             }
  991.         }
  992.  
  993.  
  994.         else if (White_Robot_Rand_motion == 4)                                  // Moving Left => Rand_motion == 4
  995.         {
  996.             White_Robot_counter++;
  997.             if (Grid[left.i][left.j].getTexture() == &ground || Grid[left.i][left.j].getTexture() == &ground2)
  998.             {
  999.                 Movement_Left(White_Robot, White_Robot_time, White_Robot_clock, White_Robot_position, White_Robot_size, Random_Monsters_Speed);
  1000.             }
  1001.             else
  1002.             {
  1003.                 White_Robot_counter = 250;
  1004.             }
  1005.  
  1006.         }
  1007.  
  1008.         //######################################################################################################
  1009.  
  1010.         // Player Movement
  1011.         Player_xindx = (float)((float)(player.getPosition().x - 183) / 53 + 2);
  1012.         Player_yindx = (float)((float)(player.getPosition().y - 74) / 48 + 2);
  1013.         right.i = GetXindx(player.getPosition().x + 20); right.j = Player_yindx;
  1014.         left.i = GetXindx(player.getPosition().x - 20); left.j = Player_yindx;
  1015.         up.i = Player_xindx; up.j = GetYindx(player.getPosition().y - 7);
  1016.         down.i = Player_xindx; down.j = GetYindx(player.getPosition().y + 7);
  1017.  
  1018.         if (Keyboard::isKeyPressed(Keyboard::Key::Right) && (Grid[right.i][right.j].getTexture() == &ground || Grid[right.i][right.j].getTexture() == &ground2))      // Moving Right
  1019.         {
  1020.             bool check_bomb = 0;
  1021.             for (int io = 0; io < bombs.size(); io++)
  1022.             {
  1023.                 if (bombs[io].x_index == GetXindx(player.getPosition().x + 1) && bombs[io].x_index != GetXindx(player.getPosition().x) && bombs[io].y_index == right.j)
  1024.                 {
  1025.                     check_bomb = 1; break;
  1026.                 }
  1027.             }
  1028.             if (!check_bomb)
  1029.                 Movement_Right(player, player_time, player_clock, player_position, player_size, player_speed);
  1030.         }
  1031.         else if (Keyboard::isKeyPressed(Keyboard::Key::Left) && (Grid[left.i][left.j].getTexture() == &ground || Grid[left.i][left.j].getTexture() == &ground2))         // Moving Left
  1032.         {
  1033.             bool check_bomb = 0;
  1034.             for (int io = 0; io < bombs.size(); io++)
  1035.             {
  1036.                 if (bombs[io].x_index == GetXindx(player.getPosition().x - 1) && bombs[io].x_index != GetXindx(player.getPosition().x) && bombs[io].y_index == left.j)
  1037.                 {
  1038.                     check_bomb = 1; break;
  1039.                 }
  1040.             }
  1041.             if (!check_bomb)
  1042.                 Movement_Left(player, player_time, player_clock, player_position, player_size, player_speed);
  1043.         }
  1044.         else if (Keyboard::isKeyPressed(Keyboard::Key::Up) && (Grid[GetXindx(player.getPosition().x + 25)][up.j].getTexture() == &ground || Grid[up.i][up.j].getTexture() == &ground2))           // Moving Up
  1045.         {
  1046.             bool check_bomb = 0;
  1047.             for (int io = 0; io < bombs.size(); io++)
  1048.             {
  1049.                 if (bombs[io].y_index == GetYindx(player.getPosition().y - 1) && bombs[io].y_index != GetYindx(player.getPosition().y) && bombs[io].x_index == up.i)
  1050.                 {
  1051.                     check_bomb = 1; break;
  1052.                 }
  1053.             }
  1054.             if (!check_bomb)
  1055.  
  1056.                 Movement_Upward(player, player_time, player_clock, player_position, player_size, player_speed);
  1057.         }
  1058.         else if (Keyboard::isKeyPressed(Keyboard::Key::Down) && (Grid[GetXindx(player.getPosition().x + 25)][down.j].getTexture() == &ground || Grid[down.i][down.j].getTexture() == &ground2))         // Moving Down
  1059.         {
  1060.             bool check_bomb = 0;
  1061.             for (int io = 0; io < bombs.size(); io++)
  1062.             {
  1063.                 if (bombs[io].y_index == GetYindx(player.getPosition().y + 1) && bombs[io].y_index != GetYindx(player.getPosition().y) && bombs[io].x_index == up.i)
  1064.                 {
  1065.                     check_bomb = 1; break;
  1066.                 }
  1067.             }
  1068.             if (!check_bomb)
  1069.  
  1070.                 Movement_Downward(player, player_time, player_clock, player_position, player_size, player_speed);
  1071.         }
  1072.  
  1073.         //######################################################################################################
  1074.  
  1075.         Event event;
  1076.         while (Level_1.pollEvent(event))
  1077.         {
  1078.             if (event.type == sf::Event::Closed || Keyboard::isKeyPressed(Keyboard::Escape))
  1079.                 Level_1.close();
  1080.  
  1081.         }
  1082.  
  1083.         //#####################################################################################################
  1084.         // Bombing stuff
  1085.         //#####################################################################################################
  1086.         // Bombing stuff
  1087.             // bombing
  1088.  
  1089.         if (bomb_placement_timer < 80)
  1090.         {
  1091.             bomb_placement_timer++;
  1092.         }
  1093.         if (Keyboard::isKeyPressed(Keyboard::Key::Space) && bomb_placement_timer == 80 && counter_placed_bombs < boombs) {
  1094.             bombs.push_back(bomb_template);
  1095.             bombs[bombs.size() - 1].bomb_clock.restart();
  1096.             bombs[bombs.size() - 1].explosion_clock.restart();
  1097.             bombs[bombs.size() - 1].start_clock.restart();
  1098.             bombs[bombs.size() - 1].bomb_placed = 1;
  1099.             bombs[bombs.size() - 1].x_pos = GetXpostion(Player_xindx) + 12;
  1100.             bombs[bombs.size() - 1].y_pos = GetYpostion(Player_yindx) + 12;
  1101.             bombs[bombs.size() - 1].sprt.setPosition(bombs[bombs.size() - 1].x_pos, bombs[bombs.size() - 1].y_pos);
  1102.             bombs[bombs.size() - 1].sprt.setTextureRect(IntRect(0, text_size_bomb.y * bombs[bombs.size() - 1].bomb_animation_y, text_size_bomb.x, text_size_bomb.y));
  1103.             bombs[bombs.size() - 1].x_index = GetXindx(bombs[bombs.size() - 1].x_pos);
  1104.             bombs[bombs.size() - 1].y_index = GetYindx(bombs[bombs.size() - 1].y_pos);
  1105.             bomb_placement_timer = 0;
  1106.             counter_placed_bombs++;
  1107.         }
  1108.  
  1109.         for (int io = 0; io < bombs.size(); io++)
  1110.         {
  1111.             if (bombs[io].bomb_placed == 1) {
  1112.                 bombs[io].bomb_time = bombs[io].bomb_clock.getElapsedTime();
  1113.                 bombs[io].start_explosion = bombs[io].start_clock.getElapsedTime();
  1114.                 if (bombs[io].bomb_time.asSeconds() >= 0.2) {
  1115.                     bombs[io].bomb_clock.restart();
  1116.                     bombs[io].sprt.setPosition(bombs[io].x_pos, bombs[io].y_pos + 25);
  1117.                     bombs[io].sprt.setTextureRect(IntRect(0, text_size_bomb.y * bombs[io].bomb_animation_y, text_size_bomb.x, text_size_bomb.y));
  1118.                     bombs[io].bomb_animation_y += 2;
  1119.                     if (bombs[io].bomb_animation_y > 2)
  1120.                         bombs[io].bomb_animation_y = 0;
  1121.                 }
  1122.                 if (bombs[io].start_explosion.asSeconds() >= 3) {
  1123.                     bombs[io].bomb_exploded = 1;
  1124.                     bombs[io].bomb_placed = 0;
  1125.                     //                bombs[number_of_bombs].sprt.setColor(Color::Transparent);
  1126.                     for (int k = 0; k <= range_of_bomb; k++)
  1127.                     {
  1128.                         bombs[io].range_right.push_back(exp);
  1129.                         bombs[io].range_left.push_back(exp);
  1130.                         bombs[io].range_up.push_back(exp);
  1131.                         bombs[io].range_down.push_back(exp);
  1132.                         //                     v[z].push_back(exp);
  1133.                     }
  1134.                 }
  1135.             }
  1136.             //cout<<player.getPosition().x<<' '<<player.getPosition().y<<endl;
  1137.             if (bombs[io].bomb_exploded) {
  1138.                 bombs[io].explosion_time = bombs[io].explosion_clock.getElapsedTime();
  1139.                 if (bombs[io].explosion_time.asSeconds() >= 0.08) {
  1140.                     bombs[io].explosion_clock.restart();
  1141.                     for (int n = 0, k = 0; k < bombs[io].range_right.size(), n <= range_of_bomb * 50; k++, n += 50)
  1142.                         bombs[io].range_right[k].setPosition(bombs[io].x_pos + n, bombs[io].y_pos);
  1143.  
  1144.                     for (int n = 0, k = 0; k < bombs[io].range_right.size(), n <= range_of_bomb * 50; k++, n += 50)
  1145.                         bombs[io].range_right[k].setTextureRect(IntRect(text_size_exp.x * bombs[io].exp_animation_x, text_size_exp.y * bombs[io].exp_animation_y, text_size_exp.x, text_size_exp.y));
  1146.  
  1147.                     for (int n = 0, k = 0; k < bombs[io].range_left.size(), n <= range_of_bomb * 50; k++, n += 50)
  1148.                         bombs[io].range_left[k].setPosition(bombs[io].x_pos - n, bombs[io].y_pos);
  1149.  
  1150.                     for (int n = 0, k = 0; k < bombs[io].range_left.size(), n <= range_of_bomb * 50; k++, n += 50)
  1151.                         bombs[io].range_left[k].setTextureRect(IntRect(text_size_exp.x * bombs[io].exp_animation_x, text_size_exp.y * bombs[io].exp_animation_y, text_size_exp.x, text_size_exp.y));
  1152.  
  1153.                     for (int n = 0, k = 0; k < bombs[io].range_up.size(), n <= range_of_bomb * 50; k++, n += 50)
  1154.                         bombs[io].range_up[k].setPosition(bombs[io].x_pos, bombs[io].y_pos - n);
  1155.  
  1156.                     for (int n = 0, k = 0; k < bombs[io].range_up.size(), n <= range_of_bomb * 50; k++, n += 50)
  1157.                         bombs[io].range_up[k].setTextureRect(IntRect(text_size_exp.x * bombs[io].exp_animation_x, text_size_exp.y * bombs[io].exp_animation_y, text_size_exp.x, text_size_exp.y));
  1158.  
  1159.                     for (int n = 0, k = 0; k < bombs[io].range_down.size(), n <= range_of_bomb * 50; k++, n += 50)
  1160.                         bombs[io].range_down[k].setPosition(bombs[io].x_pos, bombs[io].y_pos + n);
  1161.  
  1162.                     for (int n = 0, k = 0; k < bombs[io].range_down.size(), n <= range_of_bomb * 50; k++, n += 50)
  1163.                         bombs[io].range_down[k].setTextureRect(IntRect(text_size_exp.x * bombs[io].exp_animation_x, text_size_exp.y * bombs[io].exp_animation_y, text_size_exp.x, text_size_exp.y));
  1164.  
  1165.                     bombs[io].exp_animation_x++;
  1166.                     if (bombs[io].exp_animation_x == 3) {
  1167.                         bombs[io].exp_animation_x = 0, bombs[io].exp_animation_y++;
  1168.                         if (bombs[io].exp_animation_y == 3) {
  1169.                             bombs[io].bomb_exploded = 0;
  1170.                             bombs.erase(bombs.begin());
  1171.                             counter_placed_bombs--;
  1172.                         }
  1173.                     }
  1174.                 }
  1175.             }
  1176.         }
  1177.         //}
  1178.         // Drawing of the Wallpaper
  1179.         Level_1.clear();
  1180.         Level_1.draw(Wallpaper);
  1181.         //}
  1182.         // Drawing of the Wallpaper
  1183.         Level_1.clear();
  1184.         Level_1.draw(Wallpaper);
  1185.         //}
  1186.         //#####################################################################################################
  1187.         bool death_flag = 0;
  1188.  
  1189.  
  1190.  
  1191.         //Drawing of The Map
  1192.         for (int i = 2; i < width; i++)
  1193.         {
  1194.             for (int j = 2; j < length; j++)
  1195.             {
  1196.                 if (Grid[i][j].getTexture() == &ground || Grid[i][j].getTexture() == &ground2)
  1197.                 {
  1198.                     Level_1.draw(Grid[i][j]);
  1199.                 }
  1200.             }
  1201.  
  1202.         }
  1203.  
  1204.         for (int i = 0; i < 14; i++)
  1205.         {
  1206.             Level_1.draw(SuperPowers[i]);
  1207.         }
  1208.  
  1209.         for (int j = 1; j <= length; j++)
  1210.         {
  1211.             for (int i = 1; i <= width; i++)
  1212.             {
  1213.                 if (Grid[i][j].getTexture() == &ground || Grid[i][j].getTexture() == &ground2)
  1214.                 {
  1215.                     continue;
  1216.                 }
  1217.  
  1218.                 Level_1.draw(Grid[i][j]);
  1219.  
  1220.                 if (GetYindx(player.getPosition().y) >= j)
  1221.                 {
  1222.                     Level_1.draw(player);
  1223.                 }
  1224.  
  1225.                 if (GetYindx(Yellow_Robot.getPosition().y) >= j && !Yellow_Robot_death)
  1226.                 {
  1227.                     Level_1.draw(Yellow_Robot);
  1228.                 }
  1229.                 if (GetYindx(Skeleton.getPosition().y) >= j && !Skeleton_death)
  1230.                 {
  1231.                     Level_1.draw(Skeleton);
  1232.                 }
  1233.                 if (GetYindx(White_Robot.getPosition().y) >= j && !White_Robot_death)
  1234.                 {
  1235.                     Level_1.draw(White_Robot);
  1236.                 }
  1237.                 for (int io = 0; io < bombs.size(); io++)
  1238.                 {
  1239.                     if (bombs[io].y_index >= j && bombs[io].bomb_placed)
  1240.                     {
  1241.                         Level_1.draw(bombs[io].sprt);
  1242.                     }
  1243.                 }
  1244.  
  1245.             }
  1246.         }
  1247.  
  1248.         // Drawing Bombs
  1249.         for (int io = 0; io < bombs.size(); io++)
  1250.         {
  1251.             //if (bombs[io].bomb_placed)
  1252.                 //window.draw(bombs[io].sprt);
  1253.             if (bombs[io].bomb_exploded)
  1254.             {
  1255.  
  1256.                 //Right
  1257.                 for (int g = 0; g < bombs[io].range_right.size(); g++)
  1258.                 {
  1259.  
  1260.                     Level_1.draw(bombs[io].range_right[g]);
  1261.  
  1262.                     if ((Grid[bombs[io].x_index + g][bombs[io].y_index].getTexture() == &breakable) && bombs[io].flag_range_right)
  1263.                     {
  1264.                         destroy_breakable_walls(bombs[io].x_index + g, bombs[io].y_index, Grid, ground, ground2);
  1265.                         bombs[io].flag_range_right = 0;
  1266.                         break;
  1267.                     }
  1268.                     else if (Grid[bombs[io].x_index + g][bombs[io].y_index].getTexture() == &wall)
  1269.                     {
  1270.  
  1271.                         bombs[io].flag_range_right = 0;
  1272.                         break;
  1273.                     }
  1274.  
  1275.                     if (bombs[io].x_index + g == Player_xindx && bombs[io].y_index == Player_yindx && bombs[io].flag_range_right)
  1276.                     {
  1277.                         if (Clock_Damgae.getElapsedTime().asSeconds() >= 1) {
  1278.                             lives--;
  1279.                             ssl = to_string(lives);
  1280.                             Clock_Damgae.restart();
  1281.                         }
  1282.                         Level_1.draw(Hurt);
  1283.                     }
  1284.  
  1285.                     if (bombs[io].x_index + g == Robot_xindx && bombs[io].y_index == Robot_yindx && bombs[io].flag_range_right)
  1286.                     {
  1287.                         Yellow_Robot_death = 1;
  1288.                         Yellow_Robot.setFillColor(Color::Transparent);
  1289.                     }
  1290.                     if (bombs[io].x_index + g == White_Robot_xindx && bombs[io].y_index == White_Robot_yindx && bombs[io].flag_range_right)
  1291.                     {
  1292.                         White_Robot_death = 1;
  1293.                         White_Robot.setFillColor(Color::Transparent);
  1294.                     }
  1295.                     if (bombs[io].x_index + g == Skeleton_xindx && bombs[io].y_index == Skeleton_yindx && bombs[io].flag_range_right)
  1296.                     {
  1297.                         Skeleton_death = 1;
  1298.                         Skeleton.setFillColor(Color::Transparent);
  1299.                     }
  1300.  
  1301.  
  1302.  
  1303.                 }
  1304.  
  1305.  
  1306.                 //UP
  1307.                 for (int g = 0; g < bombs[io].range_up.size(); g++)
  1308.                 {
  1309.  
  1310.                     Level_1.draw(bombs[io].range_up[g]);
  1311.  
  1312.                     if ((Grid[bombs[io].x_index][bombs[io].y_index - g].getTexture() == &breakable) && bombs[io].flag_range_up)
  1313.                     {
  1314.  
  1315.  
  1316.                         destroy_breakable_walls(bombs[io].x_index, bombs[io].y_index - g, Grid, ground, ground2);
  1317.  
  1318.                         bombs[io].flag_range_up = 0;
  1319.                         break;
  1320.  
  1321.                     }
  1322.                     else if (Grid[bombs[io].x_index][bombs[io].y_index - g].getTexture() == &wall)
  1323.                     {
  1324.  
  1325.                         bombs[io].flag_range_up = 0;
  1326.                         break;
  1327.                     }
  1328.  
  1329.                     if (bombs[io].x_index == Player_xindx && bombs[io].y_index - g == Player_yindx && bombs[io].flag_range_up)
  1330.                     {
  1331.                         if (Clock_Damgae.getElapsedTime().asSeconds() >= 1) {
  1332.                             lives--;
  1333.                             ssl = to_string(lives);
  1334.                             Clock_Damgae.restart();
  1335.                         }
  1336.                         Level_1.draw(Hurt);
  1337.                     }
  1338.  
  1339.                     if (bombs[io].x_index == Robot_xindx && bombs[io].y_index - g == Robot_yindx && bombs[io].flag_range_up)
  1340.                     {
  1341.                         Yellow_Robot_death = 1;
  1342.                         Yellow_Robot.setFillColor(Color::Transparent);
  1343.                     }
  1344.                     if (bombs[io].x_index == White_Robot_xindx && bombs[io].y_index - g == White_Robot_yindx && bombs[io].flag_range_up)
  1345.                     {
  1346.                         White_Robot_death = 1;
  1347.                         White_Robot.setFillColor(Color::Transparent);
  1348.                     }
  1349.                     if (bombs[io].x_index == Skeleton_xindx && bombs[io].y_index - g == Skeleton_yindx && bombs[io].flag_range_up)
  1350.                     {
  1351.                         Skeleton_death = 1;
  1352.                         Skeleton.setFillColor(Color::Transparent);
  1353.                     }
  1354.  
  1355.  
  1356.                 }
  1357.  
  1358.                 //Left
  1359.                 for (int g = 0; g < bombs[io].range_left.size(); g++)
  1360.                 {
  1361.  
  1362.                     Level_1.draw(bombs[io].range_left[g]);
  1363.  
  1364.                     if ((Grid[bombs[io].x_index - g][bombs[io].y_index].getTexture() == &breakable) && bombs[io].flag_range_left)
  1365.                     {
  1366.                         destroy_breakable_walls(bombs[io].x_index - g, bombs[io].y_index, Grid, ground, ground2);
  1367.  
  1368.                         bombs[io].flag_range_left = 0;
  1369.                         break;
  1370.                     }
  1371.                     else if (Grid[bombs[io].x_index - g][bombs[io].y_index].getTexture() == &wall)
  1372.                     {
  1373.                         bombs[io].flag_range_left = 0;
  1374.                         break;
  1375.                     }
  1376.                     if (bombs[io].x_index - g == Player_xindx && bombs[io].y_index == Player_yindx && bombs[io].flag_range_left)
  1377.                     {
  1378.                         if (Clock_Damgae.getElapsedTime().asSeconds() >= 1) {
  1379.                             lives--;
  1380.                             ssl = to_string(lives);
  1381.                             Clock_Damgae.restart();
  1382.                         }
  1383.                         Level_1.draw(Hurt);
  1384.                     }
  1385.  
  1386.                     if (bombs[io].x_index - g == Robot_xindx - g && bombs[io].y_index == Robot_yindx && bombs[io].flag_range_left)
  1387.                     {
  1388.                         Yellow_Robot_death = 1;
  1389.                         Yellow_Robot.setFillColor(Color::Transparent);
  1390.                     }
  1391.                     if (bombs[io].x_index - g == White_Robot_xindx && bombs[io].y_index == White_Robot_yindx && bombs[io].flag_range_left)
  1392.                     {
  1393.                         White_Robot_death = 1;
  1394.                         White_Robot.setFillColor(Color::Transparent);
  1395.                     }
  1396.                     if (bombs[io].x_index - g == Skeleton_xindx && bombs[io].y_index == Skeleton_yindx && bombs[io].flag_range_left)
  1397.                     {
  1398.                         Skeleton_death = 1;
  1399.                         Skeleton.setFillColor(Color::Transparent);
  1400.                     }
  1401.  
  1402.  
  1403.                 }
  1404.  
  1405.                 //Down
  1406.                 for (int g = 0; g < bombs[io].range_down.size(); g++)
  1407.                 {
  1408.  
  1409.                     Level_1.draw(bombs[io].range_down[g]);
  1410.                     if ((Grid[bombs[io].x_index][bombs[io].y_index + g].getTexture() == &breakable) && bombs[io].flag_range_down)
  1411.                     {
  1412.                         destroy_breakable_walls(bombs[io].x_index, bombs[io].y_index + g, Grid, ground, ground2);
  1413.                         bombs[io].flag_range_down = 0;
  1414.                         break;
  1415.                     }
  1416.                     else if (Grid[bombs[io].x_index][bombs[io].y_index + g].getTexture() == &wall)
  1417.                     {
  1418.  
  1419.                         bombs[io].flag_range_down = 0;
  1420.                         break;
  1421.                     }
  1422.                     if (bombs[io].x_index == Player_xindx && bombs[io].y_index + g == Player_yindx && bombs[io].flag_range_down)
  1423.                     {
  1424.                         if (Clock_Damgae.getElapsedTime().asSeconds() >= 1) {
  1425.                             lives--;
  1426.                             ssl = to_string(lives);
  1427.                             Clock_Damgae.restart();
  1428.                         }
  1429.                         Level_1.draw(Hurt);
  1430.                     }
  1431.  
  1432.                     if (bombs[io].x_index == Robot_xindx && bombs[io].y_index + g == Robot_yindx && bombs[io].flag_range_down)
  1433.                     {
  1434.                         Yellow_Robot_death = 1;
  1435.                         Yellow_Robot.setFillColor(Color::Transparent);
  1436.                     }
  1437.                     if (bombs[io].x_index == White_Robot_xindx && bombs[io].y_index + g == White_Robot_yindx && bombs[io].flag_range_down)
  1438.                     {
  1439.                         White_Robot_death = 1;
  1440.                         White_Robot.setFillColor(Color::Transparent);
  1441.                     }
  1442.                     if (bombs[io].x_index == Skeleton_xindx && bombs[io].y_index + g == Skeleton_yindx && bombs[io].flag_range_down)
  1443.                     {
  1444.                         Skeleton_death = 1;
  1445.                         Skeleton.setFillColor(Color::Transparent);
  1446.                     }
  1447.  
  1448.                 }
  1449.  
  1450.             }
  1451.         }
  1452.  
  1453.  
  1454.         //############################################################################################//############################################################################################
  1455.  
  1456.         for (int i = 0; i < 14; i++) {
  1457.             int sumP = 0; int sumR = 0;
  1458.             sumP = GetXindx(player.getPosition().x) + GetYindx(player.getPosition().y);
  1459.             sumR = GetXindx(SuperPowers[i].getPosition().x) + GetYindx(SuperPowers[i].getPosition().y);
  1460.  
  1461.             if (sumR == sumP + 1 && (GetXindx(SuperPowers[i].getPosition().x) == GetXindx(player.getPosition().x))
  1462.                 && !visted[GetXindx(SuperPowers[i].getPosition().x)][GetYindx(SuperPowers[i].getPosition().y)])
  1463.             {
  1464.  
  1465.                 visted[GetXindx(SuperPowers[i].getPosition().x)][GetYindx(SuperPowers[i].getPosition().y)] = 1;
  1466.  
  1467.                 if (SuperPowers[i].getTexture() == &rangeskill) {
  1468.  
  1469.  
  1470.                     temp_range_of_bomb++;
  1471.                     SuperPowers[i].setColor(Color::Transparent);
  1472.                     ss = to_string(temp_range_of_bomb);
  1473.  
  1474.                 }
  1475.                 else if (SuperPowers[i].getTexture() == &bombskill) {
  1476.                     boombs++;
  1477.                     SuperPowers[i].setColor(Color::Transparent);
  1478.                     sss = to_string(boombs);
  1479.  
  1480.  
  1481.                 }
  1482.                 else if (SuperPowers[i].getTexture() == &healskill) {
  1483.                     lives++;
  1484.                     SuperPowers[i].setColor(Color::Transparent);
  1485.                     ssl = to_string(lives);
  1486.                 }
  1487.             }
  1488.  
  1489.         }
  1490.  
  1491.  
  1492.  
  1493.         bool isbombing = 0;
  1494.         for (int io = 0; io < bombs.size(); io++)
  1495.         {
  1496.             if (bombs[io].bomb_exploded) { isbombing = 1; break; }
  1497.         }
  1498.         if (!isbombing)
  1499.         {
  1500.             range_of_bomb = temp_range_of_bomb;
  1501.         }
  1502.         //############################################################################################
  1503.  
  1504.  
  1505.  
  1506.  
  1507.  
  1508.  
  1509.  
  1510.  
  1511.         if ((GetXindx(player.getPosition().x) == GetXindx(White_Robot.getPosition().x) && GetYindx(player.getPosition().y) == GetYindx(White_Robot.getPosition().y)) && !White_Robot_death) {
  1512.             if (Clock_Damgae.getElapsedTime().asSeconds() >= 1) {
  1513.                 lives--;
  1514.                 ssl = to_string(lives);
  1515.                 Clock_Damgae.restart();
  1516.             }
  1517.             Level_1.draw(Hurt);
  1518.  
  1519.         }
  1520.  
  1521.         if (GetXindx(player.getPosition().x) == GetXindx(Yellow_Robot.getPosition().x) && GetYindx(player.getPosition().y) == GetYindx(Yellow_Robot.getPosition().y) && !Yellow_Robot_death)
  1522.         {
  1523.             if (Clock_Damgae.getElapsedTime().asSeconds() >= 1) {
  1524.                 lives--;
  1525.                 ssl = to_string(lives);
  1526.                 Clock_Damgae.restart();
  1527.             }
  1528.             Level_1.draw(Hurt);
  1529.         }
  1530.  
  1531.         if (GetXindx(player.getPosition().x) == GetXindx(Skeleton.getPosition().x) && GetYindx(player.getPosition().y) == GetYindx(Skeleton.getPosition().y) && !Skeleton_death)
  1532.         {
  1533.             if (Clock_Damgae.getElapsedTime().asSeconds() >= 1) {
  1534.                 lives--;
  1535.                 ssl = to_string(lives);
  1536.                 Clock_Damgae.restart();
  1537.             }
  1538.             Level_1.draw(Hurt);
  1539.         }
  1540.  
  1541.         Level_1.draw(nooflives);
  1542.         Level_1.draw(noofbombs);
  1543.         Level_1.draw(noofranges);
  1544.  
  1545.         Level_1.draw(lifeS);
  1546.         Level_1.draw(rangeS);
  1547.         Level_1.draw(bombS);
  1548.         Level_1.draw(txt); // بيترسم تحت
  1549.         if (Player_xindx == 16 && Player_yindx == 10) {
  1550.             //ingame.stop();
  1551.             Level_1.clear(Color::Black), Level_1.draw(Level_complete);
  1552.             --elapsed;
  1553.             if (elapsed <= 1) {
  1554.                 exit(0);
  1555.             }
  1556.         }
  1557.  
  1558.         if (lives < 1) {
  1559.             ingame.stop();
  1560.             player.setFillColor(Color::Transparent);
  1561.             Tomb.setPosition(player.getPosition().x, player.getPosition().y);
  1562.             Level_1.draw(Tomb);
  1563.             --elapsed;
  1564.             if (elapsed <= 50 + 500) {
  1565.                 if (playsong) {
  1566.                     lost.play();
  1567.                     playsong = 0;
  1568.                 }
  1569.                 if (elapsed <= -500) {
  1570.                     Level_1.clear(Color::Black), Level_1.draw(RIP_Photo);
  1571.                     exit(0);
  1572.                 }
  1573.             }
  1574.         }
  1575.  
  1576.         if (Die) {
  1577.             ingame.stop();
  1578.             Level_1.clear(Color::Black), Level_1.draw(big_exp), Level_1.draw(RIP_Photo);
  1579.             --elapsed;
  1580.             if (elapsed <= 1) {
  1581.                 exit(0);
  1582.             }
  1583.         }
  1584.  
  1585.  
  1586.         Level_1.display();
  1587.  
  1588.  
  1589.     }
  1590.  
  1591. }
  1592. void Advanced_Level()
  1593. {
  1594.     ////////////////////////////////////////////////////////
  1595.     int big_pos_x = 1, big_pos_y = 0; //بيتعرف فوق
  1596.     Texture big_exp_text;
  1597.     big_exp_text.loadFromFile("exp.png");
  1598.     Sprite big_exp, RIP_photo, Tomb;
  1599.     big_exp.setTexture(big_exp_text);
  1600.     Vector2u text_size_big_exp = big_exp_text.getSize();
  1601.     text_size_big_exp.x /= 3;
  1602.     text_size_big_exp.y /= 3;
  1603.     big_exp.setScale(3, 3);
  1604.     Clock start_clock, timer_clock, clock_shutdown;
  1605.     Time start_timer, timer, timer_shutdown;
  1606.     int display_timer, minutes = 1;
  1607.     Text txt;
  1608.     Texture death_texture, tomb;
  1609.     tomb.loadFromFile("RIP.png");
  1610.     Tomb.setTexture(tomb);
  1611.     death_texture.loadFromFile("death.png");
  1612.     Font dis_time;
  1613.     if (!dis_time.loadFromFile("Chocolate Bar Demo.otf"))
  1614.     {
  1615.         cout << "error font";
  1616.     }
  1617.     RIP_photo.setTexture(death_texture);
  1618.     Tomb.setScale(0.1, 0.1);
  1619.     Texture Complete;
  1620.     Complete.loadFromFile("level-completed.png");
  1621.     Sprite Level_complete;
  1622.     Level_complete.setTexture(Complete);
  1623.     ////////////////////////////////////////////////////////
  1624.     Music ingame, lost;
  1625.     ingame.openFromFile("ingame.wav");
  1626.     lost.openFromFile("For the Damaged Coda.wav");
  1627.     ingame.play();
  1628.     ingame.setLoop(1);
  1629.  
  1630.     //======================================================================//
  1631.                         // Making of Player //
  1632.     RectangleShape player(Vector2f(100, 120));
  1633.     Texture player_texture;
  1634.     Vector2u player_size;
  1635.     Clock player_clock;
  1636.     Time player_time;
  1637.     float player_position = 0;
  1638.     const int player_speed = 2;
  1639.     Generate_Charcter(player, player_texture, player_size, "mainplayer.png", 2, 2);
  1640.     //======================================================================//
  1641.     Sprite timebombS, SuperPowers[19];
  1642.     Texture timebomb;
  1643.     Texture healskill, bombskill, rangeskill;
  1644.     timebomb.loadFromFile("time-bomb.png");
  1645.     healskill.loadFromFile("Heal .png");
  1646.     bombskill.loadFromFile("bomb skill .png");
  1647.     rangeskill.loadFromFile("Range skill.png");
  1648.     for (int i = 0; i < 5; i++)
  1649.     {
  1650.  
  1651.         SuperPowers[i].setTexture(healskill);           // Rand_Choice 1 => Bombing
  1652.         SuperPowers[i].setScale(0.5, 0.3);
  1653.  
  1654.     }
  1655.     for (int i = 5; i < 13; i++)
  1656.     {
  1657.         SuperPowers[i].setTexture(bombskill);       // Rand_Choice 2 => Health
  1658.         SuperPowers[i].setScale(0.5, 0.3);
  1659.     }
  1660.  
  1661.     for (int i = 13; i < 16; i++)
  1662.     {
  1663.         SuperPowers[i].setTexture(rangeskill);              // Rand_Choice 3 => Range
  1664.         SuperPowers[i].setScale(0.5, 0.3);
  1665.     }
  1666.     SuperPowers[18].setTexture(timebomb);               // Rand_Choice 3 => Range
  1667.     SuperPowers[18].setScale(0.05, 0.05);
  1668.     SuperPowers[0].setPosition(GetXpostion(16) + 20, GetYpostion(4));
  1669.     SuperPowers[1].setPosition(GetXpostion(14) + 20, GetYpostion(6));
  1670.     //SuperPowers[2].setPosition(GetXpostion(8) + 20, GetYpostion(8));
  1671.     SuperPowers[3].setPosition(GetXpostion(8) + 20, GetYpostion(10));
  1672.     SuperPowers[4].setPosition(GetXpostion(8) + 20, GetYpostion(5));
  1673.     SuperPowers[5].setPosition(GetXpostion(14) + 20, GetYpostion(10));
  1674.     SuperPowers[6].setPosition(GetXpostion(16) + 20, GetYpostion(6));
  1675.     SuperPowers[7].setPosition(GetXpostion(4) + 20, GetYpostion(6));
  1676.     SuperPowers[8].setPosition(GetXpostion(4) + 20, GetYpostion(7));
  1677.     SuperPowers[9].setPosition(GetXpostion(16) + 20, GetYpostion(8));
  1678.     SuperPowers[10].setPosition(GetXpostion(6) + 20, GetYpostion(10));
  1679.     SuperPowers[11].setPosition(GetXpostion(2) + 20, GetYpostion(8));
  1680.     SuperPowers[12].setPosition(GetXpostion(6) + 20, GetYpostion(6));
  1681.     SuperPowers[13].setPosition(GetXpostion(6) + 20, GetYpostion(5));
  1682.     //SuperPowers[14].setPosition(GetXpostion(16) + 20, GetYpostion(4));
  1683.     SuperPowers[15].setPosition(GetXpostion(12) + 20, GetYpostion(11));
  1684.     SuperPowers[16].setPosition(GetXpostion(16) + 20, GetYpostion(11));
  1685.     SuperPowers[17].setPosition(GetXpostion(12) + 20, GetYpostion(10));
  1686.     SuperPowers[18].setPosition(GetXpostion(16) + 15, GetYpostion(11));
  1687.  
  1688.     //======================================================================//
  1689.                         // Player abilities //
  1690.  
  1691.     // Making of Grid
  1692.     Texture wall, ground, wallpaper, ground2, breakable, life, bomb_frame, range, hurt, choice;
  1693.     if (!breakable.loadFromFile("breakable.png"))
  1694.     {
  1695.         cout << "error loading breakable wall pic";
  1696.     }
  1697.     if (!wallpaper.loadFromFile("wallpaper.jpg"))
  1698.     {
  1699.         cout << "error loading wallpaper pic";
  1700.     }
  1701.     if (!wall.loadFromFile("3d wall.png"))
  1702.     {
  1703.         cout << "error loading wall pic";
  1704.     }
  1705.  
  1706.     if (!ground.loadFromFile("ground 1.png"))
  1707.     {
  1708.         cout << "error loading ground pic";
  1709.     }
  1710.     if (!ground2.loadFromFile("grass.png"))
  1711.     {
  1712.         cout << "error loading grass pic";
  1713.     }
  1714.  
  1715.     if (!life.loadFromFile("flife.png"))
  1716.     {
  1717.         cout << "error loading life pic";
  1718.     }
  1719.     if (!range.loadFromFile("frange.png"))
  1720.     {
  1721.  
  1722.         cout << "error loading range pic";
  1723.     }
  1724.     if (!bomb_frame.loadFromFile("fbomb.png"))
  1725.     {
  1726.         cout << "error loading bomb pic";
  1727.     }
  1728.  
  1729.     if (!hurt.loadFromFile("hurt.png"))
  1730.     {
  1731.         cout << "error loading  hurt pic";
  1732.     }
  1733.  
  1734.  
  1735.  
  1736.     life.setSmooth(1);
  1737.     bomb_frame.setSmooth(1);
  1738.     hurt.setSmooth(1);
  1739.     range.setSmooth(1);
  1740.     //======================================================================//
  1741.     // player stuff
  1742.  
  1743.     Clock Clock_Damgae;
  1744.     Sprite lifeS, bombS, rangeS, Hurt;
  1745.     lifeS.setTexture(life);
  1746.     lifeS.setPosition(0, 250);
  1747.     lifeS.setScale(0.4f, 0.4f);
  1748.  
  1749.     rangeS.setTexture(range);
  1750.     rangeS.setPosition(0, 180);
  1751.     rangeS.setScale(0.4f, 0.4f);
  1752.  
  1753.     bombS.setTexture(bomb_frame);
  1754.     bombS.setPosition(0, 320);
  1755.     bombS.setScale(0.4f, 0.4f);
  1756.  
  1757.     Hurt.setTexture(hurt);
  1758.  
  1759.     //======================================================================//
  1760.  
  1761.     //======================================================================//
  1762.                      // Making of Yellow Robot //
  1763.  
  1764.     RectangleShape Yellow_Robot(Vector2f(100, 120));
  1765.     Texture Yellow_Robot_text;
  1766.     Vector2u Yellow_Robot_size;
  1767.     Clock Yellow_Robot_clock;
  1768.     Time Yellow_Robot_time;
  1769.     float Yellow_Robot_speed = 1;
  1770.     float Yellow_Robot_position = 0;
  1771.     int Yellow_Robot_Counter = 0;
  1772.     int Yellow_Robot_Rand_motion = rand() % 4 + 1;
  1773.     Generate_Charcter(Yellow_Robot, Yellow_Robot_text, Yellow_Robot_size, "yellow_robot.png", 10, 7);
  1774.     //======================================================================//
  1775.  
  1776.  
  1777.     //======================================================================//
  1778.                       // Making of White Robot //
  1779.  
  1780.     RectangleShape  White_Robot(Vector2f(100, 120));
  1781.     Texture  White_Robot_text;
  1782.     Vector2u  White_Robot_size;
  1783.     Clock  White_Robot_clock;
  1784.     Time  White_Robot_time;
  1785.     float White_Robot_speed = 1;
  1786.     float White_Robot_position = 0;
  1787.     int White_Robot_Counter = 0;
  1788.     int White_Robot_Rand_motion = rand() % 4 + 1;
  1789.     Generate_Charcter(White_Robot, White_Robot_text, White_Robot_size, "white_robot.png", 14, 3);
  1790.     //======================================================================//
  1791.  
  1792.  
  1793.     //======================================================================//
  1794.                 // Making of  Blue Skeleton  //
  1795.  
  1796.     RectangleShape Blue_Skeleton(Vector2f(100, 120));
  1797.     Texture Blue_Skeleton_text;
  1798.     Vector2u Blue_Skeleton_size;
  1799.     Clock Blue_Skeleton_clock;
  1800.     Time Blue_Skeleton_time;
  1801.     float Blue_Skeleton_speed = 0.5;
  1802.     float Blue_Skeleton_position = 0;
  1803.     Generate_Charcter(Blue_Skeleton, Blue_Skeleton_text, Blue_Skeleton_size, "smart_skeleton.png", 3, 8);
  1804.     //======================================================================//
  1805.  
  1806.  
  1807.  
  1808.     //======================================================================//
  1809.                     // Making of White Skeleton //  
  1810.  
  1811.     RectangleShape White_Skeleton(Vector2f(100, 120));
  1812.     Texture White_Skeleton_text;
  1813.     Vector2u White_Skeleton_text_size;
  1814.     Clock White_Skeleton_clock;
  1815.     Time White_Skeleton_time;
  1816.     float White_Skeleton_speed = 1;
  1817.     float  White_Skeleton_position = 0;
  1818.     int White_Skeleton_Counter = 0;
  1819.     int White_Skeleton_Rand_motion = rand() % 4 + 1;
  1820.     Generate_Charcter(White_Skeleton, White_Skeleton_text, White_Skeleton_text_size, "monster (5).png", 10, 3);
  1821.     //======================================================================//
  1822.  
  1823.  
  1824.     //###############################################################################
  1825.     // Movement stuff
  1826.     leftmovement left; rightmovement right; upmovement up; downmovement down;
  1827.     int Player_xindx = 0, Player_yindx = 0, White_Robot_xindx = 0, White_Robot_yindx = 0, Skeleton_xindx = 0, Skeleton_yindx = 0, Robot_xindx = 0, Robot_yindx = 0;
  1828.     //###############################################################################
  1829.  
  1830.  
  1831.  
  1832.  
  1833.                        // Making of Grid //
  1834.     //======================================================================//
  1835.                        // MAP DEFINATION //
  1836.  
  1837.     Sprite Wallpaper;
  1838.     Wallpaper.setTexture(wallpaper);
  1839.     //======================================================================//
  1840.  
  1841.     //======================================================================//
  1842.           // Distribution of wall ,breakable and ground on the Grid //
  1843.  
  1844.  
  1845.     Sprite Grid[width + 1][length + 1];
  1846.  
  1847.     for (int i = 1; i <= width; i++)      //  Distribution of wall and ground
  1848.     {
  1849.         for (int j = 1; j <= length; j++)
  1850.         {
  1851.             if (i % 2 != 0 && j % 2 != 0)
  1852.             {
  1853.  
  1854.                 Grid[i][j].setTexture(wall);
  1855.                 Grid[i][j].setPosition((i + 1.97) * 53.15, (j + 0.255) * 48);
  1856.                 Grid[i][j].setScale(Vector2f(0.1009, 0.165));
  1857.  
  1858.             }
  1859.  
  1860.             else if (i == 1 || i == width)
  1861.             {
  1862.                 Grid[i][j].setTexture(wall);
  1863.                 Grid[i][j].setPosition((i + 1.97) * 53.15, (j + 0.255) * 48);
  1864.                 Grid[i][j].setScale(Vector2f(0.1009, 0.165));
  1865.             }
  1866.             else if (j == 1 || j == length)
  1867.             {
  1868.                 Grid[i][j].setTexture(wall);
  1869.                 Grid[i][j].setPosition((i + 1.97) * 53.15, (j + 0.255) * 48);
  1870.                 Grid[i][j].setScale(Vector2f(0.1009, 0.165));
  1871.             }
  1872.             else
  1873.             {
  1874.                 if (i % 2 == j % 2) { Grid[i][j].setTexture(ground); }
  1875.                 else { Grid[i][j].setTexture(ground2); }
  1876.                 Grid[i][j].setPosition((i + 2) * 53, (j + 0.8) * 48);
  1877.                 Grid[i][j].setScale(0.1, 0.101);
  1878.             }
  1879.         }
  1880.     }
  1881.  
  1882.     for (int i = 1; i <= 40; i++)       //  Distribution of breakable
  1883.     {
  1884.         int x = rand() % 15 + 2, y = rand() % 9 + 2;
  1885.         if (x % 2 != 0 && y % 2 != 0)
  1886.         {
  1887.             x++;
  1888.         }
  1889.         Grid[x][y].setTexture(breakable);
  1890.         Grid[x][y].setPosition((x + 1.97) * 53.15, (y + 0.255) * 48);
  1891.         Grid[x][y].setScale(Vector2f(0.1009, 0.165));
  1892.     }
  1893.  
  1894.  
  1895.  
  1896.     //======================================================================//
  1897.  
  1898.     //###############################################################################
  1899.                 //Player Bomb stuff //
  1900.     Sprite bombing, exp;
  1901.     bombing.setScale(0.2f, 0.2f);
  1902.     exp.setScale(0.25, 0.25);
  1903.     Texture playertext, player2text, bombtext, exptext;
  1904.     playertext.loadFromFile("mainplayer.png");
  1905.     player2text.loadFromFile("blue.png");
  1906.     bombtext.loadFromFile("BOOM.png");
  1907.     exptext.loadFromFile("exp.png");
  1908.     bombing.setTexture(bombtext);
  1909.     exp.setTexture(exptext);
  1910.     Vector2u text_size_bomb = bombtext.getSize();
  1911.     Vector2u text_size_exp = exptext.getSize();
  1912.     text_size_bomb.y /= 4;
  1913.     text_size_exp.x /= 3;
  1914.     text_size_exp.y /= 3;
  1915.     Time times2, times, t, ti, bomb_timer;
  1916.     Clock clocks2, c, cs, clocks, clock_timer;
  1917.  
  1918.     bomb bomb_template;
  1919.     bomb_template.sprt.setTexture(bombtext);
  1920.     bomb_template.sprt.setScale(0.15f, 0.15f);
  1921.     vector<bomb>bombs;
  1922.     int number_of_bombs = 0, range_of_bomb = 3, bomb_placement_timer = 0, superpower_of_bomb = 2, counter_placed_bombs = 0;
  1923.     //###############################################################################
  1924.  
  1925.     bool Yellow_Robot_death = 0, White_Robot_death = 0, White_Skeleton_death = 0, Blue_Skeleton_death = 0;
  1926.     int lives = 3;
  1927.     int boombs = 1;
  1928.     Clock counter;
  1929.     Time elaps = seconds(200);
  1930.     int elapsed = elaps.asSeconds();
  1931.  
  1932.     int temp_range_of_bomb = 3;
  1933.     //=======================================================================================//
  1934.  
  1935.     RenderWindow window(VideoMode(1280, 768), "Advanced Level");
  1936.  
  1937.     while (window.isOpen())
  1938.     {
  1939.         //=======================================================================================//
  1940.         timer = timer_clock.getElapsedTime();
  1941.         display_timer = timer.asSeconds();
  1942.         string s1, s2;
  1943.         //int  minu=display_timer/60;
  1944.         s1 = to_string(59 - (display_timer));
  1945.         s2 = to_string(minutes);
  1946.         s2 += ":";
  1947.         //s2=to_string(1-minu);
  1948.         //s2+=" : ";
  1949.         //s2+=s1;
  1950.         txt.setFont(dis_time);
  1951.         txt.setString(s2 + s1);
  1952.         txt.setPosition(512, 22);
  1953.         if (display_timer > 59 && minutes > 0)
  1954.         {
  1955.             minutes--;
  1956.             timer_clock.restart();
  1957.         }
  1958.         if (minutes == 0 && display_timer == 59) {
  1959.             Die = 1;
  1960.             ispressed = 1;
  1961.         }
  1962.         if (ispressed) {
  1963.             start_timer = start_clock.getElapsedTime();
  1964.             if (start_timer.asSeconds() >= 0.2) {
  1965.                 start_clock.restart();
  1966.                 big_exp.setPosition((window.getPosition().x / 2) - 25, (window.getPosition().y / 2) - 210);
  1967.                 big_exp.setTextureRect(IntRect(text_size_big_exp.x * big_pos_x, text_size_big_exp.y * big_pos_y, text_size_big_exp.x, text_size_big_exp.y));
  1968.  
  1969.                 big_pos_x++;
  1970.                 if (big_pos_x == 3) {
  1971.                     big_pos_x = 0, big_pos_y++;
  1972.                     if (big_pos_y == 2 && big_pos_x == 2) {
  1973.                         ispressed = 0;
  1974.                         big_exp.setColor(Color::Transparent);
  1975.                     }
  1976.                 }
  1977.             }
  1978.         }
  1979.         //=======================================================================================//
  1980.         // player status
  1981.         string ss = to_string(temp_range_of_bomb);
  1982.  
  1983.         Text noofranges;
  1984.         noofranges.setFont(font);
  1985.         noofranges.setString(ss);
  1986.         noofranges.setCharacterSize(45);
  1987.         noofranges.setPosition(90, 195);
  1988.  
  1989.         string sss = to_string(boombs);
  1990.  
  1991.         Text noofbombs;
  1992.         noofbombs.setFont(font);
  1993.         noofbombs.setString(sss);
  1994.         noofbombs.setCharacterSize(50);
  1995.         noofbombs.setPosition(90, 320);
  1996.  
  1997.         string ssl = to_string(lives);
  1998.  
  1999.         Text nooflives;
  2000.         nooflives.setFont(font);
  2001.         nooflives.setString(ssl);
  2002.         nooflives.setCharacterSize(50);
  2003.         nooflives.setPosition(90, 255);
  2004.  
  2005.         //=======================================================================================//
  2006.         // indxex of all monsters
  2007.         Robot_xindx = GetXindx(Yellow_Robot.getPosition().x), Robot_yindx = GetYindx(Yellow_Robot.getPosition().y);
  2008.         White_Robot_xindx = GetXindx(White_Robot.getPosition().x), White_Robot_yindx = GetYindx(White_Robot.getPosition().y);
  2009.         Skeleton_xindx = GetXindx(White_Skeleton.getPosition().x), Skeleton_yindx = GetYindx(White_Skeleton.getPosition().y);
  2010.  
  2011.         //=======================================================================================//
  2012.                             // Random Movment of Yellow Robot //
  2013.         if (Yellow_Robot_Counter >= 5000)
  2014.         {
  2015.             Yellow_Robot_Rand_motion = rand() % 4 + 1;
  2016.             Yellow_Robot_Counter = 0;
  2017.         }
  2018.  
  2019.         if (Yellow_Robot_Rand_motion == 1)                                          // Moving UP => Rand_motion == 1
  2020.         {
  2021.             Yellow_Robot_Counter++;
  2022.             if (Grid[GetXindx(Yellow_Robot.getPosition().x + 25)][GetYindx(Yellow_Robot.getPosition().y - 7)].getTexture() == &ground || Grid[GetXindx(Yellow_Robot.getPosition().x)][GetYindx(Yellow_Robot.getPosition().y - 7)].getTexture() == &ground2)
  2023.             {
  2024.                 Movement_Upward(Yellow_Robot, Yellow_Robot_time, Yellow_Robot_clock, Yellow_Robot_position, Yellow_Robot_size, Yellow_Robot_speed);
  2025.             }
  2026.             else
  2027.             {
  2028.                 Yellow_Robot_Counter = 5000;
  2029.             }
  2030.  
  2031.         }
  2032.         else if (Yellow_Robot_Rand_motion == 2)                                 // Moving Down => Rand_motion == 2
  2033.         {
  2034.             Yellow_Robot_Counter++;
  2035.             if (Grid[GetXindx(Yellow_Robot.getPosition().x + 25)][GetYindx(Yellow_Robot.getPosition().y + 7)].getTexture() == &ground || Grid[GetXindx(Yellow_Robot.getPosition().x)][GetYindx(Yellow_Robot.getPosition().y + 7)].getTexture() == &ground2)
  2036.             {
  2037.                 Movement_Downward(Yellow_Robot, Yellow_Robot_time, Yellow_Robot_clock, Yellow_Robot_position, Yellow_Robot_size, Yellow_Robot_speed);
  2038.             }
  2039.  
  2040.             else
  2041.             {
  2042.                 Yellow_Robot_Counter = 5000;
  2043.             }
  2044.         }
  2045.  
  2046.  
  2047.         else if (Yellow_Robot_Rand_motion == 3)                                 // Moving Right => Rand_motion == 3
  2048.         {
  2049.             Yellow_Robot_Counter++;
  2050.             if (Grid[GetXindx(Yellow_Robot.getPosition().x + 12)][GetYindx(Yellow_Robot.getPosition().y)].getTexture() == &ground || Grid[GetXindx(Yellow_Robot.getPosition().x + 12)][GetYindx(Yellow_Robot.getPosition().y)].getTexture() == &ground2)
  2051.             {
  2052.                 Movement_Right(Yellow_Robot, Yellow_Robot_time, Yellow_Robot_clock, Yellow_Robot_position, Yellow_Robot_size, Yellow_Robot_speed);
  2053.             }
  2054.             else
  2055.             {
  2056.                 Yellow_Robot_Counter = 5000;
  2057.             }
  2058.         }
  2059.  
  2060.  
  2061.         else if (Yellow_Robot_Rand_motion == 4)                                 // Moving Left => Rand_motion == 4
  2062.         {
  2063.             Yellow_Robot_Counter++;
  2064.             if (Grid[GetXindx(Yellow_Robot.getPosition().x - 12)][GetYindx(Yellow_Robot.getPosition().y)].getTexture() == &ground || Grid[GetXindx(Yellow_Robot.getPosition().x - 12)][GetYindx(Yellow_Robot.getPosition().y)].getTexture() == &ground2)
  2065.             {
  2066.                 Movement_Left(Yellow_Robot, Yellow_Robot_time, Yellow_Robot_clock, Yellow_Robot_position, Yellow_Robot_size, Yellow_Robot_speed);
  2067.             }
  2068.             else
  2069.             {
  2070.                 Yellow_Robot_Counter = 5000;
  2071.             }
  2072.  
  2073.         }
  2074.         //=======================================================================================//
  2075.  
  2076.         //=======================================================================================//
  2077.                                 // Random Movment of White Robot //
  2078.         if (White_Robot_Counter >= 5000)
  2079.         {
  2080.             White_Robot_Rand_motion = rand() % 4 + 1;
  2081.             White_Robot_Counter = 0;
  2082.         }
  2083.  
  2084.         if (White_Robot_Rand_motion == 1)                                           // Moving UP => Rand_motion == 1
  2085.         {
  2086.             White_Robot_Counter++;
  2087.             if (Grid[GetXindx(White_Robot.getPosition().x + 25)][GetYindx(White_Robot.getPosition().y - 7)].getTexture() == &ground || Grid[GetXindx(White_Robot.getPosition().x)][GetYindx(White_Robot.getPosition().y - 7)].getTexture() == &ground2)
  2088.             {
  2089.                 Movement_Upward(White_Robot, White_Robot_time, White_Robot_clock, White_Robot_position, White_Robot_size, White_Robot_speed);
  2090.             }
  2091.             else
  2092.             {
  2093.                 White_Robot_Counter = 5000;
  2094.             }
  2095.  
  2096.         }
  2097.         else if (White_Robot_Rand_motion == 2)                                  // Moving Down => Rand_motion == 2
  2098.         {
  2099.             White_Robot_Counter++;
  2100.             if (Grid[GetXindx(White_Robot.getPosition().x + 25)][GetYindx(White_Robot.getPosition().y + 7)].getTexture() == &ground || Grid[GetXindx(White_Robot.getPosition().x)][GetYindx(White_Robot.getPosition().y + 7)].getTexture() == &ground2)
  2101.             {
  2102.                 Movement_Downward(White_Robot, White_Robot_time, White_Robot_clock, White_Robot_position, White_Robot_size, White_Robot_speed);
  2103.             }
  2104.  
  2105.             else
  2106.             {
  2107.                 White_Robot_Counter = 5000;
  2108.             }
  2109.         }
  2110.  
  2111.  
  2112.         else if (White_Robot_Rand_motion == 3)                                  // Moving Right => Rand_motion == 3
  2113.         {
  2114.             White_Robot_Counter++;
  2115.             if (Grid[GetXindx(White_Robot.getPosition().x + 12)][GetYindx(White_Robot.getPosition().y)].getTexture() == &ground || Grid[GetXindx(White_Robot.getPosition().x + 12)][GetYindx(White_Robot.getPosition().y)].getTexture() == &ground2)
  2116.             {
  2117.                 Movement_Right(White_Robot, White_Robot_time, White_Robot_clock, White_Robot_position, White_Robot_size, White_Robot_speed);
  2118.             }
  2119.             else
  2120.             {
  2121.                 White_Robot_Counter = 5000;
  2122.             }
  2123.         }
  2124.  
  2125.  
  2126.         else if (White_Robot_Rand_motion == 4)                                  // Moving Left => Rand_motion == 4
  2127.         {
  2128.             White_Robot_Counter++;
  2129.             if (Grid[GetXindx(White_Robot.getPosition().x - 12)][GetYindx(White_Robot.getPosition().y)].getTexture() == &ground || Grid[GetXindx(White_Robot.getPosition().x - 12)][GetYindx(White_Robot.getPosition().y)].getTexture() == &ground2)
  2130.             {
  2131.                 Movement_Left(White_Robot, White_Robot_time, White_Robot_clock, White_Robot_position, White_Robot_size, White_Robot_speed);
  2132.             }
  2133.             else
  2134.             {
  2135.                 White_Robot_Counter = 5000;
  2136.             }
  2137.  
  2138.         }
  2139.         //=======================================================================================//
  2140.  
  2141.  
  2142.         //=======================================================================================//
  2143.                             // Random Movment of White Skeleton //  
  2144.         if (White_Skeleton_Counter >= 5000)
  2145.         {
  2146.             White_Skeleton_Rand_motion = rand() % 4 + 1;
  2147.             White_Skeleton_Counter = 0;
  2148.         }
  2149.  
  2150.         if (White_Skeleton_Rand_motion == 1)                                            // Moving UP => Rand_motion == 1
  2151.         {
  2152.             White_Skeleton_Counter++;
  2153.             if (Grid[GetXindx(White_Skeleton.getPosition().x + 25)][GetYindx(White_Skeleton.getPosition().y - 7)].getTexture() == &ground || Grid[GetXindx(White_Skeleton.getPosition().x)][GetYindx(White_Skeleton.getPosition().y - 7)].getTexture() == &ground2)
  2154.             {
  2155.                 Movement_Upward(White_Skeleton, White_Skeleton_time, White_Skeleton_clock, White_Skeleton_position, White_Skeleton_text_size, White_Skeleton_speed);
  2156.             }
  2157.             else
  2158.             {
  2159.                 White_Skeleton_Counter = 5000;
  2160.             }
  2161.  
  2162.         }
  2163.         else if (White_Skeleton_Rand_motion == 2)                                   // Moving Down => Rand_motion == 2
  2164.         {
  2165.             White_Skeleton_Counter++;
  2166.             if (Grid[GetXindx(White_Skeleton.getPosition().x + 25)][GetYindx(White_Skeleton.getPosition().y + 7)].getTexture() == &ground || Grid[GetXindx(White_Skeleton.getPosition().x)][GetYindx(White_Skeleton.getPosition().y + 7)].getTexture() == &ground2)
  2167.             {
  2168.                 Movement_Downward(White_Skeleton, White_Skeleton_time, White_Skeleton_clock, White_Skeleton_position, White_Skeleton_text_size, White_Skeleton_speed);
  2169.             }
  2170.  
  2171.             else
  2172.             {
  2173.                 White_Skeleton_Counter = 5000;
  2174.             }
  2175.         }
  2176.  
  2177.  
  2178.         else if (White_Skeleton_Rand_motion == 3)                                   // Moving Right => Rand_motion == 3
  2179.         {
  2180.             White_Skeleton_Counter++;
  2181.             if (Grid[GetXindx(White_Skeleton.getPosition().x + 12)][GetYindx(White_Skeleton.getPosition().y)].getTexture() == &ground || Grid[GetXindx(White_Skeleton.getPosition().x + 12)][GetYindx(White_Skeleton.getPosition().y)].getTexture() == &ground2)
  2182.             {
  2183.                 Movement_Right(White_Skeleton, White_Skeleton_time, White_Skeleton_clock, White_Skeleton_position, White_Skeleton_text_size, White_Skeleton_speed);
  2184.             }
  2185.             else
  2186.             {
  2187.                 White_Skeleton_Counter = 5000;
  2188.             }
  2189.         }
  2190.  
  2191.  
  2192.         else if (White_Skeleton_Rand_motion == 4)                                   // Moving Left => Rand_motion == 4
  2193.         {
  2194.             White_Skeleton_Counter++;
  2195.             if (Grid[GetXindx(White_Skeleton.getPosition().x - 12)][GetYindx(White_Skeleton.getPosition().y)].getTexture() == &ground || Grid[GetXindx(White_Skeleton.getPosition().x - 12)][GetYindx(White_Skeleton.getPosition().y)].getTexture() == &ground2)
  2196.             {
  2197.                 Movement_Left(White_Skeleton, White_Skeleton_time, White_Skeleton_clock, White_Skeleton_position, White_Skeleton_text_size, White_Skeleton_speed);
  2198.             }
  2199.             else
  2200.             {
  2201.                 White_Skeleton_Counter = 5000;
  2202.             }
  2203.  
  2204.         }
  2205.         //=======================================================================================//
  2206.  
  2207.  
  2208.         //=======================================================================================//
  2209.                             // BFS Movement of Blue Skeleton
  2210.  
  2211.         BFS(GetXindx(player.getPosition().x), GetYindx(player.getPosition().y), GetXindx(Blue_Skeleton.getPosition().x), GetYindx(Blue_Skeleton.getPosition().y), Grid, ground, ground2);
  2212.         if (Smart_Skeleton_Movement.i == GetXindx(Blue_Skeleton.getPosition().x) && Smart_Skeleton_Movement.j - GetYindx(Blue_Skeleton.getPosition().y) == 1)
  2213.         {
  2214.             Movement_Downward(Blue_Skeleton, Blue_Skeleton_time, Blue_Skeleton_clock, Blue_Skeleton_position, Blue_Skeleton_size, Blue_Skeleton_speed); // Moving Downward
  2215.         }
  2216.         else if (Smart_Skeleton_Movement.i == GetXindx(Blue_Skeleton.getPosition().x) && Smart_Skeleton_Movement.j - GetYindx(Blue_Skeleton.getPosition().y) == -1)
  2217.         {
  2218.             Movement_Upward(Blue_Skeleton, Blue_Skeleton_time, Blue_Skeleton_clock, Blue_Skeleton_position, Blue_Skeleton_size, Blue_Skeleton_speed);       // Moving Upward
  2219.         }
  2220.         else if (Smart_Skeleton_Movement.i - GetXindx(Blue_Skeleton.getPosition().x) == 1 && Smart_Skeleton_Movement.j == GetYindx(Blue_Skeleton.getPosition().y))
  2221.         {
  2222.             Movement_Right(Blue_Skeleton, Blue_Skeleton_time, Blue_Skeleton_clock, Blue_Skeleton_position, Blue_Skeleton_size, Blue_Skeleton_speed);        // Moving Right
  2223.         }
  2224.         else if (Smart_Skeleton_Movement.i - GetXindx(Blue_Skeleton.getPosition().x) == -1 && Smart_Skeleton_Movement.j == GetYindx(Blue_Skeleton.getPosition().y))
  2225.         {
  2226.             Movement_Left(Blue_Skeleton, Blue_Skeleton_time, Blue_Skeleton_clock, Blue_Skeleton_position, Blue_Skeleton_size, Blue_Skeleton_speed);     // Moving Left
  2227.         }
  2228.  
  2229.         //=======================================================================================//
  2230.  
  2231.             //######################################################################################################
  2232.  
  2233.         // Player Movement
  2234.         Player_xindx = (float)((float)(player.getPosition().x - 183) / 53 + 2);
  2235.         Player_yindx = (float)((float)(player.getPosition().y - 74) / 48 + 2);
  2236.         right.i = GetXindx(player.getPosition().x + 20); right.j = Player_yindx;
  2237.         left.i = GetXindx(player.getPosition().x - 20); left.j = Player_yindx;
  2238.         up.i = Player_xindx; up.j = GetYindx(player.getPosition().y - 7);
  2239.         down.i = Player_xindx; down.j = GetYindx(player.getPosition().y + 7);
  2240.  
  2241.         if (Keyboard::isKeyPressed(Keyboard::Key::Right) && (Grid[right.i][right.j].getTexture() == &ground || Grid[right.i][right.j].getTexture() == &ground2))      // Moving Right
  2242.         {
  2243.             bool check_bomb = 0;
  2244.             for (int io = 0; io < bombs.size(); io++)
  2245.             {
  2246.                 if (bombs[io].x_index == GetXindx(player.getPosition().x + 1) && bombs[io].x_index != GetXindx(player.getPosition().x) && bombs[io].y_index == right.j)
  2247.                 {
  2248.                     check_bomb = 1; break;
  2249.                 }
  2250.             }
  2251.             if (!check_bomb)
  2252.                 Movement_Right(player, player_time, player_clock, player_position, player_size, player_speed);
  2253.         }
  2254.         else if (Keyboard::isKeyPressed(Keyboard::Key::Left) && (Grid[left.i][left.j].getTexture() == &ground || Grid[left.i][left.j].getTexture() == &ground2))         // Moving Left
  2255.         {
  2256.             bool check_bomb = 0;
  2257.             for (int io = 0; io < bombs.size(); io++)
  2258.             {
  2259.                 if (bombs[io].x_index == GetXindx(player.getPosition().x - 1) && bombs[io].x_index != GetXindx(player.getPosition().x) && bombs[io].y_index == left.j)
  2260.                 {
  2261.                     check_bomb = 1; break;
  2262.                 }
  2263.             }
  2264.             if (!check_bomb)
  2265.                 Movement_Left(player, player_time, player_clock, player_position, player_size, player_speed);
  2266.         }
  2267.         else if (Keyboard::isKeyPressed(Keyboard::Key::Up) && (Grid[GetXindx(player.getPosition().x + 25)][up.j].getTexture() == &ground || Grid[up.i][up.j].getTexture() == &ground2))           // Moving Up
  2268.         {
  2269.             bool check_bomb = 0;
  2270.             for (int io = 0; io < bombs.size(); io++)
  2271.             {
  2272.                 if (bombs[io].y_index == GetYindx(player.getPosition().y - 1) && bombs[io].y_index != GetYindx(player.getPosition().y) && bombs[io].x_index == up.i)
  2273.                 {
  2274.                     check_bomb = 1; break;
  2275.                 }
  2276.             }
  2277.             if (!check_bomb)
  2278.  
  2279.  
  2280.                 Movement_Upward(player, player_time, player_clock, player_position, player_size, player_speed);
  2281.         }
  2282.         else if (Keyboard::isKeyPressed(Keyboard::Key::Down) && (Grid[GetXindx(player.getPosition().x + 25)][down.j].getTexture() == &ground || Grid[down.i][down.j].getTexture() == &ground2))         // Moving Down
  2283.         {
  2284.             bool check_bomb = 0;
  2285.             for (int io = 0; io < bombs.size(); io++)
  2286.             {
  2287.                 if (bombs[io].y_index == GetYindx(player.getPosition().y + 1) && bombs[io].y_index != GetYindx(player.getPosition().y) && bombs[io].x_index == up.i)
  2288.                 {
  2289.                     check_bomb = 1; break;
  2290.                 }
  2291.             }
  2292.             if (!check_bomb)
  2293.  
  2294.                 Movement_Downward(player, player_time, player_clock, player_position, player_size, player_speed);
  2295.         }
  2296.  
  2297.         //######################################################################################################
  2298.         //=======================================================================================//
  2299.  
  2300.  
  2301.         //=======================================================================================//
  2302.         Event event;
  2303.         while (window.pollEvent(event))
  2304.         {
  2305.             if (event.type == sf::Event::Closed || Keyboard::isKeyPressed(Keyboard::Escape))
  2306.                 window.close();
  2307.         }
  2308.  
  2309.         //#####################################################################################################
  2310.         // Bombing stuff
  2311.         //#####################################################################################################
  2312.         // Bombing stuff
  2313.             // bombing
  2314.  
  2315.         if (bomb_placement_timer < 80)
  2316.         {
  2317.             bomb_placement_timer++;
  2318.         }
  2319.         if (Keyboard::isKeyPressed(Keyboard::Key::Space) && bomb_placement_timer == 80 && counter_placed_bombs < boombs) {
  2320.             bombs.push_back(bomb_template);
  2321.             bombs[bombs.size() - 1].bomb_clock.restart();
  2322.             bombs[bombs.size() - 1].explosion_clock.restart();
  2323.             bombs[bombs.size() - 1].start_clock.restart();
  2324.             bombs[bombs.size() - 1].bomb_placed = 1;
  2325.             bombs[bombs.size() - 1].x_pos = GetXpostion(Player_xindx) + 12;
  2326.             bombs[bombs.size() - 1].y_pos = GetYpostion(Player_yindx) + 12;
  2327.             bombs[bombs.size() - 1].x_index = GetXindx(bombs[bombs.size() - 1].x_pos);
  2328.             bombs[bombs.size() - 1].y_index = GetYindx(bombs[bombs.size() - 1].y_pos);
  2329.             bombs[bombs.size() - 1].sprt.setPosition(bombs[bombs.size() - 1].x_pos, bombs[bombs.size() - 1].y_pos);
  2330.             bombs[bombs.size() - 1].sprt.setTextureRect(IntRect(0, text_size_bomb.y * bombs[bombs.size() - 1].bomb_animation_y, text_size_bomb.x, text_size_bomb.y));
  2331.             bomb_placement_timer = 0;
  2332.             counter_placed_bombs++;
  2333.         }
  2334.  
  2335.         for (int io = 0; io < bombs.size(); io++)
  2336.         {
  2337.             if (bombs[io].bomb_placed == 1) {
  2338.                 bombs[io].bomb_time = bombs[io].bomb_clock.getElapsedTime();
  2339.                 bombs[io].start_explosion = bombs[io].start_clock.getElapsedTime();
  2340.                 if (bombs[io].bomb_time.asSeconds() >= 0.2) {
  2341.                     bombs[io].bomb_clock.restart();
  2342.                     bombs[io].sprt.setPosition(bombs[io].x_pos, bombs[io].y_pos + 25);
  2343.                     bombs[io].sprt.setTextureRect(IntRect(0, text_size_bomb.y * bombs[io].bomb_animation_y, text_size_bomb.x, text_size_bomb.y));
  2344.                     bombs[io].bomb_animation_y += 2;
  2345.                     if (bombs[io].bomb_animation_y > 2)
  2346.                         bombs[io].bomb_animation_y = 0;
  2347.                 }
  2348.                 if (bombs[io].start_explosion.asSeconds() >= 3) {
  2349.                     bombs[io].bomb_exploded = 1;
  2350.                     bombs[io].bomb_placed = 0;
  2351.                     //                bombs[number_of_bombs].sprt.setColor(Color::Transparent);
  2352.                     for (int k = 0; k <= range_of_bomb; k++)
  2353.                     {
  2354.                         bombs[io].range_right.push_back(exp);
  2355.                         bombs[io].range_left.push_back(exp);
  2356.                         bombs[io].range_up.push_back(exp);
  2357.                         bombs[io].range_down.push_back(exp);
  2358.                         //                     v[z].push_back(exp);
  2359.                     }
  2360.                 }
  2361.             }
  2362.             //cout<<player.getPosition().x<<' '<<player.getPosition().y<<endl;
  2363.             if (bombs[io].bomb_exploded) {
  2364.                 bombs[io].explosion_time = bombs[io].explosion_clock.getElapsedTime();
  2365.                 if (bombs[io].explosion_time.asSeconds() >= 0.08) {
  2366.                     bombs[io].explosion_clock.restart();
  2367.                     for (int n = 0, k = 0; k < bombs[io].range_right.size(), n <= range_of_bomb * 50; k++, n += 50)
  2368.                         bombs[io].range_right[k].setPosition(bombs[io].x_pos + n, bombs[io].y_pos);
  2369.  
  2370.                     for (int n = 0, k = 0; k < bombs[io].range_right.size(), n <= range_of_bomb * 50; k++, n += 50)
  2371.                         bombs[io].range_right[k].setTextureRect(IntRect(text_size_exp.x * bombs[io].exp_animation_x, text_size_exp.y * bombs[io].exp_animation_y, text_size_exp.x, text_size_exp.y));
  2372.  
  2373.                     for (int n = 0, k = 0; k < bombs[io].range_left.size(), n <= range_of_bomb * 50; k++, n += 50)
  2374.                         bombs[io].range_left[k].setPosition(bombs[io].x_pos - n, bombs[io].y_pos);
  2375.  
  2376.                     for (int n = 0, k = 0; k < bombs[io].range_left.size(), n <= range_of_bomb * 50; k++, n += 50)
  2377.                         bombs[io].range_left[k].setTextureRect(IntRect(text_size_exp.x * bombs[io].exp_animation_x, text_size_exp.y * bombs[io].exp_animation_y, text_size_exp.x, text_size_exp.y));
  2378.  
  2379.                     for (int n = 0, k = 0; k < bombs[io].range_up.size(), n <= range_of_bomb * 50; k++, n += 50)
  2380.                         bombs[io].range_up[k].setPosition(bombs[io].x_pos, bombs[io].y_pos - n);
  2381.  
  2382.                     for (int n = 0, k = 0; k < bombs[io].range_up.size(), n <= range_of_bomb * 50; k++, n += 50)
  2383.                         bombs[io].range_up[k].setTextureRect(IntRect(text_size_exp.x * bombs[io].exp_animation_x, text_size_exp.y * bombs[io].exp_animation_y, text_size_exp.x, text_size_exp.y));
  2384.  
  2385.                     for (int n = 0, k = 0; k < bombs[io].range_down.size(), n <= range_of_bomb * 50; k++, n += 50)
  2386.                         bombs[io].range_down[k].setPosition(bombs[io].x_pos, bombs[io].y_pos + n);
  2387.  
  2388.                     for (int n = 0, k = 0; k < bombs[io].range_down.size(), n <= range_of_bomb * 50; k++, n += 50)
  2389.                         bombs[io].range_down[k].setTextureRect(IntRect(text_size_exp.x * bombs[io].exp_animation_x, text_size_exp.y * bombs[io].exp_animation_y, text_size_exp.x, text_size_exp.y));
  2390.  
  2391.                     bombs[io].exp_animation_x++;
  2392.                     if (bombs[io].exp_animation_x == 3) {
  2393.                         bombs[io].exp_animation_x = 0, bombs[io].exp_animation_y++;
  2394.                         if (bombs[io].exp_animation_y == 3) {
  2395.                             bombs[io].bomb_exploded = 0;
  2396.                             bombs.erase(bombs.begin());
  2397.                             counter_placed_bombs--;
  2398.  
  2399.                         }
  2400.                     }
  2401.                 }
  2402.             }
  2403.         }
  2404.         //}
  2405.         // Drawing of the Wallpaper
  2406.         window.clear();
  2407.         window.draw(Wallpaper);
  2408.         //=======================================================================================//
  2409.  
  2410.         // Drawing of The Map //
  2411. //=======================================================================================//
  2412.                         // Drawing of The Ground //
  2413.  
  2414.         for (int i = 2; i < width; i++)
  2415.         {
  2416.             for (int j = 2; j < length; j++)
  2417.             {
  2418.                 if (Grid[i][j].getTexture() == &ground || Grid[i][j].getTexture() == &ground2)
  2419.                 {
  2420.                     window.draw(Grid[i][j]);
  2421.                 }
  2422.             }
  2423.  
  2424.         }
  2425.  
  2426.         //=======================================================================================//
  2427.  
  2428.         for (int i = 0; i < 19; i++)
  2429.         {
  2430.             if (i == 14 || i == 2)
  2431.                 continue;
  2432.  
  2433.             window.draw(SuperPowers[i]);
  2434.         }
  2435.         //=======================================================================================//
  2436.                                     // Drawing of Wall and Breakable //
  2437.         for (int j = 1; j <= length; j++)
  2438.         {
  2439.             for (int i = 1; i <= width; i++)
  2440.             {
  2441.                 if (Grid[i][j].getTexture() == &ground || Grid[i][j].getTexture() == &ground2)
  2442.                 {
  2443.                     continue;
  2444.                 }
  2445.  
  2446.                 window.draw(Grid[i][j]);
  2447.  
  2448.                 if (GetYindx(player.getPosition().y) >= j)              // Drawing of Player //
  2449.                 {
  2450.                     window.draw(player);
  2451.                 }
  2452.                 if (GetYindx(White_Robot.getPosition().y) >= j && !White_Robot_death)           // Drawing of White_Robot //
  2453.                 {
  2454.                     window.draw(White_Robot);
  2455.                 }
  2456.                 if (GetYindx(Yellow_Robot.getPosition().y) >= j && !Yellow_Robot_death)     // Drawing of Yellow_Robot //
  2457.                 {
  2458.                     window.draw(Yellow_Robot);
  2459.                 }
  2460.                 if (GetYindx(White_Skeleton.getPosition().y) >= j && !White_Skeleton_death)     // Drawing of White_Skeleton //
  2461.                 {
  2462.                     window.draw(White_Skeleton);
  2463.                 }
  2464.                 if (GetYindx(Blue_Skeleton.getPosition().y) >= j && !Blue_Skeleton_death)       // Drawing of Blue_Skeleton //
  2465.                 {
  2466.                     window.draw(Blue_Skeleton);
  2467.                 }
  2468.                 for (int io = 0; io < bombs.size(); io++)
  2469.                 {
  2470.                     if (bombs[io].y_index >= j && bombs[io].bomb_placed)
  2471.                     {
  2472.                         window.draw(bombs[io].sprt);
  2473.                     }
  2474.                 }
  2475.  
  2476.             }
  2477.         }
  2478.  
  2479.         //############################################################################################
  2480.         // Drawing Bombs
  2481.         for (int io = 0; io < bombs.size(); io++)
  2482.         {
  2483.             //if (bombs[io].bomb_placed)
  2484.                 //window.draw(bombs[io].sprt);
  2485.             if (bombs[io].bomb_exploded)
  2486.             {
  2487.  
  2488.                 //Right
  2489.                 for (int g = 0; g <= range_of_bomb; g++)
  2490.                 {
  2491.  
  2492.                     window.draw(bombs[io].range_right[g]);
  2493.  
  2494.                     if ((Grid[bombs[io].x_index + g][bombs[io].y_index].getTexture() == &breakable) && bombs[io].flag_range_right)
  2495.                     {
  2496.                         destroy_breakable_walls(bombs[io].x_index + g, bombs[io].y_index, Grid, ground, ground2);
  2497.                         bombs[io].flag_range_right = 0;
  2498.                         break;
  2499.                     }
  2500.                     else if (Grid[bombs[io].x_index + g][bombs[io].y_index].getTexture() == &wall)
  2501.                     {
  2502.  
  2503.                         bombs[io].flag_range_right = 0;
  2504.                         break;
  2505.                     }
  2506.  
  2507.                     if (bombs[io].x_index + g == Player_xindx && bombs[io].y_index == Player_yindx && bombs[io].flag_range_right)
  2508.                     {
  2509.                         if (Clock_Damgae.getElapsedTime().asSeconds() >= 1) {
  2510.                             lives--;
  2511.                             ssl = to_string(lives);
  2512.                             Clock_Damgae.restart();
  2513.                         }
  2514.                         window.draw(Hurt);
  2515.                     }
  2516.  
  2517.                     if (bombs[io].x_index + g == Robot_xindx && bombs[io].y_index == Robot_yindx && bombs[io].flag_range_right)
  2518.                     {
  2519.                         Yellow_Robot_death = 1;
  2520.                         Yellow_Robot.setFillColor(Color::Transparent);
  2521.                     }
  2522.                     if (bombs[io].x_index + g == White_Robot_xindx && bombs[io].y_index == White_Robot_yindx && bombs[io].flag_range_right)
  2523.                     {
  2524.                         White_Robot_death = 1;
  2525.                         White_Robot.setFillColor(Color::Transparent);
  2526.                     }
  2527.                     if (bombs[io].x_index + g == Skeleton_xindx && bombs[io].y_index == Skeleton_yindx && bombs[io].flag_range_right)
  2528.                     {
  2529.                         White_Skeleton_death = 1;
  2530.                         White_Skeleton.setFillColor(Color::Transparent);
  2531.                     }
  2532.                     if (bombs[io].x_index + g == GetXindx(Blue_Skeleton.getPosition().x) && bombs[io].y_index == GetYindx(Blue_Skeleton.getPosition().y) && bombs[io].flag_range_right)
  2533.                     {
  2534.                         Blue_Skeleton_death = 1;
  2535.                         Blue_Skeleton.setFillColor(Color::Transparent);
  2536.                     }
  2537.  
  2538.  
  2539.                 }
  2540.  
  2541.  
  2542.                 //UP
  2543.                 for (int g = 0; g <= range_of_bomb; g++)
  2544.                 {
  2545.  
  2546.                     window.draw(bombs[io].range_up[g]);
  2547.  
  2548.                     if ((Grid[bombs[io].x_index][bombs[io].y_index - g].getTexture() == &breakable) && bombs[io].flag_range_up)
  2549.                     {
  2550.  
  2551.  
  2552.                         destroy_breakable_walls(bombs[io].x_index, bombs[io].y_index - g, Grid, ground, ground2);
  2553.  
  2554.                         bombs[io].flag_range_up = 0;
  2555.                         break;
  2556.  
  2557.                     }
  2558.                     else if (Grid[bombs[io].x_index][bombs[io].y_index - g].getTexture() == &wall)
  2559.                     {
  2560.  
  2561.                         bombs[io].flag_range_up = 0;
  2562.                         break;
  2563.                     }
  2564.  
  2565.                     if (bombs[io].x_index == Player_xindx && bombs[io].y_index - g == Player_yindx && bombs[io].flag_range_up)
  2566.                     {
  2567.                         if (Clock_Damgae.getElapsedTime().asSeconds() >= 1) {
  2568.                             lives--;
  2569.                             ssl = to_string(lives);
  2570.                             Clock_Damgae.restart();
  2571.                         }
  2572.                         window.draw(Hurt);
  2573.                     }
  2574.  
  2575.                     if (bombs[io].x_index == Robot_xindx && bombs[io].y_index - g == Robot_yindx && bombs[io].flag_range_up)
  2576.                     {
  2577.                         Yellow_Robot_death = 1;
  2578.                         Yellow_Robot.setFillColor(Color::Transparent);
  2579.                     }
  2580.                     if (bombs[io].x_index == White_Robot_xindx && bombs[io].y_index - g == White_Robot_yindx && bombs[io].flag_range_up)
  2581.                     {
  2582.                         White_Robot_death = 1;
  2583.                         White_Robot.setFillColor(Color::Transparent);
  2584.                     }
  2585.                     if (bombs[io].x_index == Skeleton_xindx && bombs[io].y_index - g == Skeleton_yindx && bombs[io].flag_range_up)
  2586.                     {
  2587.                         White_Skeleton_death = 1;
  2588.                         White_Skeleton.setFillColor(Color::Transparent);
  2589.                     }
  2590.                     if (bombs[io].x_index == GetXindx(Blue_Skeleton.getPosition().x) && bombs[io].y_index - g == GetYindx(Blue_Skeleton.getPosition().y) && bombs[io].flag_range_up)
  2591.                     {
  2592.                         Blue_Skeleton_death = 1;
  2593.                         Blue_Skeleton.setFillColor(Color::Transparent);
  2594.                     }
  2595.  
  2596.                 }
  2597.  
  2598.                 //Left
  2599.                 for (int g = 0; g <= range_of_bomb; g++)
  2600.                 {
  2601.  
  2602.                     window.draw(bombs[io].range_left[g]);
  2603.  
  2604.                     if ((Grid[bombs[io].x_index - g][bombs[io].y_index].getTexture() == &breakable) && bombs[io].flag_range_left)
  2605.                     {
  2606.                         destroy_breakable_walls(bombs[io].x_index - g, bombs[io].y_index, Grid, ground, ground2);
  2607.  
  2608.                         bombs[io].flag_range_left = 0;
  2609.                         break;
  2610.                     }
  2611.                     else if (Grid[bombs[io].x_index - g][bombs[io].y_index].getTexture() == &wall)
  2612.                     {
  2613.                         bombs[io].flag_range_left = 0;
  2614.                         break;
  2615.                     }
  2616.                     if (bombs[io].x_index - g == Player_xindx && bombs[io].y_index == Player_yindx && bombs[io].flag_range_left)
  2617.                     {
  2618.                         if (Clock_Damgae.getElapsedTime().asSeconds() >= 1) {
  2619.                             lives--;
  2620.                             //SuperPowers[i].setColor(Color::Transparent);
  2621.                             ssl = to_string(lives);
  2622.                             //counter.restart();
  2623.                             Clock_Damgae.restart();
  2624.                         }
  2625.                         window.draw(Hurt);
  2626.                     }
  2627.  
  2628.                     if (bombs[io].x_index - g == Robot_xindx - g && bombs[io].y_index == Robot_yindx && bombs[io].flag_range_left)
  2629.                     {
  2630.                         Yellow_Robot_death = 1;
  2631.                         Yellow_Robot.setFillColor(Color::Transparent);
  2632.                     }
  2633.                     if (bombs[io].x_index - g == White_Robot_xindx && bombs[io].y_index == White_Robot_yindx && bombs[io].flag_range_left)
  2634.                     {
  2635.                         White_Robot_death = 1;
  2636.                         White_Robot.setFillColor(Color::Transparent);
  2637.                     }
  2638.                     if (bombs[io].x_index - g == Skeleton_xindx && bombs[io].y_index == Skeleton_yindx && bombs[io].flag_range_left)
  2639.                     {
  2640.                         White_Skeleton_death = 1;
  2641.                         White_Skeleton.setFillColor(Color::Transparent);
  2642.                     }
  2643.                     if (bombs[io].x_index - g == GetXindx(Blue_Skeleton.getPosition().x) && bombs[io].y_index == GetYindx(Blue_Skeleton.getPosition().y) && bombs[io].flag_range_left)
  2644.                     {
  2645.                         Blue_Skeleton_death = 1;
  2646.                         Blue_Skeleton.setFillColor(Color::Transparent);
  2647.                     }
  2648.  
  2649.                 }
  2650.  
  2651.                 //Down
  2652.                 for (int g = 0; g <= range_of_bomb; g++)
  2653.                 {
  2654.  
  2655.                     window.draw(bombs[io].range_down[g]);
  2656.                     if ((Grid[bombs[io].x_index][bombs[io].y_index + g].getTexture() == &breakable) && bombs[io].flag_range_down)
  2657.                     {
  2658.                         destroy_breakable_walls(bombs[io].x_index, bombs[io].y_index + g, Grid, ground, ground2);
  2659.                         bombs[io].flag_range_down = 0;
  2660.                         break;
  2661.                     }
  2662.                     else if (Grid[bombs[io].x_index][bombs[io].y_index + g].getTexture() == &wall)
  2663.                     {
  2664.  
  2665.                         bombs[io].flag_range_down = 0;
  2666.                         break;
  2667.                     }
  2668.                     if (bombs[io].x_index == Player_xindx && bombs[io].y_index + g == Player_yindx && bombs[io].flag_range_down)
  2669.                     {
  2670.                         if (Clock_Damgae.getElapsedTime().asSeconds() >= 1) {
  2671.                             lives--;
  2672.                             ssl = to_string(lives);
  2673.                             Clock_Damgae.restart();
  2674.                         }
  2675.                         window.draw(Hurt);
  2676.                     }
  2677.  
  2678.                     if (bombs[io].x_index == Robot_xindx && bombs[io].y_index + g == Robot_yindx && bombs[io].flag_range_down)
  2679.                     {
  2680.                         Yellow_Robot_death = 1;
  2681.                         Yellow_Robot.setFillColor(Color::Transparent);
  2682.                     }
  2683.                     if (bombs[io].x_index == White_Robot_xindx && bombs[io].y_index + g == White_Robot_yindx && bombs[io].flag_range_down)
  2684.                     {
  2685.                         White_Robot_death = 1;
  2686.                         White_Robot.setFillColor(Color::Transparent);
  2687.                     }
  2688.                     if (bombs[io].x_index == Skeleton_xindx && bombs[io].y_index + g == Skeleton_yindx && bombs[io].flag_range_down)
  2689.                     {
  2690.                         White_Skeleton_death = 1;
  2691.                         White_Skeleton.setFillColor(Color::Transparent);
  2692.                     }
  2693.                     if (bombs[io].x_index == GetXindx(Blue_Skeleton.getPosition().x) && bombs[io].y_index + g == GetYindx(Blue_Skeleton.getPosition().y) && bombs[io].flag_range_down)
  2694.                     {
  2695.                         Blue_Skeleton_death = 1;
  2696.                         Blue_Skeleton.setFillColor(Color::Transparent);
  2697.                     }
  2698.  
  2699.                 }
  2700.  
  2701.             }
  2702.         }
  2703.  
  2704.         //############################################################################################//############################################################################################
  2705.  
  2706.         for (int i = 0; i < 19; i++) {
  2707.             int sumP = 0; int sumR = 0;
  2708.             sumP = GetXindx(player.getPosition().x) + GetYindx(player.getPosition().y);
  2709.             sumR = GetXindx(SuperPowers[i].getPosition().x) + GetYindx(SuperPowers[i].getPosition().y);
  2710.  
  2711.             if (sumR == sumP + 1 && (GetXindx(SuperPowers[i].getPosition().x) == GetXindx(player.getPosition().x))
  2712.                 && !visted[GetXindx(SuperPowers[i].getPosition().x)][GetYindx(SuperPowers[i].getPosition().y)])
  2713.             {
  2714.  
  2715.                 visted[GetXindx(SuperPowers[i].getPosition().x)][GetYindx(SuperPowers[i].getPosition().y)] = 1;
  2716.  
  2717.                 if (SuperPowers[i].getTexture() == &rangeskill) {
  2718.  
  2719.  
  2720.                     temp_range_of_bomb++;
  2721.                     SuperPowers[i].setColor(Color::Transparent);
  2722.                     ss = to_string(temp_range_of_bomb);
  2723.  
  2724.                 }
  2725.                 else if (SuperPowers[i].getTexture() == &bombskill) {
  2726.                     boombs++;
  2727.                     SuperPowers[i].setColor(Color::Transparent);
  2728.                     sss = to_string(boombs);
  2729.  
  2730.  
  2731.                 }
  2732.                 else if (SuperPowers[i].getTexture() == &healskill) {
  2733.                     lives++;
  2734.                     SuperPowers[i].setColor(Color::Transparent);
  2735.                     ssl = to_string(lives);
  2736.                 }
  2737.             }
  2738.  
  2739.         }
  2740.  
  2741.  
  2742.  
  2743.         bool isbombing = 0;
  2744.         for (int io = 0; io < bombs.size(); io++)
  2745.         {
  2746.             if (bombs[io].bomb_exploded) { isbombing = 1; break; }
  2747.         }
  2748.         if (!isbombing)
  2749.         {
  2750.             range_of_bomb = temp_range_of_bomb;
  2751.         }
  2752.         //############################################################################################
  2753.  
  2754.  
  2755.  
  2756.         if ((GetXindx(player.getPosition().x) == GetXindx(White_Robot.getPosition().x) && GetYindx(player.getPosition().y) == GetYindx(White_Robot.getPosition().y)) && !White_Robot_death) {
  2757.             if (Clock_Damgae.getElapsedTime().asSeconds() >= 1) {
  2758.                 lives--;
  2759.                 ssl = to_string(lives);
  2760.                 Clock_Damgae.restart();
  2761.             }
  2762.             window.draw(Hurt);
  2763.  
  2764.         }
  2765.  
  2766.         if (GetXindx(player.getPosition().x) == GetXindx(Yellow_Robot.getPosition().x) && GetYindx(player.getPosition().y) == GetYindx(Yellow_Robot.getPosition().y) && !Yellow_Robot_death)
  2767.         {
  2768.             if (Clock_Damgae.getElapsedTime().asSeconds() >= 1) {
  2769.                 lives--;
  2770.                 ssl = to_string(lives);
  2771.                 Clock_Damgae.restart();
  2772.             }
  2773.             window.draw(Hurt);
  2774.         }
  2775.  
  2776.         if (GetXindx(player.getPosition().x) == GetXindx(White_Skeleton.getPosition().x) && GetYindx(player.getPosition().y) == GetYindx(White_Skeleton.getPosition().y) && !White_Skeleton_death)
  2777.         {
  2778.             if (Clock_Damgae.getElapsedTime().asSeconds() >= 1) {
  2779.                 lives--;
  2780.                 ssl = to_string(lives);
  2781.                 Clock_Damgae.restart();
  2782.             }
  2783.             window.draw(Hurt);
  2784.         }
  2785.  
  2786.         if (GetXindx(player.getPosition().x) == GetXindx(Blue_Skeleton.getPosition().x) && GetYindx(player.getPosition().y) == GetYindx(Blue_Skeleton.getPosition().y) && !Blue_Skeleton_death)
  2787.         {
  2788.             if (Clock_Damgae.getElapsedTime().asSeconds() >= 1) {
  2789.                 lives--;
  2790.                 ssl = to_string(lives);
  2791.                 Clock_Damgae.restart();
  2792.             }
  2793.             window.draw(Hurt);
  2794.         }
  2795.  
  2796.         cout << lives << endl;
  2797.  
  2798.         window.draw(nooflives);
  2799.         window.draw(noofbombs);
  2800.         window.draw(noofranges);
  2801.         window.draw(lifeS);
  2802.         window.draw(rangeS);
  2803.         window.draw(bombS);
  2804.         window.draw(txt); // بيترسم تحت
  2805.         if (lives < 1) {
  2806.             ingame.stop();
  2807.             player.setFillColor(Color::Transparent);
  2808.             Tomb.setPosition(player.getPosition().x, player.getPosition().y);
  2809.             window.draw(Tomb);
  2810.             --elapsed;
  2811.             if (elapsed <= 50 + 500) {
  2812.                 if (playsong) {
  2813.                     lost.play();
  2814.                     playsong = 0;
  2815.                 }
  2816.                 if (elapsed <= -500) {
  2817.                     window.clear(Color::Black), window.draw(RIP_photo);
  2818.                     exit(0);
  2819.                 }
  2820.             }
  2821.         }
  2822.  
  2823.         if (Die) {
  2824.             ingame.stop();
  2825.             window.clear(Color::Black), window.draw(big_exp), window.draw(RIP_photo);
  2826.             --elapsed;
  2827.             if (elapsed <= 1) {
  2828.                 exit(0);
  2829.             }
  2830.         }
  2831.  
  2832.         if (Player_xindx == 16 && Player_yindx == 11) {
  2833.             ingame.stop();
  2834.             window.clear(Color::Black), window.draw(Level_complete);
  2835.             --elapsed;
  2836.             if (elapsed <= 1) {
  2837.                 exit(0);
  2838.             }
  2839.         }
  2840.         window.display();
  2841.     }
  2842. }
  2843. void Legendary_Mode() {
  2844.     //////////////////////////////////////////////////////////////////////////////////
  2845.     int big_pos_x = 1, big_pos_y = 0; //بيتعرف فوق
  2846.     Texture big_exp_text;
  2847.     big_exp_text.loadFromFile("exp.png");
  2848.     Sprite big_exp;
  2849.     big_exp.setTexture(big_exp_text);
  2850.     Vector2u text_size_big_exp = big_exp_text.getSize();
  2851.     text_size_big_exp.x /= 3;
  2852.     text_size_big_exp.y /= 3;
  2853.     big_exp.setScale(3, 3);
  2854.     Clock start_clock;
  2855.     Time start_timer;
  2856.     int display_timer, minutes = 1;
  2857.     Text txt;
  2858.     Font dis_time;
  2859.     if (!dis_time.loadFromFile("Chocolate Bar Demo.otf"))
  2860.     {
  2861.         cout << "error font";
  2862.     }
  2863.     Time elaps = seconds(200);
  2864.     int elapsed = elaps.asSeconds();
  2865.     //////////////////////////////////////////////////////////////////////////////////
  2866.     Music ingame, lost; ingame.openFromFile("ingame.wav");
  2867.     ingame.play();
  2868.     lost.openFromFile("For the Damaged Coda.wav");
  2869.     ingame.setLoop(1);
  2870.  
  2871.     //###############################################################################
  2872.     // Making of Player
  2873.     RectangleShape player(Vector2f(100, 120));
  2874.     Texture player_texture;
  2875.     Vector2u player_size;
  2876.     Clock player_clock;
  2877.     Time player_time;
  2878.     float player_position = 0;
  2879.     const int player_speed = 2;
  2880.     Generate_Charcter(player, player_texture, player_size, "mainplayer.png", 2, 2);
  2881.     //###############################################################################
  2882.  
  2883.     //###############################################################################
  2884.     // Making of Red_Monster(Smart)
  2885.     RectangleShape Red_Robot(Vector2f(100, 120));
  2886.     Texture Red_Robot_texture;
  2887.     Vector2u Red_Robot_size;
  2888.     Clock Red_Robot_clock;
  2889.     Time Red_Robot_time;
  2890.     float Red_Robot_position = 0;
  2891.     float Red_Robot_Speed = 0.6;
  2892.     Generate_Charcter(Red_Robot, Red_Robot_texture, Red_Robot_size, "red_robot.png", 14, 3);
  2893.     //###############################################################################
  2894.  
  2895.     //###############################################################################
  2896.     // Making of Blue_Skeleton(smart)
  2897.     RectangleShape Blue_Skeleton(Vector2f(100, 120));
  2898.     Texture Blue_Skeleton_text;
  2899.     Vector2u Blue_Skeleton_text_size;
  2900.     Clock Blue_Skeleton_clock;
  2901.     Time Blue_Skeleton_time;
  2902.     float Blue_Skeleton_speed = 0.3;
  2903.     float Blue_Skeleton_position = 0;
  2904.     Generate_Charcter(Blue_Skeleton, Blue_Skeleton_text, Blue_Skeleton_text_size, "smart_skeleton.png", 10, 2);
  2905.     //###############################################################################
  2906.  
  2907.     //###############################################################################
  2908.     // Making of Skeleton
  2909.     RectangleShape Skeleton(Vector2f(100, 120));
  2910.     Texture Skeleton_texture;
  2911.     Vector2u Skeleton_size;
  2912.     Clock Skeleton_clock;
  2913.     Time Skeleton_time;
  2914.     int Skeleton_Rand_motion = rand() % 4 + 1;
  2915.     int Skeleton_counter = 0;
  2916.     float Skeleton_position = 0;
  2917.     Generate_Charcter(Skeleton, Skeleton_texture, Skeleton_size, "monster (5).png", 7, 8);
  2918.     //###############################################################################
  2919.  
  2920.     //###############################################################################
  2921.     // Making of White_Robot
  2922.     RectangleShape White_Robot(Vector2f(100, 120));
  2923.     Texture White_Robot_texture;
  2924.     Vector2u White_Robot_size;
  2925.     Clock White_Robot_clock;
  2926.     Time White_Robot_time;
  2927.     int White_Robot_Rand_motion = rand() % 4 + 1;
  2928.     int White_Robot_counter = 0;
  2929.     float White_Robot_position = 0;
  2930.     Generate_Charcter(White_Robot, White_Robot_texture, White_Robot_size, "white_robot.png", 14, 8);
  2931.     //###############################################################################
  2932.  
  2933.     //###############################################################################
  2934.     // Movement stuff
  2935.     leftmovement left; rightmovement right; upmovement up; downmovement down;
  2936.     int Player_xindx = 0, Player_yindx = 0, White_Robot_xindx = 0, White_Robot_yindx = 0, Skeleton_xindx = 0, Skeleton_yindx = 0, Blue_Skeleton_xindx = 0, Blue_Skeleton_yindx = 0, Red_Robot_xindx = 0, Red_Robot_yindx = 0;
  2937.     bool Red_Robot_death = 0, White_Robot_death = 0, Skeleton_death = 0, Blue_Skeleton_death = 0;
  2938.     //###############################################################################
  2939.  
  2940.  // Making of Grid
  2941.     Texture wall, ground, wallpaper, ground2, breakable, life, bomb_frame, range, hurt, choice;
  2942.     if (!breakable.loadFromFile("breakable.png"))
  2943.     {
  2944.         cout << "error loading breakable wall pic";
  2945.     }
  2946.     if (!wallpaper.loadFromFile("wallpaper.jpg"))
  2947.     {
  2948.         cout << "error loading wallpaper pic";
  2949.     }
  2950.     if (!wall.loadFromFile("3d wall.png"))
  2951.     {
  2952.         cout << "error loading wall pic";
  2953.     }
  2954.  
  2955.     if (!ground.loadFromFile("ground 1.png"))
  2956.     {
  2957.         cout << "error loading ground pic";
  2958.     }
  2959.     if (!ground2.loadFromFile("grass.png"))
  2960.     {
  2961.         cout << "error loading grass pic";
  2962.     }
  2963.  
  2964.     if (!life.loadFromFile("flife.png"))
  2965.     {
  2966.         cout << "error loading life pic";
  2967.     }
  2968.     if (!range.loadFromFile("frange.png"))
  2969.     {
  2970.  
  2971.         cout << "error loading range pic";
  2972.     }
  2973.     if (!bomb_frame.loadFromFile("fbomb.png"))
  2974.     {
  2975.         cout << "error loading bomb pic";
  2976.     }
  2977.  
  2978.     if (!hurt.loadFromFile("hurt.png"))
  2979.     {
  2980.         cout << "error loading  hurt pic";
  2981.     }
  2982.  
  2983.     //###############################################################################
  2984.                             // Player Abilities and Features //
  2985.     Sprite lifeS, bombS, rangeS, Hurt, Wallpaper;
  2986.     Texture Rip, tomb, healskill, speedskill, rangeskill, bombskill;
  2987.     Hurt.setTexture(hurt);
  2988.     Wallpaper.setTexture(wallpaper);
  2989.     if (!life.loadFromFile("flife.png"))
  2990.     {
  2991.         cout << "error loading life pic";
  2992.     }
  2993.     if (!range.loadFromFile("frange.png"))
  2994.     {
  2995.         cout << "error loading range pic";
  2996.     }
  2997.     if (!bomb_frame.loadFromFile("fbomb.png"))
  2998.     {
  2999.         cout << "error loading bomb pic";
  3000.     }
  3001.     if (!Rip.loadFromFile("death.png"))
  3002.     {
  3003.         cout << "error loading RIP pic";
  3004.     }
  3005.     if (!tomb.loadFromFile("RIP.png"))
  3006.     {
  3007.         cout << "error loading tomb pic";
  3008.     }
  3009.     if (!healskill.loadFromFile("Heal .png"))
  3010.     {
  3011.         cout << "error to loading Heal skill" << endl;
  3012.     }
  3013.  
  3014.     if (!rangeskill.loadFromFile("Range skill.png"))
  3015.     {
  3016.         cout << "error to loading Range skill " << endl;
  3017.     }
  3018.     if (!bombskill.loadFromFile("bomb skill .png"))
  3019.     {
  3020.         cout << "error to loading Range skill " << endl;
  3021.     }
  3022.  
  3023.  
  3024.  
  3025.     //###############################################################################
  3026.  
  3027.  
  3028.  
  3029.  
  3030.     life.setSmooth(1);
  3031.     bomb_frame.setSmooth(1);
  3032.     hurt.setSmooth(1);
  3033.     range.setSmooth(1);
  3034.  
  3035.  
  3036.     //###############################################################################
  3037.     // Player abilities
  3038.     int lives = 3;
  3039.     int boombs = 1;
  3040.     Clock counter;
  3041.  
  3042.     //###############################################################################
  3043.     Texture Complete;
  3044.     Complete.loadFromFile("level-completed.png");
  3045.     Sprite Tomb, RIP_Photo, Level_complete;
  3046.     Level_complete.setTexture(Complete);
  3047.     Tomb.setTexture(tomb);
  3048.     Tomb.setScale(0.1, 0.1);
  3049.     RIP_Photo.setTexture(Rip);
  3050.     lifeS.setTexture(life);
  3051.     lifeS.setPosition(0, 250);
  3052.     lifeS.setScale(0.4, 0.4);
  3053.  
  3054.     rangeS.setTexture(range);
  3055.     rangeS.setPosition(0, 180);
  3056.     rangeS.setScale(0.4, 0.4);
  3057.  
  3058.     bombS.setTexture(bomb_frame);
  3059.     bombS.setPosition(0, 330);
  3060.     bombS.setScale(0.4, 0.4);
  3061.  
  3062.     Tomb.setTexture(tomb);
  3063.     Tomb.setScale(0.09, 0.09);
  3064.  
  3065.     RIP_Photo.setTexture(Rip);
  3066.  
  3067.     Hurt.setTexture(hurt);
  3068.     Wallpaper.setTexture(wallpaper);
  3069.     // Numbers
  3070.     Clock Clock_Damgae;
  3071.     //###############################################################################
  3072.  
  3073.  
  3074.     // Distribution of wall & ground on the Grid
  3075.  
  3076.     Sprite Grid[width + 1][length + 1];
  3077.  
  3078.     for (int i = 1; i <= width; i++)
  3079.     {
  3080.         for (int j = 1; j <= length; j++)
  3081.         {
  3082.             if (i % 2 != 0 && j % 2 != 0)
  3083.             {
  3084.  
  3085.                 Grid[i][j].setTexture(wall);
  3086.                 Grid[i][j].setPosition((i + 1.97) * 53.15, (j + 0.255) * 48);
  3087.                 Grid[i][j].setScale(Vector2f(0.1009, 0.165));
  3088.  
  3089.             }
  3090.  
  3091.             else if (i == 1 || i == width)
  3092.             {
  3093.                 Grid[i][j].setTexture(wall);
  3094.                 Grid[i][j].setPosition((i + 1.97) * 53.15, (j + 0.255) * 48);
  3095.                 Grid[i][j].setScale(Vector2f(0.1009, 0.165));
  3096.             }
  3097.             else if (j == 1 || j == length)
  3098.             {
  3099.                 Grid[i][j].setTexture(wall);
  3100.                 Grid[i][j].setPosition((i + 1.97) * 53.15, (j + 0.255) * 48);
  3101.                 Grid[i][j].setScale(Vector2f(0.1009, 0.165));
  3102.             }
  3103.             else
  3104.             {
  3105.                 if (i % 2 == j % 2) { Grid[i][j].setTexture(ground); }
  3106.                 else { Grid[i][j].setTexture(ground2); }
  3107.                 Grid[i][j].setPosition((i + 2) * 53, (j + 0.8) * 48);
  3108.                 Grid[i][j].setScale(0.1, 0.101);
  3109.             }
  3110.         }
  3111.     }
  3112.  
  3113.  
  3114.  
  3115.     for (int i = 1; i <= 30; i++)
  3116.     {
  3117.         int x = rand() % 15 + 2, y = rand() % 9 + 2;
  3118.         if (x % 2 != 0 && y % 2 != 0)
  3119.         {
  3120.             x++;
  3121.         }
  3122.         Grid[x][y].setTexture(breakable);
  3123.         Grid[x][y].setPosition((x + 1.97) * 53.15, (y + 0.255) * 48);
  3124.         Grid[x][y].setScale(Vector2f(0.1009, 0.165));
  3125.     }
  3126.  
  3127.  
  3128.  
  3129.     //###############################################################################
  3130.                //Player Bomb stuff //
  3131.     Sprite bombing, exp;
  3132.     bombing.setScale(0.2f, 0.2f);
  3133.     exp.setScale(0.25, 0.25);
  3134.     Texture playertext, player2text, bombtext, exptext;
  3135.     playertext.loadFromFile("mainplayer.png");
  3136.     player2text.loadFromFile("blue.png");
  3137.     bombtext.loadFromFile("BOOM.png");
  3138.     exptext.loadFromFile("exp.png");
  3139.     bombing.setTexture(bombtext);
  3140.     exp.setTexture(exptext);
  3141.     Vector2u text_size_bomb = bombtext.getSize();
  3142.     Vector2u text_size_exp = exptext.getSize();
  3143.     text_size_bomb.y /= 4;
  3144.     text_size_exp.x /= 3;
  3145.     text_size_exp.y /= 3;
  3146.     Time times2, times, t, ti, bomb_timer;
  3147.     Clock clocks2, c, cs, clocks, clock_timer;
  3148.  
  3149.     bomb bomb_template;
  3150.     bomb_template.sprt.setTexture(bombtext);
  3151.     bomb_template.sprt.setScale(0.15f, 0.15f);
  3152.     vector<bomb>bombs;
  3153.     int number_of_bombs = 0, range_of_bomb = 2, bomb_placement_timer = 0, superpower_of_bomb = 2, counter_placed_bombs = 0;
  3154.     int temp_range_of_bomb = 2;
  3155.     //bombs.push_back(bomb_template);
  3156.     //###############################################################################
  3157.     // abilites
  3158.  
  3159.     Sprite SuperPowers[14];
  3160.     for (int i = 0; i < 5; i++)
  3161.     {
  3162.  
  3163.         SuperPowers[i].setTexture(bombskill);           // Rand_Choice 1 => Bombing
  3164.         SuperPowers[i].setScale(0.5, 0.3);
  3165.  
  3166.     }
  3167.     for (int i = 5; i < 8; i++)
  3168.     {
  3169.         SuperPowers[i].setTexture(healskill);       // Rand_Choice 2 => Health
  3170.         SuperPowers[i].setScale(0.5, 0.3);
  3171.     }
  3172.  
  3173.     for (int i = 8; i < 13; i++)
  3174.     {
  3175.         SuperPowers[i].setTexture(rangeskill);              // Rand_Choice 3 => Range
  3176.         SuperPowers[i].setScale(0.5, 0.3);
  3177.     }
  3178.  
  3179.     SuperPowers[0].setPosition(GetXpostion(4) + 20, GetYpostion(3));
  3180.     SuperPowers[1].setPosition(GetXpostion(15) + 20, GetYpostion(4));
  3181.     SuperPowers[2].setPosition(GetXpostion(4) + 20, GetYpostion(4));
  3182.     SuperPowers[3].setPosition(GetXpostion(14) + 20, GetYpostion(10));
  3183.     SuperPowers[4].setPosition(GetXpostion(4) + 20, GetYpostion(6));
  3184.     SuperPowers[5].setPosition(GetXpostion(14) + 20, GetYpostion(3));
  3185.     SuperPowers[6].setPosition(GetXpostion(4) + 20, GetYpostion(8));
  3186.     SuperPowers[7].setPosition(GetXpostion(12) + 20, GetYpostion(10));
  3187.     SuperPowers[8].setPosition(GetXpostion(6) + 20, GetYpostion(7));
  3188.     SuperPowers[9].setPosition(GetXpostion(12) + 20, GetYpostion(6));
  3189.     SuperPowers[10].setPosition(GetXpostion(8) + 20, GetYpostion(8));
  3190.     SuperPowers[11].setPosition(GetXpostion(10) + 20, GetYpostion(9));
  3191.     SuperPowers[12].setPosition(GetXpostion(8) + 20, GetYpostion(9));
  3192.     SuperPowers[13].setPosition(GetXpostion(16) + 20, GetYpostion(4));
  3193.  
  3194.     Texture timebomb;
  3195.     timebomb.loadFromFile("time-bomb.png");
  3196.     Sprite timebombS;
  3197.     SuperPowers[13].setTexture(timebomb);               // Rand_Choice 3 => Range
  3198.     SuperPowers[13].setScale(0.05, 0.05);
  3199.  
  3200.     Time timer; Clock timer_clock;
  3201.     //###############################################################################
  3202.     // Game Window
  3203.     RenderWindow Level_3(VideoMode(1280, 768), "Legendary Mode");
  3204.     while (Level_3.isOpen())
  3205.     {
  3206.         ////////////////////////////////////////////////////////////////////////////////
  3207.         timer = timer_clock.getElapsedTime();
  3208.         display_timer = timer.asSeconds();
  3209.         string s1, s2;
  3210.         s1 = to_string(59 - (display_timer));
  3211.         s2 = to_string(minutes);
  3212.         s2 += ":";
  3213.         txt.setFont(dis_time);
  3214.         txt.setString(s2 + s1);
  3215.         txt.setPosition(512, 22);
  3216.         if (display_timer > 59 && minutes > 0)
  3217.         {
  3218.             minutes--;
  3219.             timer_clock.restart();
  3220.         }
  3221.         if (minutes == 0 && display_timer == 59) {
  3222.             Die = 1;
  3223.             ispressed = 1;
  3224.         }
  3225.         if (ispressed) {
  3226.             start_timer = start_clock.getElapsedTime();
  3227.             if (start_timer.asSeconds() >= 0.2) {
  3228.                 start_clock.restart();
  3229.                 big_exp.setPosition((Level_3.getPosition().x / 2) - 25, (Level_3.getPosition().y / 2) - 210);
  3230.                 big_exp.setTextureRect(IntRect(text_size_big_exp.x * big_pos_x, text_size_big_exp.y * big_pos_y, text_size_big_exp.x, text_size_big_exp.y));
  3231.  
  3232.                 big_pos_x++;
  3233.                 if (big_pos_x == 3) {
  3234.                     big_pos_x = 0, big_pos_y++;
  3235.                     if (big_pos_y == 2 && big_pos_x == 2) {
  3236.                         ispressed = 0;
  3237.                         big_exp.setColor(Color::Transparent);
  3238.                     }
  3239.                 }
  3240.             }
  3241.         }
  3242.         /////////////////////////////////////////////////////////////////////////////////
  3243.         string ss = to_string(temp_range_of_bomb);
  3244.  
  3245.         Text noofranges;
  3246.         noofranges.setFont(font);
  3247.         noofranges.setString(ss);
  3248.         noofranges.setCharacterSize(45);
  3249.         noofranges.setPosition(90, 195);
  3250.  
  3251.         string sss = to_string(boombs);
  3252.  
  3253.         Text noofbombs;
  3254.         noofbombs.setFont(font);
  3255.         noofbombs.setString(sss);
  3256.         noofbombs.setCharacterSize(45);
  3257.         noofbombs.setPosition(90, 335);
  3258.  
  3259.         string ssl = to_string(lives);
  3260.  
  3261.         Text nooflives;
  3262.         nooflives.setFont(font);
  3263.         nooflives.setString(ssl);
  3264.         nooflives.setCharacterSize(45);
  3265.         nooflives.setPosition(90, 270);
  3266.  
  3267.         /////////////////////////////////////////////////////////////////////////////////
  3268.  
  3269.     //######################################################################################################
  3270.  
  3271.         // Player Movement
  3272.         Player_xindx = (float)((float)(player.getPosition().x - 183) / 53 + 2);
  3273.         Player_yindx = (float)((float)(player.getPosition().y - 74) / 48 + 2);
  3274.         right.i = GetXindx(player.getPosition().x + 20); right.j = Player_yindx;
  3275.         left.i = GetXindx(player.getPosition().x - 20); left.j = Player_yindx;
  3276.         up.i = Player_xindx; up.j = GetYindx(player.getPosition().y - 7);
  3277.         down.i = Player_xindx; down.j = GetYindx(player.getPosition().y + 7);
  3278.  
  3279.         if (Keyboard::isKeyPressed(Keyboard::Key::Right) && (Grid[right.i][right.j].getTexture() == &ground || Grid[right.i][right.j].getTexture() == &ground2))      // Moving Right
  3280.         {
  3281.             bool check_bomb = 0;
  3282.             for (int io = 0; io < bombs.size(); io++)
  3283.             {
  3284.                 if (bombs[io].x_index == GetXindx(player.getPosition().x + 1) && bombs[io].x_index != GetXindx(player.getPosition().x) && bombs[io].y_index == right.j)
  3285.                 {
  3286.                     check_bomb = 1; break;
  3287.                 }
  3288.             }
  3289.             if (!check_bomb)
  3290.                 Movement_Right(player, player_time, player_clock, player_position, player_size, player_speed);
  3291.         }
  3292.         else if (Keyboard::isKeyPressed(Keyboard::Key::Left) && (Grid[left.i][left.j].getTexture() == &ground || Grid[left.i][left.j].getTexture() == &ground2))         // Moving Left
  3293.         {
  3294.             bool check_bomb = 0;
  3295.             for (int io = 0; io < bombs.size(); io++)
  3296.             {
  3297.                 if (bombs[io].x_index == GetXindx(player.getPosition().x - 1) && bombs[io].x_index != GetXindx(player.getPosition().x) && bombs[io].y_index == left.j)
  3298.                 {
  3299.                     check_bomb = 1; break;
  3300.                 }
  3301.             }
  3302.             if (!check_bomb)
  3303.                 Movement_Left(player, player_time, player_clock, player_position, player_size, player_speed);
  3304.         }
  3305.         else if (Keyboard::isKeyPressed(Keyboard::Key::Up) && (Grid[GetXindx(player.getPosition().x + 25)][up.j].getTexture() == &ground || Grid[up.i][up.j].getTexture() == &ground2))           // Moving Up
  3306.         {
  3307.             bool check_bomb = 0;
  3308.             for (int io = 0; io < bombs.size(); io++)
  3309.             {
  3310.                 if (bombs[io].y_index == GetYindx(player.getPosition().y - 1) && bombs[io].y_index != GetYindx(player.getPosition().y) && bombs[io].x_index == up.i)
  3311.                 {
  3312.                     check_bomb = 1; break;
  3313.                 }
  3314.             }
  3315.             if (!check_bomb)
  3316.                 Movement_Upward(player, player_time, player_clock, player_position, player_size, player_speed);
  3317.  
  3318.         }
  3319.         else if (Keyboard::isKeyPressed(Keyboard::Key::Down) && (Grid[GetXindx(player.getPosition().x + 25)][down.j].getTexture() == &ground || Grid[down.i][down.j].getTexture() == &ground2))         // Moving Down
  3320.         {
  3321.             bool check_bomb = 0;
  3322.             for (int io = 0; io < bombs.size(); io++)
  3323.             {
  3324.                 if (bombs[io].y_index == GetYindx(player.getPosition().y + 1) && bombs[io].y_index != GetYindx(player.getPosition().y) && bombs[io].x_index == up.i)
  3325.                 {
  3326.                     check_bomb = 1; break;
  3327.                 }
  3328.             }
  3329.             if (!check_bomb)
  3330.  
  3331.                 Movement_Downward(player, player_time, player_clock, player_position, player_size, player_speed);
  3332.         }
  3333.  
  3334.         //######################################################################################################
  3335.         //######################################################################################################
  3336.  
  3337.  
  3338.  
  3339.         //######################################################################################################
  3340.         // Smart_Skeleton movement
  3341.         Blue_Skeleton_xindx = (float)((float)(Blue_Skeleton.getPosition().x - 183) / 53 + 2);
  3342.         Blue_Skeleton_yindx = (float)((float)(Blue_Skeleton.getPosition().y - 74) / 48 + 2);
  3343.         right.i = GetXindx(Blue_Skeleton.getPosition().x + 20); right.j = Blue_Skeleton_yindx;
  3344.         left.i = GetXindx(Blue_Skeleton.getPosition().x - 20); left.j = Blue_Skeleton_yindx;
  3345.         up.i = Blue_Skeleton_xindx; up.j = GetYindx(Blue_Skeleton.getPosition().y - 7);
  3346.         down.i = Blue_Skeleton_xindx; down.j = GetYindx(Blue_Skeleton.getPosition().y + 7);
  3347.  
  3348.         // Call BFS
  3349.         BFS(Player_xindx, Player_yindx, Blue_Skeleton_xindx, Blue_Skeleton_yindx, Grid, ground, ground2);
  3350.  
  3351.         // Movement
  3352.         if (Smart_Skeleton_Movement.i == Blue_Skeleton_xindx && Smart_Skeleton_Movement.j - Blue_Skeleton_yindx == 1) {
  3353.             Movement_Downward(Blue_Skeleton, Blue_Skeleton_time, Blue_Skeleton_clock, Blue_Skeleton_position, Blue_Skeleton_text_size, Blue_Skeleton_speed);    // Moving Downward
  3354.         }
  3355.         else if (Smart_Skeleton_Movement.i == Blue_Skeleton_xindx && Smart_Skeleton_Movement.j - Blue_Skeleton_yindx == -1) {
  3356.             Movement_Upward(Blue_Skeleton, Blue_Skeleton_time, Blue_Skeleton_clock, Blue_Skeleton_position, Blue_Skeleton_text_size, Blue_Skeleton_speed);      // Moving Upward
  3357.         }
  3358.         else if (Smart_Skeleton_Movement.i - Blue_Skeleton_xindx == 1 && Smart_Skeleton_Movement.j == Blue_Skeleton_yindx) {
  3359.             Movement_Right(Blue_Skeleton, Blue_Skeleton_time, Blue_Skeleton_clock, Blue_Skeleton_position, Blue_Skeleton_text_size, Blue_Skeleton_speed);       // Moving Right
  3360.         }
  3361.         else if (Smart_Skeleton_Movement.i - Blue_Skeleton_xindx == -1 && Smart_Skeleton_Movement.j == Blue_Skeleton_yindx) {
  3362.             Movement_Left(Blue_Skeleton, Blue_Skeleton_time, Blue_Skeleton_clock, Blue_Skeleton_position, Blue_Skeleton_text_size, Blue_Skeleton_speed);        // Moving Left
  3363.         }
  3364.  
  3365.         //######################################################################################################
  3366.  
  3367.  
  3368.         //######################################################################################################
  3369.         // Red_Robot movement
  3370.         Red_Robot_xindx = (float)((float)(Red_Robot.getPosition().x - 183) / 53 + 2);
  3371.         Red_Robot_yindx = (float)((float)(Red_Robot.getPosition().y - 74) / 48 + 2);
  3372.         right.i = GetXindx(Red_Robot.getPosition().x + 20); right.j = Red_Robot_yindx;
  3373.         left.i = GetXindx(Red_Robot.getPosition().x - 20); left.j = Red_Robot_yindx;
  3374.         up.i = Red_Robot_xindx; up.j = GetYindx(Red_Robot.getPosition().y - 7);
  3375.         down.i = Red_Robot_xindx; down.j = GetYindx(Red_Robot.getPosition().y + 7);
  3376.  
  3377.         // Call BFS
  3378.         BFS(Player_xindx, Player_yindx, Red_Robot_xindx, Red_Robot_yindx, Grid, ground, ground2);
  3379.  
  3380.         // Movement
  3381.         if (Red_Robot_Movement.i == Red_Robot_xindx && Red_Robot_Movement.j - Red_Robot_yindx == 1) {
  3382.             Movement_Downward(Red_Robot, Red_Robot_time, Red_Robot_clock, Red_Robot_position, Red_Robot_size, Red_Robot_Speed); // Moving Downward
  3383.         }
  3384.         else if (Red_Robot_Movement.i == Red_Robot_xindx && Red_Robot_Movement.j - Red_Robot_yindx == -1) {
  3385.             Movement_Upward(Red_Robot, Red_Robot_time, Red_Robot_clock, Red_Robot_position, Red_Robot_size, Red_Robot_Speed);   // Moving Upward
  3386.         }
  3387.         else if (Red_Robot_Movement.i - Red_Robot_xindx == 1 && Red_Robot_Movement.j == Red_Robot_yindx) {
  3388.             Movement_Right(Red_Robot, Red_Robot_time, Red_Robot_clock, Red_Robot_position, Red_Robot_size, Red_Robot_Speed);    // Movement Right
  3389.         }
  3390.         else if (Red_Robot_Movement.i - Red_Robot_xindx == -1 && Red_Robot_Movement.j == Red_Robot_yindx) {
  3391.             Movement_Left(Red_Robot, Red_Robot_time, Red_Robot_clock, Red_Robot_position, Red_Robot_size, Red_Robot_Speed); // Moving left
  3392.         }
  3393.  
  3394.         //######################################################################################################
  3395.  
  3396.  
  3397.  
  3398.  
  3399.         // Skeleton movement
  3400.         Skeleton_xindx = (float)((float)(Skeleton.getPosition().x - 183) / 53 + 2);
  3401.         Skeleton_yindx = (float)((float)(Skeleton.getPosition().y - 74) / 48 + 2);
  3402.         right.i = GetXindx(Skeleton.getPosition().x + 20); right.j = Skeleton_yindx;
  3403.         left.i = GetXindx(Skeleton.getPosition().x - 20); left.j = Skeleton_yindx;
  3404.         up.i = Skeleton_xindx; up.j = GetYindx(Skeleton.getPosition().y - 7);
  3405.         down.i = Skeleton_xindx; down.j = GetYindx(Skeleton.getPosition().y + 7);
  3406.         //######################################################################################################
  3407.  
  3408.         //######################################################################################################
  3409.         // Skeleton Movement
  3410.         if (Skeleton_counter >= 250)
  3411.         {
  3412.             Skeleton_Rand_motion = rand() % 4 + 1;
  3413.             Skeleton_counter = 0;
  3414.         }
  3415.  
  3416.         if (Skeleton_Rand_motion == 1)                                          // Moving UP => Rand_motion == 1
  3417.         {
  3418.             Skeleton_counter++;
  3419.             if (Grid[GetXindx(Skeleton.getPosition().x + 25)][up.j].getTexture() == &ground || Grid[up.i][up.j].getTexture() == &ground2)
  3420.             {
  3421.  
  3422.                 Movement_Upward(Skeleton, Skeleton_time, Skeleton_clock, Skeleton_position, Skeleton_size, Random_Monsters_Speed);
  3423.  
  3424.             }
  3425.             else
  3426.             {
  3427.                 Skeleton_counter = 250;
  3428.             }
  3429.  
  3430.         }
  3431.  
  3432.  
  3433.         else if (Skeleton_Rand_motion == 2)                                 // Moving Down => Rand_motion == 2
  3434.         {
  3435.             Skeleton_counter++;
  3436.             if (Grid[GetXindx(Skeleton.getPosition().x + 25)][down.j].getTexture() == &ground || Grid[down.i][down.j].getTexture() == &ground2)
  3437.             {
  3438.                 Movement_Downward(Skeleton, Skeleton_time, Skeleton_clock, Skeleton_position, Skeleton_size, Random_Monsters_Speed);
  3439.  
  3440.             }
  3441.  
  3442.             else
  3443.             {
  3444.                 Skeleton_counter = 250;
  3445.             }
  3446.         }
  3447.  
  3448.  
  3449.         else if (Skeleton_Rand_motion == 3)                                 // Moving Right => Rand_motion == 3
  3450.         {
  3451.             Skeleton_counter++;
  3452.             if (Grid[right.i][right.j].getTexture() == &ground || Grid[right.i][right.j].getTexture() == &ground2)
  3453.             {
  3454.                 Movement_Right(Skeleton, Skeleton_time, Skeleton_clock, Skeleton_position, Skeleton_size, Random_Monsters_Speed);
  3455.  
  3456.             }
  3457.             else
  3458.             {
  3459.                 Skeleton_counter = 250;
  3460.             }
  3461.         }
  3462.  
  3463.  
  3464.         else if (Skeleton_Rand_motion == 4)                                 // Moving Left => Rand_motion == 4
  3465.         {
  3466.             Skeleton_counter++;
  3467.             if (Grid[left.i][left.j].getTexture() == &ground || Grid[left.i][left.j].getTexture() == &ground2)
  3468.             {
  3469.                 Movement_Left(Skeleton, Skeleton_time, Skeleton_clock, Skeleton_position, Skeleton_size, Random_Monsters_Speed);
  3470.  
  3471.             }
  3472.             else
  3473.             {
  3474.                 Skeleton_counter = 250;
  3475.             }
  3476.  
  3477.         }
  3478.  
  3479.         //######################################################################################################
  3480.         // White_Robot movement
  3481.         White_Robot_xindx = (float)((float)(White_Robot.getPosition().x - 183) / 53 + 2);
  3482.         White_Robot_yindx = (float)((float)(White_Robot.getPosition().y - 74) / 48 + 2);
  3483.         right.i = GetXindx(White_Robot.getPosition().x + 20); right.j = White_Robot_yindx;
  3484.         left.i = GetXindx(White_Robot.getPosition().x - 20); left.j = White_Robot_yindx;
  3485.         up.i = White_Robot_xindx; up.j = GetYindx(White_Robot.getPosition().y - 7);
  3486.         down.i = White_Robot_xindx; down.j = GetYindx(White_Robot.getPosition().y + 7);
  3487.         //######################################################################################################
  3488.  
  3489.         //######################################################################################################
  3490.         // White_Robot Movement
  3491.         if (White_Robot_counter >= 250)
  3492.         {
  3493.             White_Robot_Rand_motion = rand() % 4 + 1;
  3494.             White_Robot_counter = 0;
  3495.         }
  3496.  
  3497.         if (White_Robot_Rand_motion == 1)                                           // Moving UP => Rand_motion == 1
  3498.         {
  3499.             White_Robot_counter++;
  3500.             if (Grid[GetXindx(White_Robot.getPosition().x + 25)][up.j].getTexture() == &ground || Grid[up.i][up.j].getTexture() == &ground2)
  3501.             {
  3502.  
  3503.                 Movement_Upward(White_Robot, White_Robot_time, White_Robot_clock, White_Robot_position, White_Robot_size, Random_Monsters_Speed);
  3504.  
  3505.             }
  3506.             else
  3507.             {
  3508.                 White_Robot_counter = 250;
  3509.             }
  3510.  
  3511.         }
  3512.  
  3513.  
  3514.         else if (White_Robot_Rand_motion == 2)                                  // Moving Down => Rand_motion == 2
  3515.         {
  3516.             White_Robot_counter++;
  3517.             if (Grid[GetXindx(White_Robot.getPosition().x + 25)][down.j].getTexture() == &ground || Grid[down.i][down.j].getTexture() == &ground2)
  3518.             {
  3519.                 Movement_Downward(White_Robot, White_Robot_time, White_Robot_clock, White_Robot_position, White_Robot_size, Random_Monsters_Speed);
  3520.             }
  3521.  
  3522.             else
  3523.             {
  3524.                 White_Robot_counter = 250;
  3525.             }
  3526.         }
  3527.  
  3528.  
  3529.         else if (White_Robot_Rand_motion == 3)                                  // Moving Right => Rand_motion == 3
  3530.         {
  3531.             White_Robot_counter++;
  3532.             if (Grid[right.i][right.j].getTexture() == &ground || Grid[right.i][right.j].getTexture() == &ground2)
  3533.             {
  3534.                 Movement_Right(White_Robot, White_Robot_time, White_Robot_clock, White_Robot_position, White_Robot_size, Random_Monsters_Speed);
  3535.             }
  3536.             else
  3537.             {
  3538.                 White_Robot_counter = 250;
  3539.             }
  3540.         }
  3541.  
  3542.  
  3543.         else if (White_Robot_Rand_motion == 4)                                  // Moving Left => Rand_motion == 4
  3544.         {
  3545.             White_Robot_counter++;
  3546.             if (Grid[left.i][left.j].getTexture() == &ground || Grid[left.i][left.j].getTexture() == &ground2)
  3547.             {
  3548.                 Movement_Left(White_Robot, White_Robot_time, White_Robot_clock, White_Robot_position, White_Robot_size, Random_Monsters_Speed);
  3549.             }
  3550.             else
  3551.             {
  3552.                 White_Robot_counter = 250;
  3553.             }
  3554.  
  3555.         }
  3556.  
  3557.         //######################################################################################################
  3558.  
  3559.  
  3560.  
  3561.         Event event;
  3562.         while (Level_3.pollEvent(event))
  3563.         {
  3564.             if (event.type == sf::Event::Closed || Keyboard::isKeyPressed(Keyboard::Escape))
  3565.                 Level_3.close();
  3566.  
  3567.         }
  3568.  
  3569.         //#####################################################################################################
  3570.         // Bombing stuff
  3571.             // bombing
  3572.  
  3573.         if (bomb_placement_timer < 80)
  3574.         {
  3575.             bomb_placement_timer++;
  3576.         }
  3577.         if (Keyboard::isKeyPressed(Keyboard::Key::Space) && bomb_placement_timer == 80 && counter_placed_bombs < boombs) {
  3578.             bombs.push_back(bomb_template);
  3579.             bombs[bombs.size() - 1].bomb_clock.restart();
  3580.             bombs[bombs.size() - 1].explosion_clock.restart();
  3581.             bombs[bombs.size() - 1].start_clock.restart();
  3582.             bombs[bombs.size() - 1].bomb_placed = 1;
  3583.             bombs[bombs.size() - 1].x_pos = GetXpostion(Player_xindx) + 12;
  3584.             bombs[bombs.size() - 1].y_pos = GetYpostion(Player_yindx) + 12;
  3585.             bombs[bombs.size() - 1].x_index = GetXindx(bombs[bombs.size() - 1].x_pos);
  3586.             bombs[bombs.size() - 1].y_index = GetYindx(bombs[bombs.size() - 1].y_pos);
  3587.             bombs[bombs.size() - 1].sprt.setPosition(bombs[bombs.size() - 1].x_pos, bombs[bombs.size() - 1].y_pos);
  3588.             bombs[bombs.size() - 1].sprt.setTextureRect(IntRect(0, text_size_bomb.y * bombs[bombs.size() - 1].bomb_animation_y, text_size_bomb.x, text_size_bomb.y));
  3589.             bomb_placement_timer = 0;
  3590.         }
  3591.  
  3592.         for (int io = 0; io < bombs.size(); io++)
  3593.         {
  3594.             if (bombs[io].bomb_placed == 1) {
  3595.                 bombs[io].bomb_time = bombs[io].bomb_clock.getElapsedTime();
  3596.                 bombs[io].start_explosion = bombs[io].start_clock.getElapsedTime();
  3597.                 if (bombs[io].bomb_time.asSeconds() >= 0.2) {
  3598.                     bombs[io].bomb_clock.restart();
  3599.                     bombs[io].sprt.setPosition(bombs[io].x_pos, bombs[io].y_pos + 25);
  3600.                     bombs[io].sprt.setTextureRect(IntRect(0, text_size_bomb.y * bombs[io].bomb_animation_y, text_size_bomb.x, text_size_bomb.y));
  3601.                     bombs[io].bomb_animation_y += 2;
  3602.                     if (bombs[io].bomb_animation_y > 2)
  3603.                         bombs[io].bomb_animation_y = 0;
  3604.                 }
  3605.                 if (bombs[io].start_explosion.asSeconds() >= 3) {
  3606.                     bombs[io].bomb_exploded = 1;
  3607.                     bombs[io].bomb_placed = 0;
  3608.                     //                bombs[number_of_bombs].sprt.setColor(Color::Transparent);
  3609.                     for (int k = 0; k <= range_of_bomb; k++)
  3610.                     {
  3611.                         bombs[io].range_right.push_back(exp);
  3612.                         bombs[io].range_left.push_back(exp);
  3613.                         bombs[io].range_up.push_back(exp);
  3614.                         bombs[io].range_down.push_back(exp);
  3615.                         //                     v[z].push_back(exp);
  3616.                     }
  3617.                 }
  3618.             }
  3619.             //cout<<player.getPosition().x<<' '<<player.getPosition().y<<endl;
  3620.             if (bombs[io].bomb_exploded) {
  3621.                 bombs[io].explosion_time = bombs[io].explosion_clock.getElapsedTime();
  3622.                 if (bombs[io].explosion_time.asSeconds() >= 0.08) {
  3623.                     bombs[io].explosion_clock.restart();
  3624.                     for (int n = 0, k = 0; k < bombs[io].range_right.size(), n <= range_of_bomb * 50; k++, n += 50)
  3625.                         bombs[io].range_right[k].setPosition(bombs[io].x_pos + n, bombs[io].y_pos);
  3626.  
  3627.                     for (int n = 0, k = 0; k < bombs[io].range_right.size(), n <= range_of_bomb * 50; k++, n += 50)
  3628.                         bombs[io].range_right[k].setTextureRect(IntRect(text_size_exp.x * bombs[io].exp_animation_x, text_size_exp.y * bombs[io].exp_animation_y, text_size_exp.x, text_size_exp.y));
  3629.  
  3630.                     for (int n = 0, k = 0; k < bombs[io].range_left.size(), n <= range_of_bomb * 50; k++, n += 50)
  3631.                         bombs[io].range_left[k].setPosition(bombs[io].x_pos - n, bombs[io].y_pos);
  3632.  
  3633.                     for (int n = 0, k = 0; k < bombs[io].range_left.size(), n <= range_of_bomb * 50; k++, n += 50)
  3634.                         bombs[io].range_left[k].setTextureRect(IntRect(text_size_exp.x * bombs[io].exp_animation_x, text_size_exp.y * bombs[io].exp_animation_y, text_size_exp.x, text_size_exp.y));
  3635.  
  3636.                     for (int n = 0, k = 0; k < bombs[io].range_up.size(), n <= range_of_bomb * 50; k++, n += 50)
  3637.                         bombs[io].range_up[k].setPosition(bombs[io].x_pos, bombs[io].y_pos - n);
  3638.  
  3639.                     for (int n = 0, k = 0; k < bombs[io].range_up.size(), n <= range_of_bomb * 50; k++, n += 50)
  3640.                         bombs[io].range_up[k].setTextureRect(IntRect(text_size_exp.x * bombs[io].exp_animation_x, text_size_exp.y * bombs[io].exp_animation_y, text_size_exp.x, text_size_exp.y));
  3641.  
  3642.                     for (int n = 0, k = 0; k < bombs[io].range_down.size(), n <= range_of_bomb * 50; k++, n += 50)
  3643.                         bombs[io].range_down[k].setPosition(bombs[io].x_pos, bombs[io].y_pos + n);
  3644.  
  3645.                     for (int n = 0, k = 0; k < bombs[io].range_down.size(), n <= range_of_bomb * 50; k++, n += 50)
  3646.                         bombs[io].range_down[k].setTextureRect(IntRect(text_size_exp.x * bombs[io].exp_animation_x, text_size_exp.y * bombs[io].exp_animation_y, text_size_exp.x, text_size_exp.y));
  3647.  
  3648.                     bombs[io].exp_animation_x++;
  3649.                     if (bombs[io].exp_animation_x == 3) {
  3650.                         bombs[io].exp_animation_x = 0, bombs[io].exp_animation_y++;
  3651.                         if (bombs[io].exp_animation_y == 3) {
  3652.                             bombs[io].bomb_exploded = 0;
  3653.                             bombs.erase(bombs.begin());
  3654.  
  3655.                         }
  3656.                     }
  3657.                 }
  3658.             }
  3659.         }
  3660.  
  3661.         // Drawing of the Wallpaper
  3662.         Level_3.clear();
  3663.         Level_3.draw(Wallpaper);
  3664.  
  3665.         //Drawing of The Map
  3666.         for (int i = 2; i < width; i++)
  3667.         {
  3668.             for (int j = 2; j < length; j++)
  3669.             {
  3670.                 if (Grid[i][j].getTexture() == &ground || Grid[i][j].getTexture() == &ground2)
  3671.                 {
  3672.                     Level_3.draw(Grid[i][j]);
  3673.                 }
  3674.             }
  3675.  
  3676.         }
  3677.  
  3678.         for (int i = 0; i < 14; i++)
  3679.         {
  3680.             Level_3.draw(SuperPowers[i]);
  3681.         }
  3682.         for (int j = 1; j <= length; j++)
  3683.         {
  3684.             for (int i = 1; i <= width; i++)
  3685.             {
  3686.                 if (Grid[i][j].getTexture() == &ground || Grid[i][j].getTexture() == &ground2)
  3687.                 {
  3688.                     continue;
  3689.                 }
  3690.  
  3691.                 Level_3.draw(Grid[i][j]);
  3692.  
  3693.                 if (GetYindx(player.getPosition().y) >= j)
  3694.                 {
  3695.                     Level_3.draw(player);
  3696.                 }
  3697.  
  3698.                 if (GetYindx(Skeleton.getPosition().y) >= j && !Skeleton_death)
  3699.                 {
  3700.                     Level_3.draw(Skeleton);
  3701.                 }
  3702.  
  3703.                 if (GetYindx(White_Robot.getPosition().y) >= j && !White_Robot_death)
  3704.                 {
  3705.                     Level_3.draw(White_Robot);
  3706.                 }
  3707.  
  3708.                 if (GetYindx(Blue_Skeleton.getPosition().y) >= j && !Blue_Skeleton_death)
  3709.                 {
  3710.                     Level_3.draw(Blue_Skeleton);
  3711.                 }
  3712.  
  3713.                 if (GetYindx(Red_Robot.getPosition().y) >= j && !Red_Robot_death)
  3714.                 {
  3715.                     Level_3.draw(Red_Robot);
  3716.                 }
  3717.                 for (int io = 0; io < bombs.size(); io++)
  3718.                 {
  3719.                     if (bombs[io].y_index >= j && bombs[io].bomb_placed)
  3720.                     {
  3721.                         Level_3.draw(bombs[io].sprt);
  3722.                     }
  3723.                 }
  3724.             }
  3725.         }
  3726.  
  3727.  
  3728.  
  3729.         for (int io = 0; io < bombs.size(); io++)
  3730.         {
  3731.             //if (bombs[io].bomb_placed)
  3732.                 //window.draw(bombs[io].sprt);
  3733.             if (bombs[io].bomb_exploded)
  3734.             {
  3735.  
  3736.                 //Right
  3737.                 for (int g = 0; g <= range_of_bomb; g++)
  3738.                 {
  3739.  
  3740.                     Level_3.draw(bombs[io].range_right[g]);
  3741.  
  3742.                     if ((Grid[bombs[io].x_index + g][bombs[io].y_index].getTexture() == &breakable) && bombs[io].flag_range_right)
  3743.                     {
  3744.                         destroy_breakable_walls(bombs[io].x_index + g, bombs[io].y_index, Grid, ground, ground2);
  3745.                         bombs[io].flag_range_right = 0;
  3746.                         break;
  3747.                     }
  3748.                     else if (Grid[bombs[io].x_index + g][bombs[io].y_index].getTexture() == &wall)
  3749.                     {
  3750.  
  3751.                         bombs[io].flag_range_right = 0;
  3752.                         break;
  3753.                     }
  3754.  
  3755.                     if (bombs[io].x_index + g == Player_xindx && bombs[io].y_index == Player_yindx && bombs[io].flag_range_right)
  3756.                     {
  3757.                         if (Clock_Damgae.getElapsedTime().asSeconds() >= 1) {
  3758.                             lives--;
  3759.                             ssl = to_string(lives);
  3760.                             Clock_Damgae.restart();
  3761.                         }
  3762.                         Level_3.draw(Hurt);
  3763.                     }
  3764.  
  3765.                     if (bombs[io].x_index + g == Red_Robot_xindx && bombs[io].y_index == Red_Robot_yindx && bombs[io].flag_range_right)
  3766.                     {
  3767.                         Red_Robot_death = 1;
  3768.                         Red_Robot.setFillColor(Color::Transparent);
  3769.                     }
  3770.                     if (bombs[io].x_index + g == White_Robot_xindx && bombs[io].y_index == White_Robot_yindx && bombs[io].flag_range_right)
  3771.                     {
  3772.                         White_Robot_death = 1;
  3773.                         White_Robot.setFillColor(Color::Transparent);
  3774.                     }
  3775.                     if (bombs[io].x_index + g == Skeleton_xindx && bombs[io].y_index == Skeleton_yindx && bombs[io].flag_range_right)
  3776.                     {
  3777.                         Skeleton_death = 1;
  3778.                         Skeleton.setFillColor(Color::Transparent);
  3779.                     }
  3780.                     if (bombs[io].x_index + g == GetXindx(Blue_Skeleton.getPosition().x) && bombs[io].y_index == GetYindx(Blue_Skeleton.getPosition().y) && bombs[io].flag_range_right)
  3781.                     {
  3782.                         Blue_Skeleton_death = 1;
  3783.                         Blue_Skeleton.setFillColor(Color::Transparent);
  3784.                     }
  3785.  
  3786.  
  3787.                 }
  3788.  
  3789.  
  3790.                 //UP
  3791.                 for (int g = 0; g <= range_of_bomb; g++)
  3792.                 {
  3793.  
  3794.                     Level_3.draw(bombs[io].range_up[g]);
  3795.  
  3796.                     if ((Grid[bombs[io].x_index][bombs[io].y_index - g].getTexture() == &breakable) && bombs[io].flag_range_up)
  3797.                     {
  3798.  
  3799.  
  3800.                         destroy_breakable_walls(bombs[io].x_index, bombs[io].y_index - g, Grid, ground, ground2);
  3801.  
  3802.                         bombs[io].flag_range_up = 0;
  3803.                         break;
  3804.  
  3805.                     }
  3806.                     else if (Grid[bombs[io].x_index][bombs[io].y_index - g].getTexture() == &wall)
  3807.                     {
  3808.  
  3809.                         bombs[io].flag_range_up = 0;
  3810.                         break;
  3811.                     }
  3812.  
  3813.                     if (bombs[io].x_index == Player_xindx && bombs[io].y_index - g == Player_yindx && bombs[io].flag_range_up)
  3814.                     {
  3815.                         if (Clock_Damgae.getElapsedTime().asSeconds() >= 1) {
  3816.                             lives--;
  3817.                             ssl = to_string(lives);
  3818.                             Clock_Damgae.restart();
  3819.                         }
  3820.                         Level_3.draw(Hurt);
  3821.                     }
  3822.  
  3823.                     if (bombs[io].x_index == Red_Robot_xindx && bombs[io].y_index - g == Red_Robot_yindx && bombs[io].flag_range_up)
  3824.                     {
  3825.                         Red_Robot_death = 1;
  3826.                         Red_Robot.setFillColor(Color::Transparent);
  3827.                     }
  3828.                     if (bombs[io].x_index == White_Robot_xindx && bombs[io].y_index - g == White_Robot_yindx && bombs[io].flag_range_up)
  3829.                     {
  3830.                         White_Robot_death = 1;
  3831.                         White_Robot.setFillColor(Color::Transparent);
  3832.                     }
  3833.                     if (bombs[io].x_index == Skeleton_xindx && bombs[io].y_index - g == Skeleton_yindx && bombs[io].flag_range_up)
  3834.                     {
  3835.                         Skeleton_death = 1;
  3836.                         Skeleton.setFillColor(Color::Transparent);
  3837.                     }
  3838.                     if (bombs[io].x_index == GetXindx(Blue_Skeleton.getPosition().x) && bombs[io].y_index - g == GetYindx(Blue_Skeleton.getPosition().y) && bombs[io].flag_range_up)
  3839.                     {
  3840.                         Blue_Skeleton_death = 1;
  3841.                         Blue_Skeleton.setFillColor(Color::Transparent);
  3842.                     }
  3843.  
  3844.                 }
  3845.  
  3846.                 //Left
  3847.                 for (int g = 0; g <= range_of_bomb; g++)
  3848.                 {
  3849.  
  3850.                     Level_3.draw(bombs[io].range_left[g]);
  3851.  
  3852.                     if ((Grid[bombs[io].x_index - g][bombs[io].y_index].getTexture() == &breakable) && bombs[io].flag_range_left)
  3853.                     {
  3854.                         destroy_breakable_walls(bombs[io].x_index - g, bombs[io].y_index, Grid, ground, ground2);
  3855.  
  3856.                         bombs[io].flag_range_left = 0;
  3857.                         break;
  3858.                     }
  3859.                     else if (Grid[bombs[io].x_index - g][bombs[io].y_index].getTexture() == &wall)
  3860.                     {
  3861.                         bombs[io].flag_range_left = 0;
  3862.                         break;
  3863.                     }
  3864.                     if (bombs[io].x_index - g == Player_xindx && bombs[io].y_index == Player_yindx && bombs[io].flag_range_left)
  3865.                     {
  3866.                         if (Clock_Damgae.getElapsedTime().asSeconds() >= 1) {
  3867.                             lives--;
  3868.                             //SuperPowers[i].setColor(Color::Transparent);
  3869.                             ssl = to_string(lives);
  3870.                             //counter.restart();
  3871.                             Clock_Damgae.restart();
  3872.                         }
  3873.                         Level_3.draw(Hurt);
  3874.                     }
  3875.  
  3876.                     if (bombs[io].x_index - g == Red_Robot_xindx - g && bombs[io].y_index == Red_Robot_yindx && bombs[io].flag_range_left)
  3877.                     {
  3878.                         Red_Robot_death = 1;
  3879.                         Red_Robot.setFillColor(Color::Transparent);
  3880.                     }
  3881.                     if (bombs[io].x_index - g == White_Robot_xindx && bombs[io].y_index == White_Robot_yindx && bombs[io].flag_range_left)
  3882.                     {
  3883.                         White_Robot_death = 1;
  3884.                         White_Robot.setFillColor(Color::Transparent);
  3885.                     }
  3886.                     if (bombs[io].x_index - g == Skeleton_xindx && bombs[io].y_index == Skeleton_yindx && bombs[io].flag_range_left)
  3887.                     {
  3888.                         Skeleton_death = 1;
  3889.                         Skeleton.setFillColor(Color::Transparent);
  3890.                     }
  3891.                     if (bombs[io].x_index - g == GetXindx(Blue_Skeleton.getPosition().x) && bombs[io].y_index == GetYindx(Blue_Skeleton.getPosition().y) && bombs[io].flag_range_left)
  3892.                     {
  3893.                         Blue_Skeleton_death = 1;
  3894.                         Blue_Skeleton.setFillColor(Color::Transparent);
  3895.                     }
  3896.  
  3897.                 }
  3898.  
  3899.                 //Down
  3900.                 for (int g = 0; g <= range_of_bomb; g++)
  3901.                 {
  3902.  
  3903.                     Level_3.draw(bombs[io].range_down[g]);
  3904.                     if ((Grid[bombs[io].x_index][bombs[io].y_index + g].getTexture() == &breakable) && bombs[io].flag_range_down)
  3905.                     {
  3906.                         destroy_breakable_walls(bombs[io].x_index, bombs[io].y_index + g, Grid, ground, ground2);
  3907.                         bombs[io].flag_range_down = 0;
  3908.                         break;
  3909.                     }
  3910.                     else if (Grid[bombs[io].x_index][bombs[io].y_index + g].getTexture() == &wall)
  3911.                     {
  3912.  
  3913.                         bombs[io].flag_range_down = 0;
  3914.                         break;
  3915.                     }
  3916.                     if (bombs[io].x_index == Player_xindx && bombs[io].y_index + g == Player_yindx && bombs[io].flag_range_down)
  3917.                     {
  3918.                         if (Clock_Damgae.getElapsedTime().asSeconds() >= 1) {
  3919.                             lives--;
  3920.                             ssl = to_string(lives);
  3921.                             Clock_Damgae.restart();
  3922.                         }
  3923.                         Level_3.draw(Hurt);
  3924.                     }
  3925.  
  3926.                     if (bombs[io].x_index == Red_Robot_xindx && bombs[io].y_index + g == Red_Robot_yindx && bombs[io].flag_range_down)
  3927.                     {
  3928.                         Red_Robot_death = 1;
  3929.                         Red_Robot.setFillColor(Color::Transparent);
  3930.                     }
  3931.                     if (bombs[io].x_index == White_Robot_xindx && bombs[io].y_index + g == White_Robot_yindx && bombs[io].flag_range_down)
  3932.                     {
  3933.                         White_Robot_death = 1;
  3934.                         White_Robot.setFillColor(Color::Transparent);
  3935.                     }
  3936.                     if (bombs[io].x_index == Skeleton_xindx && bombs[io].y_index + g == Skeleton_yindx && bombs[io].flag_range_down)
  3937.                     {
  3938.                         Skeleton_death = 1;
  3939.                         Skeleton.setFillColor(Color::Transparent);
  3940.                     }
  3941.                     if (bombs[io].x_index == GetXindx(Blue_Skeleton.getPosition().x) && bombs[io].y_index + g == GetYindx(Blue_Skeleton.getPosition().y) && bombs[io].flag_range_down)
  3942.                     {
  3943.                         Blue_Skeleton_death = 1;
  3944.                         Blue_Skeleton.setFillColor(Color::Transparent);
  3945.                     }
  3946.  
  3947.                 }
  3948.  
  3949.             }
  3950.         }
  3951.  
  3952.         //############################################################################################
  3953.  
  3954.         //############################################################################################//############################################################################################
  3955.  
  3956.         for (int i = 0; i < 13; i++) {
  3957.             int sumP = 0; int sumR = 0;
  3958.             sumP = GetXindx(player.getPosition().x) + GetYindx(player.getPosition().y);
  3959.             sumR = GetXindx(SuperPowers[i].getPosition().x) + GetYindx(SuperPowers[i].getPosition().y);
  3960.  
  3961.             if (sumR == sumP + 1 && (GetXindx(SuperPowers[i].getPosition().x) == GetXindx(player.getPosition().x))
  3962.                 && !visted[GetXindx(SuperPowers[i].getPosition().x)][GetYindx(SuperPowers[i].getPosition().y)])
  3963.             {
  3964.  
  3965.                 visted[GetXindx(SuperPowers[i].getPosition().x)][GetYindx(SuperPowers[i].getPosition().y)] = 1;
  3966.  
  3967.                 if (SuperPowers[i].getTexture() == &rangeskill) {
  3968.  
  3969.  
  3970.                     temp_range_of_bomb++;
  3971.                     SuperPowers[i].setColor(Color::Transparent);
  3972.                     ss = to_string(temp_range_of_bomb);
  3973.  
  3974.                 }
  3975.                 else if (SuperPowers[i].getTexture() == &bombskill) {
  3976.                     boombs++;
  3977.                     SuperPowers[i].setColor(Color::Transparent);
  3978.                     sss = to_string(boombs);
  3979.  
  3980.  
  3981.                 }
  3982.                 else if (SuperPowers[i].getTexture() == &healskill) {
  3983.                     lives++;
  3984.                     SuperPowers[i].setColor(Color::Transparent);
  3985.                     ssl = to_string(lives);
  3986.                 }
  3987.             }
  3988.  
  3989.         }
  3990.  
  3991.  
  3992.  
  3993.         bool isbombing = 0;
  3994.         for (int io = 0; io < bombs.size(); io++)
  3995.         {
  3996.             if (bombs[io].bomb_exploded) { isbombing = 1; break; }
  3997.         }
  3998.         if (!isbombing)
  3999.         {
  4000.             range_of_bomb = temp_range_of_bomb;
  4001.         }
  4002.         //############################################################################################
  4003.         // player damage
  4004.         if (GetXindx(player.getPosition().x) == GetXindx(White_Robot.getPosition().x) && GetYindx(player.getPosition().y) == GetYindx(White_Robot.getPosition().y) && !White_Robot_death)
  4005.         {
  4006.             if (Clock_Damgae.getElapsedTime().asSeconds() >= 1) {
  4007.                 lives--;
  4008.                 Clock_Damgae.restart();
  4009.             }
  4010.             Level_3.draw(Hurt);
  4011.  
  4012.         }
  4013.  
  4014.         if (GetXindx(player.getPosition().x) == GetXindx(Skeleton.getPosition().x) && GetYindx(player.getPosition().y) == GetYindx(Skeleton.getPosition().y) && !Skeleton_death)
  4015.         {
  4016.             if (Clock_Damgae.getElapsedTime().asSeconds() >= 1) {
  4017.                 lives--;
  4018.                 Clock_Damgae.restart();
  4019.             }
  4020.             Level_3.draw(Hurt);
  4021.         }
  4022.  
  4023.         if (GetXindx(player.getPosition().x) == GetXindx(Blue_Skeleton.getPosition().x) && GetYindx(player.getPosition().y) == GetYindx(Blue_Skeleton.getPosition().y) && !Blue_Skeleton_death)
  4024.         {
  4025.             if (Clock_Damgae.getElapsedTime().asSeconds() >= 1) {
  4026.                 lives--;
  4027.                 Clock_Damgae.restart();
  4028.             }
  4029.             Level_3.draw(Hurt);
  4030.         }
  4031.  
  4032.         if (GetXindx(player.getPosition().x) == GetXindx(Red_Robot.getPosition().x) && GetYindx(player.getPosition().y) == GetYindx(Red_Robot.getPosition().y) && !Red_Robot_death)
  4033.         {
  4034.             if (Clock_Damgae.getElapsedTime().asSeconds() >= 1) {
  4035.                 lives--;
  4036.                 Clock_Damgae.restart();
  4037.             }
  4038.             Level_3.draw(Hurt);
  4039.         }
  4040.  
  4041.         cout << player_status.lives << endl;
  4042.         Level_3.draw(nooflives);
  4043.         Level_3.draw(noofbombs);
  4044.         Level_3.draw(noofranges);
  4045.         Level_3.draw(lifeS);
  4046.         Level_3.draw(rangeS);
  4047.         Level_3.draw(bombS);
  4048.         Level_3.draw(txt); // بيترسم تحت
  4049.         if (lives < 1) {
  4050.             ingame.stop();
  4051.             player.setFillColor(Color::Transparent);
  4052.             Tomb.setPosition(player.getPosition().x, player.getPosition().y);
  4053.             Level_3.draw(Tomb);
  4054.             --elapsed;
  4055.             if (elapsed <= 50 + 500) {
  4056.                 if (playsong) {
  4057.                     lost.play();
  4058.                     playsong = 0;
  4059.                 }
  4060.                 if (elapsed <= -500) {
  4061.                     Level_3.clear(Color::Black), Level_3.draw(RIP_Photo);
  4062.                     exit(0);
  4063.                 }
  4064.             }
  4065.         }
  4066.  
  4067.         if (Die) {
  4068.             ingame.stop();
  4069.             Level_3.clear(Color::Black), Level_3.draw(big_exp), Level_3.draw(RIP_Photo);
  4070.             --elapsed;
  4071.             if (elapsed <= 1) {
  4072.                 exit(0);
  4073.             }
  4074.         }
  4075.  
  4076.         if (Player_xindx == 16 && Player_yindx == 3) {
  4077.             ingame.stop();
  4078.             Level_3.clear(Color::Black), Level_3.draw(Level_complete);
  4079.             --elapsed;
  4080.             if (elapsed <= 1) {
  4081.                 exit(0);
  4082.             }
  4083.         }
  4084.         Level_3.display();
  4085.  
  4086.  
  4087.  
  4088.     }
  4089.  
  4090. }
  4091.  
  4092. void Multiplayer()
  4093. {
  4094.  
  4095.     Font dis_time;
  4096.     if (!dis_time.loadFromFile("Chocolate Bar Demo.otf"))
  4097.     {
  4098.         cout << "error font";
  4099.     }
  4100.     //timer stuff
  4101.     int display_timer;
  4102.     Clock c, timer_clock;
  4103.     Time times, timer;
  4104.     //map stuff
  4105.     Texture wall, ground, wallpaper, ground2, breakable, zone_warning_text, hurt, tomb;
  4106.     Texture death;
  4107.     Sprite Death;
  4108.     if (!death.loadFromFile("death.png"))
  4109.         cout << "error to load death " << endl;
  4110.  
  4111.     if (!tomb.loadFromFile("RIP.png"))
  4112.         cout << "error to load death " << endl;
  4113.  
  4114.  
  4115.  
  4116.     Death.setTexture(death);
  4117.     Death.setScale(0.3, 0.3);
  4118.     // songs load
  4119.     Music ingame; ingame.openFromFile("ingame.wav");
  4120.     ingame.play();
  4121.     ingame.setLoop(1);
  4122.  
  4123.     // zone stuff
  4124.     Sprite zone_warning_sprt, Hurt;
  4125.     if (!zone_warning_text.loadFromFile("zone.png")) {
  4126.         cout << "error to load zone " << endl;
  4127.     }
  4128.     zone_warning_sprt.setTexture(zone_warning_text);
  4129.     zone_warning_sprt.setScale(0.5, 0.5);
  4130.     zone_warning_sprt.setPosition(440, 520);
  4131.     int zone_limit = 1;
  4132.     if (!breakable.loadFromFile("breakable.png")) {
  4133.         cout << "error to load breakable " << endl;
  4134.     }
  4135.     if (!hurt.loadFromFile("hurt.png")) {
  4136.         cout << "error to load breakable " << endl;
  4137.     }
  4138.     Hurt.setTexture(hurt);
  4139.     if (!wallpaper.loadFromFile("wallpaper.jpg")) {
  4140.         cout << "error to load wallpaper " << endl;
  4141.     }
  4142.  
  4143.     if (!wall.loadFromFile("3d wall.png")) {
  4144.         cout << "error to load 3d wall " << endl;
  4145.     }
  4146.     if (!ground.loadFromFile("ground 1.png")) {
  4147.         cout << "error to load ground " << endl;
  4148.     }
  4149.  
  4150.  
  4151.  
  4152.  
  4153.     if (!ground2.loadFromFile("grass.png")) {
  4154.         cout << "error to load grass " << endl;
  4155.     }
  4156.  
  4157.  
  4158.     Sprite lifeS, rangeS, bombS, Wallpaper;
  4159.  
  4160.     Wallpaper.setTexture(wallpaper);
  4161.  
  4162.  
  4163.     // Distribution of wall & ground on the Grid
  4164.  
  4165.     const int length = 9, width = 17;
  4166.  
  4167.     Sprite Grid[width + 1][length + 1];
  4168.  
  4169.     for (int i = 1; i <= width; i++)
  4170.     {
  4171.         for (int j = 1; j <= length; j++)
  4172.         {
  4173.             if (i % 2 != 0 && j % 2 != 0)
  4174.             {
  4175.  
  4176.                 Grid[i][j].setTexture(wall);
  4177.                 Grid[i][j].setPosition((i + 1.97) * 53, (j + 0.255) * 48);
  4178.                 Grid[i][j].setScale(Vector2f(0.1009, 0.165));
  4179.  
  4180.             }
  4181.  
  4182.             else if (i == 1 || i == width)
  4183.             {
  4184.                 Grid[i][j].setTexture(wall);
  4185.                 Grid[i][j].setPosition((i + 1.97) * 53, (j + 0.255) * 48);
  4186.                 Grid[i][j].setScale(Vector2f(0.1009, 0.165));
  4187.             }
  4188.             else if (j == 1 || j == length)
  4189.             {
  4190.                 Grid[i][j].setTexture(wall);
  4191.                 Grid[i][j].setPosition((i + 1.97) * 53, (j + 0.255) * 48);
  4192.                 Grid[i][j].setScale(Vector2f(0.1009, 0.165));
  4193.             }
  4194.             else
  4195.             {
  4196.                 if (i % 2 == j % 2)
  4197.                 {
  4198.                     Grid[i][j].setTexture(ground);
  4199.                 }
  4200.                 else
  4201.                 {
  4202.                     Grid[i][j].setTexture(ground2);
  4203.                 }
  4204.                 Grid[i][j].setPosition((i + 2) * 53, (j + 0.8) * 48);
  4205.                 Grid[i][j].setScale(0.1009, 0.101);
  4206.             }
  4207.         }
  4208.     }
  4209.     for (int i = 1; i <= 30; i++)
  4210.     {
  4211.         int x = rand() % 14 + 2, y = rand() % 7 + 2;
  4212.         if (x % 2 != 0 && y % 2 != 0)
  4213.         {
  4214.             x++;
  4215.         }
  4216.         Grid[x][y].setTexture(breakable);
  4217.         Grid[x][y].setPosition((x + 1.97) * 53, (y + 0.255) * 48);
  4218.         Grid[x][y].setScale(Vector2f(0.1009, 0.165));
  4219.     }
  4220.  
  4221.     // player 1 creation
  4222.     const int players_speed = 1;
  4223.     //###############################################################################
  4224.     // Making of Player1
  4225.     RectangleShape player1(Vector2f(90, 110));
  4226.     Sprite dead;
  4227.     dead.setScale(0.1, 0.1);
  4228.     dead.setTexture(tomb);
  4229.     Texture player1_texture;
  4230.     Vector2u player1_size;
  4231.     Clock player1_clock;
  4232.     Time player1_time;
  4233.     float player1_position = 0;
  4234.     Generate_Charcter(player1, player1_texture, player1_size, "mainplayer.png", 10, 2);
  4235.  
  4236.     //###############################################################################
  4237.   // Making of Player2
  4238.     RectangleShape player2(Vector2f(90, 110));
  4239.     Texture player2_texture;
  4240.     Vector2u player2_size;
  4241.     Clock player2_clock;
  4242.     Time player2_time;
  4243.     float player2_position = 0;
  4244.     Generate_Charcter(player2, player2_texture, player2_size, "mage walking poses sheet copyRR.png", 2, 2);
  4245.  
  4246.  
  4247.     //###############################################################################
  4248.    // Movement stuff
  4249.     leftmovement left; rightmovement right; upmovement up; downmovement down;
  4250.     int player1_xindx = 0, player1_yindx = 0, player2_xindx = 0, player2_yindx = 0;
  4251.     //###############################################################################
  4252.  
  4253.  
  4254.  
  4255.     //bomb stuff
  4256.     Texture bombtext, exptext;
  4257.     bombtext.loadFromFile("BOOM.png");
  4258.     exptext.loadFromFile("exp.png");
  4259.     Sprite exp;
  4260.     exp.setTexture(exptext);
  4261.     exp.setScale(0.25, 0.25);
  4262.     bomb bomb_template;
  4263.     bomb_template.sprt.setTexture(bombtext);
  4264.     bomb_template.sprt.setScale(0.15f, 0.15f);
  4265.     vector<bomb>bombs;
  4266.  
  4267.     Vector2u text_size_bomb = bombtext.getSize();
  4268.     Vector2u text_size_exp = exptext.getSize();
  4269.     text_size_bomb.y /= 4;
  4270.     text_size_exp.x /= 3;
  4271.     text_size_exp.y /= 3;
  4272.     int range_of_bomb = 3;
  4273.  
  4274.  
  4275.  
  4276.     Sprite P1_wins, P2_wins, P_Draw;
  4277.     Texture P1_wins_txt, P2_wins_txt, P_draw_txt;
  4278.     P1_wins_txt.loadFromFile("player 1 wins.png");
  4279.     P2_wins_txt.loadFromFile("player 2 wins.png");
  4280.     P_draw_txt.loadFromFile("Draw.png");
  4281.     P1_wins.setTexture(P1_wins_txt);
  4282.     P2_wins.setTexture(P2_wins_txt);
  4283.     P_Draw.setTexture(P_draw_txt);
  4284.  
  4285.  
  4286.     Time music_time;
  4287.     Clock music_clock;
  4288.  
  4289.     int death_music_duration = 0;
  4290.  
  4291.     bool player1_wins_flag = 0, player2_wins_flag = 0;
  4292.  
  4293.     int bomb_placement_timer_1 = 0, bomb_placement_timer_2 = 0;
  4294.  
  4295.     //Game Window
  4296.     RenderWindow window(VideoMode(1280, 768), "Fcis In Danger");
  4297.     while (window.isOpen())
  4298.     {
  4299.  
  4300.  
  4301.  
  4302.         Event event;
  4303.         while (window.pollEvent(event))
  4304.         {
  4305.             if (event.type == sf::Event::Closed)
  4306.                 window.close();
  4307.         }
  4308.  
  4309.  
  4310.  
  4311.  
  4312.  
  4313.         music_time = music_clock.getElapsedTime();
  4314.         death_music_duration = music_time.asSeconds();
  4315.  
  4316.  
  4317.  
  4318.  
  4319.         // Timer
  4320.         Text txt;
  4321.         timer = timer_clock.getElapsedTime();
  4322.         display_timer = timer.asSeconds();
  4323.         string s1, s2;
  4324.         //int  minu=display_timer/60;
  4325.         s1 = to_string(30 - (display_timer));
  4326.         //s2=to_string(1-minu);
  4327.         //s2+=" : ";
  4328.         //s2+=s1;
  4329.  
  4330.         txt.setFont(dis_time);
  4331.         txt.setString("0:" + s1);
  4332.         txt.setPosition(512, 22);
  4333.  
  4334.  
  4335.         if (display_timer >= 30)
  4336.         {
  4337.             timer_clock.restart();
  4338.  
  4339.  
  4340.             for (int j = 2; j < length; j++)
  4341.             {
  4342.                 Grid[zone_limit + 1][j].setTexture(wall);
  4343.  
  4344.                 Grid[width - zone_limit][j].setTexture(wall);
  4345.  
  4346.                 Grid[zone_limit + 1][j].setPosition((zone_limit + 1 + 1.97) * 53, (j + 0.255) * 48);
  4347.  
  4348.                 if ((GetXindx(player1.getPosition().x)) == zone_limit + 1) {
  4349.                     dead.setPosition(player1.getPosition().x, player1.getPosition().y);
  4350.                     player2_wins_flag = 1;
  4351.                     music_clock.restart();
  4352.                     ingame.stop();
  4353.  
  4354.                 }
  4355.  
  4356.                 if ((GetXindx(player2.getPosition().x)) == zone_limit + 1) {
  4357.                     dead.setPosition(player2.getPosition().x, player2.getPosition().y);
  4358.                     player1_wins_flag = 1;
  4359.                     music_clock.restart();
  4360.                     ingame.stop();
  4361.                 }
  4362.  
  4363.                 Grid[width - zone_limit][j].setPosition((width - zone_limit + 1.97) * 53, (j + 0.255) * 48);
  4364.  
  4365.                 Grid[zone_limit + 1][j].setScale(Vector2f(0.1009, 0.165));
  4366.  
  4367.                 Grid[width - zone_limit][j].setScale(Vector2f(0.1009, 0.165));
  4368.  
  4369.  
  4370.  
  4371.                 if ((GetXindx(player1.getPosition().x)) == width - zone_limit) {
  4372.                     dead.setPosition(player1.getPosition().x, player1.getPosition().y);
  4373.                     player2_wins_flag = 1;
  4374.                     music_clock.restart();
  4375.                     ingame.stop();
  4376.  
  4377.                 }
  4378.  
  4379.                 if ((GetXindx(player2.getPosition().x)) == width - zone_limit) {
  4380.                     dead.setPosition(player2.getPosition().x, player2.getPosition().y);
  4381.                     player1_wins_flag = 1;
  4382.                     music_clock.restart();
  4383.                     ingame.stop();
  4384.  
  4385.                 }
  4386.  
  4387.  
  4388.  
  4389.  
  4390.  
  4391.  
  4392.             }
  4393.             zone_limit++;
  4394.         }
  4395.  
  4396.  
  4397.  
  4398.  
  4399.  
  4400.  
  4401.         // player1 1 Movement
  4402.         player1_xindx = (float)((float)(player1.getPosition().x - 183) / 53 + 2);
  4403.         player1_yindx = (float)((float)(player1.getPosition().y - 74) / 48 + 2);
  4404.         right.i = GetXindx(player1.getPosition().x + 20); right.j = player1_yindx;
  4405.         left.i = GetXindx(player1.getPosition().x - 20); left.j = player1_yindx;
  4406.         up.i = player1_xindx; up.j = GetYindx(player1.getPosition().y - 7);
  4407.         down.i = player1_xindx; down.j = GetYindx(player1.getPosition().y + 7);
  4408.  
  4409.         Vector2i movejoy1(Joystick::getAxisPosition(0, Joystick::X), Joystick::getAxisPosition(0, Joystick::Y));
  4410.         if ((Keyboard::isKeyPressed(Keyboard::Key::Right) || movejoy1.x > 0) && (Grid[right.i][right.j].getTexture() == &ground || Grid[right.i][right.j].getTexture() == &ground2))      // Moving Right
  4411.         {
  4412.             bool check_bomb = 0;
  4413.             for (int io = 0; io < bombs.size(); io++)
  4414.             {
  4415.                 if (bombs[io].x_index == GetXindx(player1.getPosition().x + 1) && bombs[io].x_index != GetXindx(player1.getPosition().x) && bombs[io].y_index == right.j)
  4416.                 {
  4417.                     check_bomb = 1; break;
  4418.                 }
  4419.             }
  4420.             if (!check_bomb)
  4421.                 Movement_Right(player1, player1_time, player1_clock, player1_position, player1_size, players_speed);
  4422.         }
  4423.         else if ((Keyboard::isKeyPressed(Keyboard::Key::Left) || movejoy1.x < 0) && (Grid[left.i][left.j].getTexture() == &ground || Grid[left.i][left.j].getTexture() == &ground2))         // Moving Left
  4424.         {
  4425.             bool check_bomb = 0;
  4426.             for (int io = 0; io < bombs.size(); io++)
  4427.             {
  4428.                 if (bombs[io].x_index == GetXindx(player1.getPosition().x - 1) && bombs[io].x_index != GetXindx(player1.getPosition().x) && bombs[io].y_index == left.j)
  4429.                 {
  4430.                     check_bomb = 1; break;
  4431.                 }
  4432.             }
  4433.             if (!check_bomb)
  4434.  
  4435.                 Movement_Left(player1, player1_time, player1_clock, player1_position, player1_size, players_speed);
  4436.         }
  4437.         else if ((Keyboard::isKeyPressed(Keyboard::Key::Up) || movejoy1.y < 0) && (Grid[GetXindx(player1.getPosition().x + 25)][up.j].getTexture() == &ground || Grid[up.i][up.j].getTexture() == &ground2))           // Moving Up
  4438.         {
  4439.             bool check_bomb = 0;
  4440.             for (int io = 0; io < bombs.size(); io++)
  4441.             {
  4442.                 if (bombs[io].y_index == GetYindx(player1.getPosition().y - 1) && bombs[io].y_index != GetYindx(player1.getPosition().y) && bombs[io].x_index == up.i)
  4443.                 {
  4444.                     check_bomb = 1; break;
  4445.                 }
  4446.             }
  4447.             if (!check_bomb)
  4448.  
  4449.  
  4450.                 Movement_Upward(player1, player1_time, player1_clock, player1_position, player1_size, players_speed);
  4451.         }
  4452.         else if ((Keyboard::isKeyPressed(Keyboard::Key::Down) || movejoy1.y > 0) && (Grid[GetXindx(player1.getPosition().x + 25)][down.j].getTexture() == &ground || Grid[down.i][down.j].getTexture() == &ground2))         // Moving Down
  4453.         {
  4454.             bool check_bomb = 0;
  4455.             for (int io = 0; io < bombs.size(); io++)
  4456.             {
  4457.                 if (bombs[io].y_index == GetYindx(player1.getPosition().y + 1) && bombs[io].y_index != GetYindx(player1.getPosition().y) && bombs[io].x_index == up.i)
  4458.                 {
  4459.                     check_bomb = 1; break;
  4460.                 }
  4461.             }
  4462.             if (!check_bomb)
  4463.  
  4464.                 Movement_Downward(player1, player1_time, player1_clock, player1_position, player1_size, players_speed);
  4465.         }
  4466.         if ((Keyboard::isKeyPressed(Keyboard::Key::Enter) || Joystick::isButtonPressed(0, 2)) && bomb_placement_timer_1 >= 80) {
  4467.             bombs.push_back(bomb_template);
  4468.             bombs[bombs.size() - 1].bomb_clock.restart();
  4469.             bombs[bombs.size() - 1].explosion_clock.restart();
  4470.             bombs[bombs.size() - 1].start_clock.restart();
  4471.             bombs[bombs.size() - 1].bomb_placed = 1;
  4472.             bombs[bombs.size() - 1].x_pos = GetXpostion(player1_xindx) + 12;
  4473.             bombs[bombs.size() - 1].y_pos = GetYpostion(player1_yindx) + 12;
  4474.             bombs[bombs.size() - 1].x_index = GetXindx(bombs[bombs.size() - 1].x_pos);
  4475.             bombs[bombs.size() - 1].y_index = GetYindx(bombs[bombs.size() - 1].y_pos);
  4476.             bombs[bombs.size() - 1].sprt.setPosition(bombs[bombs.size() - 1].x_pos, bombs[bombs.size() - 1].y_pos);
  4477.             bombs[bombs.size() - 1].sprt.setTextureRect(IntRect(0, text_size_bomb.y * bombs[bombs.size() - 1].bomb_animation_y, text_size_bomb.x, text_size_bomb.y));
  4478.             bomb_placement_timer_1 = 0;
  4479.         }
  4480.  
  4481.         if (bomb_placement_timer_1 < 80) { bomb_placement_timer_1++; }
  4482.         if (bomb_placement_timer_2 < 80) { bomb_placement_timer_2++; }
  4483.  
  4484.  
  4485.  
  4486.  
  4487.  
  4488.  
  4489.         // Player 2 Movement
  4490.         player2_xindx = (float)((float)(player2.getPosition().x - 183) / 53 + 2);
  4491.         player2_yindx = (float)((float)(player2.getPosition().y - 74) / 48 + 2);
  4492.         right.i = GetXindx(player2.getPosition().x + 20); right.j = player2_yindx;
  4493.         left.i = GetXindx(player2.getPosition().x - 20); left.j = player2_yindx;
  4494.         up.i = player2_xindx; up.j = GetYindx(player2.getPosition().y - 7);
  4495.         down.i = player2_xindx; down.j = GetYindx(player2.getPosition().y + 7);
  4496.         Vector2i movejoy2(Joystick::getAxisPosition(1, Joystick::X), Joystick::getAxisPosition(1, Joystick::Y));
  4497.  
  4498.         if ((Keyboard::isKeyPressed(Keyboard::Key::D) || movejoy2.x > 0) && (Grid[right.i][right.j].getTexture() == &ground || Grid[right.i][right.j].getTexture() == &ground2))      // Moving Right
  4499.         {
  4500.             bool check_bomb = 0;
  4501.             for (int io = 0; io < bombs.size(); io++)
  4502.             {
  4503.                 if (bombs[io].x_index == GetXindx(player2.getPosition().x + 1) && bombs[io].x_index != GetXindx(player2.getPosition().x) && bombs[io].y_index == GetYindx(player2.getPosition().y))
  4504.                 {
  4505.                     check_bomb = 1; break;
  4506.                 }
  4507.             }
  4508.             if (!check_bomb)
  4509.  
  4510.                 Movement_Right(player2, player2_time, player2_clock, player2_position, player2_size, players_speed);
  4511.         }
  4512.         else if ((Keyboard::isKeyPressed(Keyboard::Key::A) || movejoy2.x < 0) && (Grid[left.i][left.j].getTexture() == &ground || Grid[left.i][left.j].getTexture() == &ground2))         // Moving Left
  4513.         {
  4514.             bool check_bomb = 0;
  4515.             for (int io = 0; io < bombs.size(); io++)
  4516.             {
  4517.                 if (bombs[io].x_index == GetXindx(player2.getPosition().x - 1) && bombs[io].x_index != GetXindx(player2.getPosition().x) && bombs[io].y_index == GetYindx(player2.getPosition().y))
  4518.                 {
  4519.                     check_bomb = 1; break;
  4520.                 }
  4521.             }
  4522.             if (!check_bomb)
  4523.  
  4524.  
  4525.                 Movement_Left(player2, player2_time, player2_clock, player2_position, player2_size, players_speed);
  4526.         }
  4527.         else if ((Keyboard::isKeyPressed(Keyboard::Key::W) || movejoy2.y < 0) && (Grid[GetXindx(player2.getPosition().x + 25)][up.j].getTexture() == &ground || Grid[up.i][up.j].getTexture() == &ground2))           // Moving Up
  4528.         {
  4529.  
  4530.             bool check_bomb = 0;
  4531.             for (int io = 0; io < bombs.size(); io++)
  4532.             {
  4533.                 if (bombs[io].y_index == GetYindx(player2.getPosition().y - 1) && bombs[io].y_index != GetYindx(player2.getPosition().y) && bombs[io].x_index == GetXindx(player2.getPosition().x))
  4534.                 {
  4535.                     check_bomb = 1; break;
  4536.                 }
  4537.             }
  4538.             if (!check_bomb)
  4539.  
  4540.                 Movement_Upward(player2, player2_time, player2_clock, player2_position, player2_size, players_speed);
  4541.         }
  4542.         else if ((Keyboard::isKeyPressed(Keyboard::Key::S) || movejoy2.y > 0) && (Grid[GetXindx(player2.getPosition().x + 25)][down.j].getTexture() == &ground || Grid[down.i][down.j].getTexture() == &ground2))         // Moving Down
  4543.         {
  4544.  
  4545.  
  4546.             bool check_bomb = 0;
  4547.             for (int io = 0; io < bombs.size(); io++)
  4548.             {
  4549.                 if (bombs[io].y_index == GetYindx(player2.getPosition().y + 1) && bombs[io].y_index != GetYindx(player2.getPosition().y) && bombs[io].x_index == GetXindx(player2.getPosition().x))
  4550.                 {
  4551.                     check_bomb = 1; break;
  4552.                 }
  4553.             }
  4554.             if (!check_bomb)
  4555.  
  4556.  
  4557.                 Movement_Downward(player2, player2_time, player2_clock, player2_position, player2_size, players_speed);
  4558.         }
  4559.         else if ((Keyboard::isKeyPressed(Keyboard::Key::Space) || Joystick::isButtonPressed(1, 2)) && bomb_placement_timer_2 >= 80) {
  4560.             bombs.push_back(bomb_template);
  4561.             bombs[bombs.size() - 1].bomb_clock.restart();
  4562.             bombs[bombs.size() - 1].explosion_clock.restart();
  4563.             bombs[bombs.size() - 1].start_clock.restart();
  4564.             bombs[bombs.size() - 1].bomb_placed = 1;
  4565.             bombs[bombs.size() - 1].x_pos = GetXpostion(player2_xindx) + 12;
  4566.             bombs[bombs.size() - 1].y_pos = GetYpostion(player2_yindx) + 12;
  4567.             bombs[bombs.size() - 1].x_index = GetXindx(bombs[bombs.size() - 1].x_pos);
  4568.             bombs[bombs.size() - 1].y_index = GetYindx(bombs[bombs.size() - 1].y_pos);
  4569.             bombs[bombs.size() - 1].y_index = GetYindx(bombs[bombs.size() - 1].y_pos);
  4570.  
  4571.             bombs[bombs.size() - 1].sprt.setPosition(bombs[bombs.size() - 1].x_pos, bombs[bombs.size() - 1].y_pos);
  4572.  
  4573.             bombs[bombs.size() - 1].sprt.setTextureRect(IntRect(0, text_size_bomb.y * bombs[bombs.size() - 1].bomb_animation_y, text_size_bomb.x, text_size_bomb.y));
  4574.  
  4575.             bomb_placement_timer_2 = 0;
  4576.         }
  4577.  
  4578.  
  4579.  
  4580.  
  4581.         for (int io = 0; io < bombs.size(); io++)
  4582.         {
  4583.  
  4584.             if (bombs[io].bomb_placed == 1) {
  4585.                 bombs[io].bomb_time = bombs[io].bomb_clock.getElapsedTime();
  4586.                 bombs[io].start_explosion = bombs[io].start_clock.getElapsedTime();
  4587.                 if (bombs[io].bomb_time.asSeconds() >= 0.2) {
  4588.                     bombs[io].bomb_clock.restart();
  4589.                     bombs[io].sprt.setPosition(bombs[io].x_pos, bombs[io].y_pos + 25);
  4590.                     bombs[io].sprt.setTextureRect(IntRect(0, text_size_bomb.y * bombs[io].bomb_animation_y, text_size_bomb.x, text_size_bomb.y));
  4591.                     bombs[io].bomb_animation_y += 2;
  4592.                     if (bombs[io].bomb_animation_y > 2)
  4593.                         bombs[io].bomb_animation_y = 0;
  4594.                 }
  4595.                 if (bombs[io].start_explosion.asSeconds() >= 3) {
  4596.                     bombs[io].bomb_exploded = 1;
  4597.                     bombs[io].bomb_placed = 0;
  4598.  
  4599.                     for (int k = 0; k <= range_of_bomb; k++)
  4600.                     {
  4601.                         bombs[io].range_right.push_back(exp);
  4602.                         bombs[io].range_left.push_back(exp);
  4603.                         bombs[io].range_up.push_back(exp);
  4604.                         bombs[io].range_down.push_back(exp);
  4605.  
  4606.                     }
  4607.                 }
  4608.             }
  4609.  
  4610.             if (bombs[io].bomb_exploded) {
  4611.                 bombs[io].explosion_time = bombs[io].explosion_clock.getElapsedTime();
  4612.                 if (bombs[io].explosion_time.asSeconds() >= 0.08) {
  4613.                     bombs[io].explosion_clock.restart();
  4614.                     for (int n = 0, k = 0; k <= range_of_bomb, n <= range_of_bomb * 50; k++, n += 50)
  4615.                         bombs[io].range_right[k].setPosition(bombs[io].x_pos + n, bombs[io].y_pos);
  4616.  
  4617.                     for (int n = 0, k = 0; k <= range_of_bomb, n <= range_of_bomb * 50; k++, n += 50)
  4618.                         bombs[io].range_right[k].setTextureRect(IntRect(text_size_exp.x * bombs[io].exp_animation_x, text_size_exp.y * bombs[io].exp_animation_y, text_size_exp.x, text_size_exp.y));
  4619.  
  4620.                     for (int n = 0, k = 0; k <= range_of_bomb, n <= range_of_bomb * 50; k++, n += 50)
  4621.                         bombs[io].range_left[k].setPosition(bombs[io].x_pos - n, bombs[io].y_pos);
  4622.  
  4623.                     for (int n = 0, k = 0; k <= range_of_bomb, n <= range_of_bomb * 50; k++, n += 50)
  4624.                         bombs[io].range_left[k].setTextureRect(IntRect(text_size_exp.x * bombs[io].exp_animation_x, text_size_exp.y * bombs[io].exp_animation_y, text_size_exp.x, text_size_exp.y));
  4625.  
  4626.                     for (int n = 0, k = 0; k <= range_of_bomb, n <= range_of_bomb * 50; k++, n += 50)
  4627.                         bombs[io].range_up[k].setPosition(bombs[io].x_pos, bombs[io].y_pos - n);
  4628.  
  4629.                     for (int n = 0, k = 0; k <= range_of_bomb, n <= range_of_bomb * 50; k++, n += 50)
  4630.                         bombs[io].range_up[k].setTextureRect(IntRect(text_size_exp.x * bombs[io].exp_animation_x, text_size_exp.y * bombs[io].exp_animation_y, text_size_exp.x, text_size_exp.y));
  4631.  
  4632.                     for (int n = 0, k = 0; k <= range_of_bomb, n <= range_of_bomb * 50; k++, n += 50)
  4633.                         bombs[io].range_down[k].setPosition(bombs[io].x_pos, bombs[io].y_pos + n);
  4634.  
  4635.                     for (int n = 0, k = 0; k <= range_of_bomb, n <= range_of_bomb * 50; k++, n += 50)
  4636.                         bombs[io].range_down[k].setTextureRect(IntRect(text_size_exp.x * bombs[io].exp_animation_x, text_size_exp.y * bombs[io].exp_animation_y, text_size_exp.x, text_size_exp.y));
  4637.  
  4638.  
  4639.                     bombs[io].exp_animation_x++;
  4640.                     if (bombs[io].exp_animation_x == 3) {
  4641.                         bombs[io].exp_animation_x = 0, bombs[io].exp_animation_y++;
  4642.                         if (bombs[io].exp_animation_y == 3) {
  4643.                             bombs[io].bomb_exploded = 0;
  4644.  
  4645.  
  4646.                             bombs.erase(bombs.begin());
  4647.  
  4648.                         }
  4649.                     }
  4650.                 }
  4651.             }
  4652.         }
  4653.  
  4654.  
  4655.  
  4656.  
  4657.         window.clear();
  4658.         // Drawing of the Wallpaper
  4659.         window.draw(Wallpaper);
  4660.  
  4661.         //Drawing of The Map
  4662.         for (int i = 2; i < width; i++)
  4663.         {
  4664.             for (int j = 2; j < length; j++)
  4665.             {
  4666.                 if (Grid[i][j].getTexture() == &ground || Grid[i][j].getTexture() == &ground2)
  4667.                 {
  4668.                     window.draw(Grid[i][j]);
  4669.                 }
  4670.             }
  4671.  
  4672.         }
  4673.  
  4674.         for (int j = 1; j <= length; j++)
  4675.         {
  4676.             for (int i = 1; i <= width; i++)
  4677.             {
  4678.                 if (Grid[i][j].getTexture() == &ground || Grid[i][j].getTexture() == &ground2)
  4679.                 {
  4680.                     continue;
  4681.                 }
  4682.  
  4683.                 window.draw(Grid[i][j]);
  4684.  
  4685.                 if (GetYindx(player1.getPosition().y) >= j)
  4686.                 {
  4687.                     window.draw(player1);
  4688.                 }
  4689.  
  4690.  
  4691.                 if (GetYindx(player2.getPosition().y) >= j)
  4692.                 {
  4693.                     window.draw(player2);
  4694.                 }
  4695.  
  4696.                 for (int io = 0; io < bombs.size(); io++)
  4697.                 {
  4698.                     if (bombs[io].bomb_placed && bombs[io].y_index > j)
  4699.                         window.draw(bombs[io].sprt);
  4700.                 }
  4701.  
  4702.             }
  4703.         }
  4704.  
  4705.         for (int io = 0; io < bombs.size(); io++)
  4706.         {
  4707.  
  4708.             if (bombs[io].bomb_exploded)
  4709.             {
  4710.                 //Right_Explosion
  4711.                 for (int g = 0; g <= range_of_bomb; g++)
  4712.                 {
  4713.  
  4714.  
  4715.                     if ((Grid[bombs[io].x_index + g][bombs[io].y_index].getTexture() == &breakable) && bombs[io].flag_range_right)
  4716.                     {
  4717.                         destroy_breakable_walls(bombs[io].x_index + g, bombs[io].y_index, Grid, ground, ground2);
  4718.                         bombs[io].flag_range_right = 0;
  4719.                         break;
  4720.                     }
  4721.                     else if (Grid[bombs[io].x_index + g][bombs[io].y_index].getTexture() == &wall)
  4722.                     {
  4723.  
  4724.                         bombs[io].flag_range_right = 0;
  4725.                         break;
  4726.                     }
  4727.  
  4728.                     if (bombs[io].x_index + g == player1_xindx && bombs[io].y_index == player1_yindx && bombs[io].flag_range_right)
  4729.                     {
  4730.                         player1.setFillColor(Color::Transparent);
  4731.                         dead.setPosition(player1.getPosition().x, player1.getPosition().y);
  4732.                         player2_wins_flag = 1;
  4733.                         music_clock.restart();
  4734.                         ingame.stop();
  4735.  
  4736.  
  4737.                     }
  4738.  
  4739.                     if (bombs[io].x_index + g == player2_xindx && bombs[io].y_index == player2_yindx && bombs[io].flag_range_right)
  4740.                     {
  4741.                         player2.setFillColor(Color::Transparent);
  4742.                         dead.setPosition(player2.getPosition().x, player2.getPosition().y);
  4743.                         player1_wins_flag = 1;
  4744.                         music_clock.restart();
  4745.                         ingame.stop();
  4746.                     }
  4747.  
  4748.                     window.draw(bombs[io].range_right[g]);
  4749.  
  4750.                 }
  4751.  
  4752.                 //Left_Explosion
  4753.                 for (int g = 0; g <= range_of_bomb; g++)
  4754.                 {
  4755.  
  4756.                     if ((Grid[bombs[io].x_index - g][bombs[io].y_index].getTexture() == &breakable) && bombs[io].flag_range_left)
  4757.                     {
  4758.                         destroy_breakable_walls(bombs[io].x_index - g, bombs[io].y_index, Grid, ground, ground2);
  4759.  
  4760.                         bombs[io].flag_range_left = 0;
  4761.                         break;
  4762.                     }
  4763.                     else if (Grid[bombs[io].x_index - g][bombs[io].y_index].getTexture() == &wall)
  4764.                     {
  4765.                         bombs[io].flag_range_left = 0;
  4766.                         break;
  4767.                     }
  4768.  
  4769.                     if (bombs[io].x_index - g == player1_xindx && bombs[io].y_index == player1_yindx && bombs[io].flag_range_left)
  4770.                     {
  4771.                         player1.setFillColor(Color::Transparent);
  4772.                         dead.setPosition(player1.getPosition().x, player1.getPosition().y);
  4773.  
  4774.                         player2_wins_flag = 1;
  4775.                         music_clock.restart();
  4776.                         ingame.stop();
  4777.  
  4778.                     }
  4779.  
  4780.                     if (bombs[io].x_index - g == player2_xindx && bombs[io].y_index == player2_yindx && bombs[io].flag_range_left)
  4781.                     {
  4782.  
  4783.                         player2.setFillColor(Color::Transparent);
  4784.                         dead.setPosition(player2.getPosition().x, player2.getPosition().y);
  4785.  
  4786.                         player1_wins_flag = 1;
  4787.                         music_clock.restart();
  4788.                         ingame.stop();
  4789.  
  4790.                     }
  4791.                     window.draw(bombs[io].range_left[g]);
  4792.  
  4793.  
  4794.  
  4795.                 }
  4796.  
  4797.                 //UP_Explosion
  4798.  
  4799.                 for (int g = 0; g <= range_of_bomb; g++)
  4800.                 {
  4801.  
  4802.  
  4803.                     if ((Grid[bombs[io].x_index][bombs[io].y_index - g].getTexture() == &breakable) && bombs[io].flag_range_up)
  4804.                     {
  4805.  
  4806.  
  4807.                         destroy_breakable_walls(bombs[io].x_index, bombs[io].y_index - g, Grid, ground, ground2);
  4808.  
  4809.                         bombs[io].flag_range_up = 0;
  4810.                         break;
  4811.  
  4812.                     }
  4813.                     else if (Grid[bombs[io].x_index][bombs[io].y_index - g].getTexture() == &wall)
  4814.                     {
  4815.  
  4816.                         bombs[io].flag_range_up = 0;
  4817.                         break;
  4818.                     }
  4819.  
  4820.  
  4821.                     if (bombs[io].x_index == player1_xindx && bombs[io].y_index - g == player1_yindx && bombs[io].flag_range_up)
  4822.                     {
  4823.                         player1.setFillColor(Color::Transparent);
  4824.                         dead.setPosition(player1.getPosition().x, player1.getPosition().y);
  4825.                         player2_wins_flag = 1;
  4826.                         music_clock.restart();
  4827.                         ingame.stop();
  4828.                     }
  4829.  
  4830.                     if (bombs[io].x_index == player2_xindx && bombs[io].y_index - g == player2_yindx && bombs[io].flag_range_up)
  4831.                     {
  4832.                         player2.setFillColor(Color::Transparent);
  4833.                         dead.setPosition(player2.getPosition().x, player2.getPosition().y);
  4834.                         player1_wins_flag = 1;
  4835.                         music_clock.restart();
  4836.                         ingame.stop();
  4837.                     }
  4838.  
  4839.                     window.draw(bombs[io].range_up[g]);
  4840.                 }
  4841.  
  4842.  
  4843.                 //Down_Explosion
  4844.  
  4845.                 for (int g = 0; g <= range_of_bomb; g++)
  4846.                 {
  4847.  
  4848.                     if ((Grid[bombs[io].x_index][bombs[io].y_index + g].getTexture() == &breakable) && bombs[io].flag_range_down)
  4849.                     {
  4850.                         destroy_breakable_walls(bombs[io].x_index, bombs[io].y_index + g, Grid, ground, ground2);
  4851.                         bombs[io].flag_range_down = 0;
  4852.                         break;
  4853.                     }
  4854.                     else if (Grid[bombs[io].x_index][bombs[io].y_index + g].getTexture() == &wall)
  4855.                     {
  4856.  
  4857.                         bombs[io].flag_range_down = 0;
  4858.                         break;
  4859.                     }
  4860.                     if (bombs[io].x_index == player1_xindx && bombs[io].y_index + g == player1_yindx && bombs[io].flag_range_down)
  4861.                     {
  4862.                         player1.setFillColor(Color::Transparent);
  4863.                         dead.setPosition(player1.getPosition().x, player1.getPosition().y);
  4864.  
  4865.                         player2_wins_flag = 1;
  4866.                         music_clock.restart();
  4867.                         ingame.stop();
  4868.                     }
  4869.  
  4870.                     if (bombs[io].x_index == player2_xindx && bombs[io].y_index + g == player2_yindx && bombs[io].flag_range_down)
  4871.                     {
  4872.                         player2.setFillColor(Color::Transparent);
  4873.                         dead.setPosition(player2.getPosition().x, player2.getPosition().y);
  4874.                         player1_wins_flag = 1;
  4875.                         music_clock.restart();
  4876.                         ingame.stop();
  4877.                     }
  4878.  
  4879.  
  4880.                     window.draw(bombs[io].range_down[g]);
  4881.                 }
  4882.             }
  4883.         }
  4884.  
  4885.  
  4886.  
  4887.  
  4888.         window.draw(txt);
  4889.         if (display_timer >= 25)
  4890.         {
  4891.             window.draw(zone_warning_sprt);
  4892.             window.draw(Hurt);
  4893.         }
  4894.         //window.draw(Death);
  4895.  
  4896.         if (death_music_duration <= 6)
  4897.         {
  4898.  
  4899.             if (player1_wins_flag && player2_wins_flag)
  4900.             {
  4901.  
  4902.                 if (death_music_duration >= 3)
  4903.                 {
  4904.                     window.clear();
  4905.                     window.draw(P_Draw);
  4906.                     if (death_music_duration == 5)
  4907.                     {
  4908.                         exit(0);
  4909.                     }
  4910.                 }
  4911.                 else
  4912.                 {
  4913.                     window.draw(dead);
  4914.                 }
  4915.             }
  4916.  
  4917.             else if (player1_wins_flag)
  4918.             {
  4919.  
  4920.                 if (death_music_duration >= 3)
  4921.                 {
  4922.                     window.clear();
  4923.                     window.draw(P1_wins);
  4924.                     if (death_music_duration == 4)
  4925.                     {
  4926.                         exit(0);
  4927.                     }
  4928.                 }
  4929.                 else
  4930.                 {
  4931.                     window.draw(dead);
  4932.                 }
  4933.             }
  4934.  
  4935.  
  4936.  
  4937.  
  4938.             else if (player2_wins_flag)
  4939.             {
  4940.                 if (death_music_duration >= 3)
  4941.                 {
  4942.                     window.clear();
  4943.                     window.draw(P2_wins);
  4944.                     if (death_music_duration == 4)
  4945.                     {
  4946.                         exit(0);
  4947.                     }
  4948.                 }
  4949.                 else
  4950.                 {
  4951.                     window.draw(dead);
  4952.                 }
  4953.             }
  4954.         }
  4955.         //if (death_flag && death_music_duration>16) {exit(0);}
  4956.         window.display();
  4957.  
  4958.     }
  4959.  
  4960.  
  4961.  
  4962. }
  4963.  
  4964.  
  4965.  
  4966. void levelsmenu(Music& outgame)
  4967. {
  4968.  
  4969.  
  4970.     Texture backgroundwall;
  4971.     backgroundwall.loadFromFile("FantasyLand.png");
  4972.     Sprite Menuwall; Menuwall.setTexture(backgroundwall);
  4973.     //Menu choices
  4974.     Sprite Choice, Choice2;
  4975.     Texture choice;
  4976.     if (!choice.loadFromFile("Untitled-1-Recovered.png"))
  4977.     {
  4978.         cout << "choice not found";
  4979.     }
  4980.     Choice.setTexture(choice);
  4981.     Choice.setPosition(0, 415);
  4982.     Choice.setScale(0.3, 0.27);
  4983.  
  4984.     Choice2.setTexture(choice);
  4985.     Choice2.setPosition(1024 - (0.3 * 1307), 315);
  4986.     Choice2.setScale(0.3, 0.27);
  4987.     //###############################################################################
  4988.  
  4989.  
  4990.     RenderWindow levels(VideoMode(1024, 680), "levels");
  4991.     setlevelsstatus(levels.getSize().x, levels.getSize().y);
  4992.     Texture levelwall;
  4993.     levelwall.loadFromFile("levelwall.png");
  4994.     Sprite levelwallS; levelwallS.setTexture(levelwall);
  4995.     Choice2.setPosition(1024 - (0.3 * 1307), 315); Choice.setPosition(0, 415);
  4996.     while (levels.isOpen())
  4997.     {
  4998.         // Menu choices Animation
  4999.         if (Choice.getPosition().x < 310)
  5000.         {
  5001.             Choice.move(0.5, 0);
  5002.         }
  5003.         if (Choice2.getPosition().x > 310)
  5004.         {
  5005.             Choice2.move(-0.5, 0);
  5006.         }
  5007.  
  5008.         Event evntlev;
  5009.         while (levels.pollEvent(evntlev))
  5010.         {
  5011.             switch (evntlev.type)
  5012.             {
  5013.             case Event::KeyReleased:
  5014.                 switch (evntlev.key.code)
  5015.                 {
  5016.                 case Keyboard::Up:
  5017.                     MoveUplev();
  5018.                     break;
  5019.  
  5020.                 case Keyboard::Down:
  5021.                     MoveDownlev();
  5022.                     break;
  5023.  
  5024.                 case Keyboard::Return:
  5025.                     switch (GetPressedlevel())
  5026.                     {
  5027.                     case 0:
  5028.                         outgame.stop();
  5029.                         levels.close();
  5030.                         Beginner_Mode();
  5031.                         break;
  5032.                     case 1:
  5033.                         outgame.stop();
  5034.                         levels.close();
  5035.                         Advanced_Level();
  5036.                         break;
  5037.                     case 2:
  5038.                         outgame.stop();
  5039.                         levels.close();
  5040.                         Legendary_Mode();
  5041.                         break;
  5042.                     case 3:
  5043.                         outgame.stop();
  5044.                         levels.close();
  5045.                         selectedlevelIndex = 0;
  5046.                         mainmenu();
  5047.                     }
  5048.  
  5049.                     break;
  5050.                 }
  5051.  
  5052.                 break;
  5053.             case Event::Closed:
  5054.                 return;
  5055.                 break;
  5056.             }
  5057.  
  5058.  
  5059.         }
  5060.         if ((Mouse::isButtonPressed(Mouse::Left)) && (Mouse::getPosition().x >= 615 && Mouse::getPosition().x <= 680)) {
  5061.             break;
  5062.  
  5063.         }
  5064.  
  5065.         levels.clear();
  5066.         levels.draw(levelwallS);
  5067.         levels.draw(Choice);
  5068.         levels.draw(Choice2);
  5069.         drawlev(levels);
  5070.         levels.display();
  5071.  
  5072.     }
  5073.  
  5074. }
  5075.  
  5076.  
  5077. void mainmenu()
  5078. {
  5079.  
  5080.     Music outgame; outgame.openFromFile("Main menu.wav");
  5081.     outgame.play();
  5082.     outgame.setLoop(1);
  5083.     //###############################################################################
  5084.     // Menu Shits
  5085.     RenderWindow background(VideoMode(1024, 680), "Bomber Man");
  5086.     setmenustatus(background.getSize().x, background.getSize().y);
  5087.  
  5088.  
  5089.     Texture backgroundwall;
  5090.     backgroundwall.loadFromFile("FantasyLand.png");
  5091.     Sprite Menuwall;
  5092.     Menuwall.setTexture(backgroundwall);
  5093.     //Menu choices
  5094.     Sprite Choice, Choice2;
  5095.     Texture choice;
  5096.     if (!choice.loadFromFile("Untitled-1-Recovered.png"))
  5097.     {
  5098.         cout << "choice not found";
  5099.     }
  5100.     Choice.setTexture(choice);
  5101.     Choice.setPosition(0, 415);
  5102.     Choice.setScale(0.3, 0.27);
  5103.  
  5104.     Choice2.setTexture(choice);
  5105.     Choice2.setPosition(1024 - (0.3 * 1307), 315);
  5106.     Choice2.setScale(0.3, 0.27);
  5107.     //###############################################################################
  5108.     while (background.isOpen())
  5109.     {
  5110.         // Menu choices Animation
  5111.         if (Choice.getPosition().x < 310)
  5112.         {
  5113.             Choice.move(0.5, 0);
  5114.         }
  5115.         if (Choice2.getPosition().x > 310)
  5116.         {
  5117.             Choice2.move(-0.5, 0);
  5118.         }
  5119.  
  5120.         Event evnt;
  5121.         while (background.pollEvent(evnt))
  5122.         {
  5123.             switch (evnt.type)
  5124.             {
  5125.             case sf::Event::KeyReleased:
  5126.                 switch (evnt.key.code)
  5127.                 {
  5128.                 case sf::Keyboard::Up:
  5129.                     MoveUp();
  5130.                     break;
  5131.  
  5132.                 case sf::Keyboard::Down:
  5133.                     MoveDown();
  5134.                     break;
  5135.  
  5136.                 case sf::Keyboard::Return:
  5137.                     switch (GetPressedItem())
  5138.                     {
  5139.                     case 0:
  5140.                         background.close();
  5141.                         levelsmenu(outgame);
  5142.                         break;
  5143.                     case 1:
  5144.                         outgame.stop();
  5145.                         background.close();
  5146.                         Multiplayer();
  5147.                         break;
  5148.                     case 2:
  5149.                         cout << "About Us button has been pressed \n";
  5150.                     case 3:
  5151.                         background.close();
  5152.                         //window.close();
  5153.                         return;
  5154.                         break;
  5155.                     }
  5156.  
  5157.                     break;
  5158.                 }
  5159.  
  5160.                 break;
  5161.             case Event::Closed:
  5162.                 background.close();
  5163.                 return;
  5164.                 break;
  5165.             }
  5166.         }
  5167.  
  5168.  
  5169.         background.clear();
  5170.         background.draw(Menuwall);
  5171.         background.draw(Choice);
  5172.         background.draw(Choice2);
  5173.         drawmenu(background);
  5174.         background.display();
  5175.  
  5176.     }
  5177.  
  5178. }
  5179.  
  5180.  
  5181.  
  5182.  
  5183. int main()
  5184. {
  5185.  
  5186.  
  5187.     mainmenu();
  5188.  
  5189. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement