Advertisement
Astaa001

complete range

Apr 30th, 2019
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 98.11 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<iostream>
  7. #include<algorithm>
  8. #include<vector>
  9. #include<queue>
  10. #include<functional>
  11. #include<ctime>
  12. #include<time.h>
  13. using namespace sf;
  14. using namespace std;
  15. struct leftmovement {
  16.     int i, j;
  17. };
  18. struct rightmovement {
  19.     int i, j;
  20. };
  21. struct upmovement {
  22.     int i, j;
  23. };
  24. struct downmovement {
  25.     int i, j;
  26. };
  27. struct BFS_Movement {
  28.     int i, j;
  29. }Smart_Skeleton_Movement, Red_Robot_Movement;
  30. struct status {
  31.     int lives = 3;
  32.     int range = 3;
  33.  
  34. }player_status;
  35. //////////////////////////////////////////////////////////
  36. //Bomb struct
  37. struct bomb {
  38.     bool bomb_placed = 0;
  39.     bool bomb_exploded = 0;
  40.     vector <Sprite>range_right;
  41.     vector <Sprite>range_left;
  42.     vector <Sprite>range_up;
  43.     vector <Sprite>range_down;
  44.     Sprite sprt;
  45.     Time bomb_time, start_explosion, explosion_time;
  46.     Clock bomb_clock, start_clock, explosion_clock;
  47.     int x_pos, y_pos, x_index, y_index;
  48.     int exp_animation_x = 1, exp_animation_y = 0, bomb_animation_y, bomb_animation_x;
  49.     bool flag_range_up = 1, flag_range_down = 1, flag_range_right = 1, flag_range_left = 1;
  50.  
  51. };
  52. int pos_x = 1, pos_y = 0, pos = 0, a, b, i, j;
  53. bool explosion = false, ispressed = false, flag = 0, flag1 = 0;
  54. /////////////////////////////////////////////////////////
  55. //General stuff
  56. const int length = 12, width = 17;
  57. float Smart_Monsters_Speed = 0.3;
  58. int Random_Monsters_Speed = 1;
  59.  
  60. // Menu stuff
  61. #define MAX_NUMBER_OF_ITEMS 4
  62. int selectedItemIndex = 0;
  63. Font font; Text menu[MAX_NUMBER_OF_ITEMS];
  64. void setmenustatus(float width, float height) {
  65.     if (!font.loadFromFile("Chocolate Bar Demo.otf"))
  66.     {
  67.         // handle error
  68.         cout << "SHIIIIT" << endl;
  69.     }
  70.  
  71.     for (int i = 0; i < MAX_NUMBER_OF_ITEMS; i++)
  72.     {
  73.         menu[i].setFont(font);
  74.         if (i == 0) {
  75.             menu[i].setFillColor(Color::Red);
  76.             menu[i].setString("Single player");
  77.             menu[i].setPosition(sf::Vector2f(width / 2.5, height / (MAX_NUMBER_OF_ITEMS + 1) * 2.35));
  78.         }
  79.         else if (i == 1) {
  80.             menu[i].setFillColor(Color::White);
  81.             menu[i].setString("Multiplayer");
  82.             menu[i].setPosition(sf::Vector2f(width / 2.5, height / (MAX_NUMBER_OF_ITEMS + 1) * 3.1));
  83.  
  84.         }
  85.         else if (i == 2)
  86.         {
  87.             menu[i].setFillColor(Color::White);
  88.             menu[i].setString("About us");
  89.             menu[i].setPosition(sf::Vector2f(width / 2.4, height / (MAX_NUMBER_OF_ITEMS + 1) * 3.75));
  90.         }
  91.         else {
  92.             menu[3].setFillColor(Color::White);
  93.             menu[3].setString("Exit");
  94.             menu[3].setPosition(sf::Vector2f(width / 2.25, height / (MAX_NUMBER_OF_ITEMS + 1) * 4.5));
  95.         }
  96.  
  97.     }
  98. }
  99.  
  100. // Levels_Menu stuff
  101. #define MAX_NUMBER_OF_levels 3
  102. int selectedlevelIndex = 0;
  103. Font levelsfont; Text levels[MAX_NUMBER_OF_levels];
  104. void setlevelsstatus(float width, float height) {
  105.     if (!levelsfont.loadFromFile("Chocolate Bar Demo.otf"))
  106.     {
  107.         // handle error
  108.         cout << "SHIIIIT" << endl;
  109.     }
  110.  
  111.     for (int i = 0; i < MAX_NUMBER_OF_levels; i++)
  112.     {
  113.         levels[i].setFont(levelsfont);
  114.         if (i == 0) {
  115.             levels[i].setFillColor(Color::Red);
  116.             levels[i].setString("Beginner");
  117.             levels[i].setPosition(sf::Vector2f(width / 2.4, height / (MAX_NUMBER_OF_ITEMS + 1) * 2.35));
  118.         }
  119.         else if (i == 1) {
  120.             levels[i].setFillColor(Color::White);
  121.             levels[i].setString("Advanced");
  122.             levels[i].setPosition(sf::Vector2f(width / 2.4, height / (MAX_NUMBER_OF_ITEMS + 1) * 3.1));
  123.  
  124.         }
  125.         else if (i == 2) {
  126.  
  127.             levels[i].setFillColor(Color::White);
  128.             levels[i].setString("Legendary");
  129.             levels[i].setPosition(sf::Vector2f(width / 2.4, height / (MAX_NUMBER_OF_ITEMS + 1) * 3.75));
  130.  
  131.         }
  132.     }
  133. }
  134. void drawmenu(RenderWindow &window)
  135. {
  136.     for (int i = 0; i < MAX_NUMBER_OF_ITEMS; i++)
  137.     {
  138.         window.draw(menu[i]);
  139.  
  140.     }
  141. }
  142. void drawlev(RenderWindow &window)
  143. {
  144.     for (int i = 0; i < MAX_NUMBER_OF_levels; i++)
  145.     {
  146.         window.draw(levels[i]);
  147.  
  148.     }
  149. }
  150. void MoveUp()
  151. {
  152.     if (selectedItemIndex - 1 >= 0)
  153.     {
  154.         menu[selectedItemIndex].setFillColor(Color::White);
  155.         selectedItemIndex--;
  156.         menu[selectedItemIndex].setFillColor(Color::Red);
  157.     }
  158. }
  159. void MoveUplev()
  160. {
  161.     if (selectedlevelIndex - 1 >= 0)
  162.     {
  163.         levels[selectedlevelIndex].setFillColor(Color::White);
  164.         selectedlevelIndex--;
  165.         levels[selectedlevelIndex].setFillColor(Color::Red);
  166.     }
  167. }
  168. void MoveDown()
  169. {
  170.     if (selectedItemIndex + 1 < MAX_NUMBER_OF_ITEMS)
  171.     {
  172.         menu[selectedItemIndex].setFillColor(Color::White);
  173.         selectedItemIndex++;
  174.         menu[selectedItemIndex].setFillColor(Color::Red);
  175.     }
  176. }
  177. void MoveDownlev()
  178. {
  179.     if (selectedlevelIndex + 1 < MAX_NUMBER_OF_levels)
  180.     {
  181.         levels[selectedlevelIndex].setFillColor(Color::White);
  182.         selectedlevelIndex++;
  183.         levels[selectedlevelIndex].setFillColor(Color::Red);
  184.     }
  185. }
  186. int GetPressedItem() {
  187.     return selectedItemIndex;
  188. }
  189. int GetPressedlevel() {
  190.     return selectedlevelIndex;
  191. }
  192.  
  193. int GetXindx(float a)
  194. {
  195.     return (a - 183) / 53 + 2;
  196. }
  197. int GetYindx(float a)
  198. {
  199.     return (a - 74) / 48 + 2;
  200. }
  201. int GetXpostion(int a)
  202. {
  203.     return ((a - 2) * 53) + 198;
  204. }
  205. int GetYpostion(int a)
  206. {
  207.     return ((a - 2) * 48) + 89;
  208. }
  209. void destroy_breakable_walls(int Xindx, int Yindx, Sprite Grid[][13], Texture &ground, Texture &ground2)
  210. {
  211.  
  212.     if (Xindx % 2 == Yindx % 2) { Grid[Xindx][Yindx].setTexture(ground); }
  213.     else { Grid[Xindx][Yindx].setTexture(ground2); }
  214.  
  215.     Grid[Xindx][Yindx].setPosition((Xindx + 2) * 53, (Yindx + 0.8) * 48);
  216.     Grid[Xindx][Yindx].setScale(0.1009, 0.101);
  217.  
  218.  
  219. }
  220. //void destroy_breakable_walls(int Xindx, int Yindx, Sprite Grid[][10], Texture &ground, Texture &ground2)
  221. //{
  222. //
  223. //  if (Xindx % 2 == Yindx % 2) { Grid[Xindx][Yindx].setTexture(ground); }
  224. //  else { Grid[Xindx][Yindx].setTexture(ground2); }
  225. //
  226. //  Grid[Xindx][Yindx].setPosition((Xindx + 2) * 53, (Yindx + 0.8) * 48);
  227. //  Grid[Xindx][Yindx].setScale(0.1009, 0.101);
  228. //
  229. //
  230. //}
  231.  
  232. bool vis[20][20];
  233. int dx[] = { 0,  0, 1, -1 };
  234. int dy[] = { 1, -1, 0,  0 };
  235. bool valid(int i, int j, Sprite arr[][length + 1], Texture &g1, Texture &g2)
  236. {
  237.     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);
  238. }
  239. void BFS(int srcX, int srcY, int distX, int distY, Sprite arr[][length + 1], Texture &g1, Texture &g2)
  240. {
  241.     memset(vis, 0, sizeof vis);
  242.     queue <pair<int, int> > Q;
  243.     vis[srcX][srcY] = 1;
  244.     Q.push({ srcX, srcY });
  245.     while (!Q.empty())
  246.     {
  247.         int nodeX = Q.front().first;
  248.         int nodeY = Q.front().second;
  249.         //cout << nodeY << endl;
  250.         if ((nodeX == distX && nodeY + 1 == distY)) {
  251.             Smart_Skeleton_Movement.i = nodeX;
  252.             Smart_Skeleton_Movement.j = nodeY;
  253.             Red_Robot_Movement.i = nodeX;
  254.             Red_Robot_Movement.j = nodeY;
  255.             break;
  256.         }
  257.         else if (nodeX == distX && nodeY - 1 == distY) {
  258.             Smart_Skeleton_Movement.i = nodeX;
  259.             Smart_Skeleton_Movement.j = nodeY;
  260.             Red_Robot_Movement.i = nodeX;
  261.             Red_Robot_Movement.j = nodeY;
  262.             break;
  263.         }
  264.         else if (nodeX + 1 == distX && nodeY == distY) {
  265.             Smart_Skeleton_Movement.i = nodeX;
  266.             Smart_Skeleton_Movement.j = nodeY;
  267.             Red_Robot_Movement.i = nodeX;
  268.             Red_Robot_Movement.j = nodeY;
  269.             break;
  270.         }
  271.         else if (nodeX - 1 == distX && nodeY == distY) {
  272.             Smart_Skeleton_Movement.i = nodeX;
  273.             Smart_Skeleton_Movement.j = nodeY;
  274.             Red_Robot_Movement.i = nodeX;
  275.             Red_Robot_Movement.j = nodeY;
  276.             break;
  277.         }
  278.  
  279.         Q.pop();
  280.         for (int k = 0; k < 4; k++)
  281.         {
  282.             int newNodeX = nodeX + dx[k];
  283.             int newNodeY = nodeY + dy[k];
  284.             if (valid(newNodeX, newNodeY, arr, g1, g2))
  285.             {
  286.                 vis[newNodeX][newNodeY] = 1;
  287.                 Q.push({ newNodeX, newNodeY });
  288.             }
  289.         }
  290.     }
  291. }
  292.  
  293. void Generate_Charcter(RectangleShape &charcter, Texture &charcter_texture, Vector2u &charcter_size, string filename, int X_Postion, int Y_Postion) {
  294.     X_Postion = GetXpostion(X_Postion); Y_Postion = GetYpostion(Y_Postion);
  295.     charcter.setPosition(X_Postion, Y_Postion);
  296.     charcter.setScale(0.8, 0.8);
  297.     charcter_texture.loadFromFile(filename);
  298.     charcter.setTexture(&charcter_texture);
  299.     charcter_size = charcter_texture.getSize();
  300.     charcter_size.x /= 9;
  301.     charcter_size.y /= 4;
  302.     charcter.setTextureRect(IntRect(charcter_size.x * 0, charcter_size.y * 2, charcter_size.x, charcter_size.y));
  303. }
  304. void Movement_Upward(RectangleShape &character, Time &Monster_time, Clock &Monster_clock, float &Monster_position, Vector2u &Monster_text_size, float Monster_speed)
  305. {
  306.     character.move(0.0, -Monster_speed);
  307.     Monster_time = Monster_clock.getElapsedTime();
  308.     if (Monster_time.asSeconds() >= 0.1) {
  309.         Monster_clock.restart();
  310.         Monster_position++;
  311.         if (Monster_position > 8)
  312.             Monster_position -= 8;
  313.     }
  314.     character.setTextureRect(IntRect(Monster_text_size.x*Monster_position, Monster_text_size.y * 0, Monster_text_size.x, Monster_text_size.y));
  315. }
  316. void Movement_Downward(RectangleShape &character, Time &Monster_time, Clock &Monster_clock, float &Monster_position, Vector2u &Monster_text_size, float Monster_speed)
  317. {
  318.     character.move(0.0, Monster_speed);
  319.     Monster_time = Monster_clock.getElapsedTime();
  320.     if (Monster_time.asSeconds() >= 0.1) {
  321.         Monster_clock.restart();
  322.         Monster_position++;
  323.         if (Monster_position > 8)
  324.             Monster_position -= 8;
  325.     }
  326.     character.setTextureRect(IntRect(Monster_text_size.x*Monster_position, Monster_text_size.y * 2, Monster_text_size.x, Monster_text_size.y));
  327. }
  328. void Movement_Right(RectangleShape &character, Time &Monster_time, Clock &Monster_clock, float &Monster_position, Vector2u &Monster_text_size, float Monster_speed)
  329. {
  330.     character.move(Monster_speed, 0.0);
  331.     Monster_time = Monster_clock.getElapsedTime();
  332.     if (Monster_time.asSeconds() >= 0.1) {
  333.         Monster_clock.restart();
  334.         Monster_position++;
  335.         if (Monster_position > 8)
  336.             Monster_position -= 8;
  337.     }
  338.     character.setTextureRect(IntRect(Monster_text_size.x*Monster_position, Monster_text_size.y * 3, Monster_text_size.x, Monster_text_size.y));
  339. }
  340. void Movement_Left(RectangleShape &character, Time &Monster_time, Clock &Monster_clock, float &Monster_position, Vector2u &Monster_text_size, float Monster_speed)
  341. {
  342.     character.move(-Monster_speed, 0.0);
  343.     Monster_time = Monster_clock.getElapsedTime();
  344.     if (Monster_time.asSeconds() >= 0.1) {
  345.         Monster_clock.restart();
  346.         Monster_position++;
  347.         if (Monster_position > 8)
  348.             Monster_position -= 8;
  349.     }
  350.     character.setTextureRect(IntRect(Monster_text_size.x*Monster_position, Monster_text_size.y * 1, Monster_text_size.x, Monster_text_size.y));
  351. }
  352. void Beginner_Mode()
  353. {
  354.     //###############################################################################
  355.                     // Load Songs
  356.     Music ingame,lost;
  357.     if (!ingame.openFromFile("ingame.wav"))             // ingame
  358.         cout << "error to load ingame " << endl;
  359.     if (!lost.openFromFile("For the Damaged Coda.wav"))     // End_Game
  360.         cout << "error to load The damgae of coda";
  361.     ingame.play();
  362.     //###############################################################################
  363.     // Making of Player
  364.     RectangleShape player(Vector2f(100, 120));
  365.     Texture player_texture;
  366.     Vector2u player_size;
  367.     Clock player_clock;
  368.     Time player_time;
  369.     float player_position = 0;
  370.     const int player_speed = 2;
  371.     Generate_Charcter(player, player_texture, player_size, "mainplayer.png", 10, 2);
  372.     //###############################################################################
  373.  
  374.     //###############################################################################
  375.     // Making of Yellow_Robot
  376.     RectangleShape Yellow_Robot(Vector2f(100, 120));
  377.     Texture Yellow_Robot_texture;
  378.     Vector2u Yellow_Robot_size;
  379.     Clock Yellow_Robot_clock;
  380.     Time Yellow_Robot_time;
  381.     float Yellow_Robot_speed = 1;
  382.     float Yellow_Robot_position = 0;
  383.     int Yellow_Robot_Counter = 0;
  384.     int Yellow_Robot_Rand_motion = rand() % 4 + 1;
  385.     Generate_Charcter(Yellow_Robot, Yellow_Robot_texture, Yellow_Robot_size, "yellow_robot.png", 15, 2);
  386.     //###############################################################################
  387.  
  388.     //###############################################################################
  389.     // Making of Skeleton
  390.     RectangleShape Skeleton(Vector2f(100, 120));
  391.     Texture Skeleton_texture;
  392.     Vector2u Skeleton_size;
  393.     Clock Skeleton_clock;
  394.     Time Skeleton_time;
  395.     int Skeleton_Rand_motion = rand() % 4 + 1;
  396.     int Skeleton_counter = 0;
  397.     float Skeleton_position = 0;
  398.     Generate_Charcter(Skeleton, Skeleton_texture, Skeleton_size, "monster (5).png", 7, 8);
  399.     //###############################################################################
  400.  
  401.  
  402.     //###############################################################################
  403.     // Making of White_Robot
  404.     RectangleShape White_Robot(Vector2f(100, 120));
  405.     Texture White_Robot_texture;
  406.     Vector2u White_Robot_size;
  407.     Clock White_Robot_clock;
  408.     Time White_Robot_time;
  409.     int White_Robot_Rand_motion = rand() % 4 + 1;
  410.     int White_Robot_counter = 0;
  411.     float White_Robot_position = 0;
  412.     Generate_Charcter(White_Robot, White_Robot_texture, White_Robot_size, "white_robot.png", 14, 8);
  413.     //###############################################################################
  414.  
  415.     //###############################################################################
  416.     // Movement stuff
  417.     leftmovement left; rightmovement right; upmovement up; downmovement down;
  418.     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;
  419.     //###############################################################################
  420.                         // Making of MAP //
  421.     //###############################################################################
  422.                         // Making of Grid //
  423.     Texture wall, ground, wallpaper, ground2, breakable, hurt, choice;
  424.     if (!breakable.loadFromFile("breakable.png"))
  425.     {
  426.         cout << "error loading breakable wall pic";
  427.     }
  428.     if (!wallpaper.loadFromFile("wallpaper.jpg"))
  429.     {
  430.         cout << "error loading wallpaper pic";
  431.     }
  432.     if (!wall.loadFromFile("3d wall.png"))
  433.     {
  434.         cout << "error loading wall pic";
  435.     }
  436.  
  437.     if (!ground.loadFromFile("ground 1.png"))
  438.     {
  439.         cout << "error loading ground pic";
  440.     }
  441.     if (!ground2.loadFromFile("grass.png"))
  442.     {
  443.         cout << "error loading grass pic";
  444.     }
  445.  
  446.     if (!hurt.loadFromFile("hurt.png"))
  447.     {
  448.         cout << "error loading  hurt pic";
  449.     }
  450.     hurt.setSmooth(1);
  451.     //###############################################################################
  452.  
  453.                 // Distribution of wall , brekable & ground on the Grid //
  454.  
  455.     Sprite Grid[width + 1][length + 1], Hurt, Wallpaper, bombing, exp;
  456.  
  457.     for (int i = 1; i <= width; i++)                // Distribution of wall and ground on the Grid //
  458.     {
  459.         for (int j = 1; j <= length; j++)
  460.         {
  461.             if (i % 2 != 0 && j % 2 != 0)
  462.             {
  463.  
  464.                 Grid[i][j].setTexture(wall);
  465.                 Grid[i][j].setPosition((i + 1.97)*53.15, (j + 0.255) * 48);
  466.                 Grid[i][j].setScale(Vector2f(0.1009, 0.165));
  467.  
  468.             }
  469.  
  470.             else if (i == 1 || i == width)
  471.             {
  472.                 Grid[i][j].setTexture(wall);
  473.                 Grid[i][j].setPosition((i + 1.97)*53.15, (j + 0.255) * 48);
  474.                 Grid[i][j].setScale(Vector2f(0.1009, 0.165));
  475.             }
  476.             else if (j == 1 || j == length)
  477.             {
  478.                 Grid[i][j].setTexture(wall);
  479.                 Grid[i][j].setPosition((i + 1.97)*53.15, (j + 0.255) * 48);
  480.                 Grid[i][j].setScale(Vector2f(0.1009, 0.165));
  481.             }
  482.             else
  483.             {
  484.                 if (i % 2 == j % 2) { Grid[i][j].setTexture(ground); }
  485.                 else { Grid[i][j].setTexture(ground2); }
  486.                 Grid[i][j].setPosition((i + 2) * 53, (j + 0.8) * 48);
  487.                 Grid[i][j].setScale(0.1, 0.101);
  488.             }
  489.         }
  490.     }
  491.  
  492.  
  493.     for (int i = 1; i <= 30; i++)                   // Distribution of Brekable on the Grid //
  494.     {
  495.         int x = rand() % 15 + 2, y = rand() % 9 + 2;
  496.         if (x % 2 != 0 && y % 2 != 0)
  497.         {
  498.             x++;
  499.         }
  500.         Grid[x][y].setTexture(breakable);
  501.         Grid[x][y].setPosition((x + 1.97)*53.15, (y + 0.255) * 48);
  502.         Grid[x][y].setScale(Vector2f(0.1009, 0.165));
  503.     }
  504.  
  505.  
  506.    
  507.     //###############################################################################
  508.  
  509.  
  510.     //###############################################################################
  511.                             // Player Abilities and Features //
  512.     Texture  life, bomb_frame, range, tomb, Rip, healskill, speedskill, rangeskill, timebomb, bombtext, exptext;
  513.     Hurt.setTexture(hurt);
  514.     Wallpaper.setTexture(wallpaper);
  515.     if (!life.loadFromFile("flife.png"))
  516.     {
  517.         cout << "error loading life pic";
  518.     }
  519.     if (!range.loadFromFile("frange.png"))
  520.     {
  521.         cout << "error loading range pic";
  522.     }
  523.     if (!bomb_frame.loadFromFile("fbomb.png"))
  524.     {
  525.         cout << "error loading bomb pic";
  526.     }
  527.     if (!Rip.loadFromFile("death.png"))
  528.     {
  529.         cout << "error loading RIP pic";
  530.     }
  531.     if (!tomb.loadFromFile("Ripp.png"))
  532.     {
  533.         cout << "error loading tomb pic";
  534.     }
  535.     if (!healskill.loadFromFile("Heal .png"))
  536.     {
  537.         cout << "error to loading Heal skill" << endl;
  538.     }
  539.  
  540.     if (!rangeskill.loadFromFile("Range skill.png"))
  541.     {
  542.         cout << "error to loading Range skill " << endl;
  543.     }
  544.     if (!timebomb.loadFromFile("time-bomb.png"))
  545.     {
  546.         cout << "error to loading time bomb skill " << endl;
  547.     }
  548.  
  549.  
  550.     //###############################################################################
  551.     // Player Abilities
  552.     //###############################################################################
  553.     Sprite lifeS, bombS, rangeS, Tomb, RIP_Photo,timebombS[2] ,super_life[2],super_speed[2],super_range[2];
  554.     /*super_life[0].setTexture(rangeskill);
  555.     super_life[0].setScale(0.5, 0.3);
  556.     super_life[0].setPosition(GetXpostion(4)+20, GetYpostion(6)); // y pos +2 needed indx*/
  557.  
  558.    
  559.     lifeS.setTexture(life);
  560.     lifeS.setPosition(0, 180);
  561.     lifeS.setScale(0.4, 0.4);
  562.  
  563.     rangeS.setTexture(range);
  564.     rangeS.setPosition(0, 250);
  565.     rangeS.setScale(0.4, 0.4);
  566.  
  567.     bombS.setTexture(bomb_frame);
  568.     bombS.setPosition(0, 330);
  569.     bombS.setScale(0.4, 0.4);
  570.  
  571.     Tomb.setTexture(tomb);
  572.     Tomb.setScale(0.09, 0.09);
  573.  
  574.     RIP_Photo.setTexture(Rip);
  575.     Clock Clock_Damgae;
  576.     //###############################################################################
  577.    
  578.  
  579.     //###############################################################################
  580.                 //Player Bomb stuff //
  581.     bombtext.loadFromFile("BOOM.png");
  582.     exptext.loadFromFile("exp.png");
  583.     bombing.setTexture(bombtext);
  584.     exp.setTexture(exptext);
  585.     Vector2u text_size_bomb = bombtext.getSize();
  586.     Vector2u text_size_exp = exptext.getSize();
  587.     text_size_bomb.y /= 4;
  588.     text_size_exp.x /= 3;
  589.     text_size_exp.y /= 3;
  590.     Time times2, times, t, ti;
  591.     Clock clocks2, c, cs, clocks;
  592.  
  593.     bomb bomb_template;
  594.     bomb_template.sprt.setTexture(bombtext);
  595.     bomb_template.sprt.setScale(0.15f, 0.15f);
  596.     vector<bomb>bombs;
  597.     int number_of_bombs = 0, range_of_bomb = 3, bomb_placement_timer = 0;
  598.     //bombs.push_back(bomb_template);
  599.     //###############################################################################
  600.     bool death_flag=0;
  601.     //###############################################################################
  602.                             // Game Window //
  603.     RenderWindow Level_1(VideoMode(1280, 768), "Fuck");
  604.     while (Level_1.isOpen())
  605.     {
  606.        
  607.         // Robot 1 movement
  608.         Robot_xindx = (float)((float)(Yellow_Robot.getPosition().x - 183) / 53 + 2);
  609.         Robot_yindx = (float)((float)(Yellow_Robot.getPosition().y - 74) / 48 + 2);
  610.         right.i = GetXindx(Yellow_Robot.getPosition().x + 20); right.j = Robot_yindx;
  611.         left.i = GetXindx(Yellow_Robot.getPosition().x - 20); left.j = Robot_yindx;
  612.         up.i = Robot_xindx; up.j = GetYindx(Yellow_Robot.getPosition().y - 7);
  613.         down.i = Robot_xindx; down.j = GetYindx(Yellow_Robot.getPosition().y + 7);
  614.         //######################################################################################################
  615.                                     // Robot Movement //
  616.         if (Yellow_Robot_Counter >= 250)
  617.         {
  618.             Yellow_Robot_Rand_motion = rand() % 4 + 1;
  619.             Yellow_Robot_Counter = 0;
  620.         }
  621.  
  622.         if (Yellow_Robot_Rand_motion == 1)                                          // Moving UP => Rand_motion == 1
  623.         {
  624.             Yellow_Robot_Counter++;
  625.             if (Grid[up.i][up.j].getTexture() == &ground || Grid[up.i][up.j].getTexture() == &ground2)
  626.             {
  627.  
  628.                 Movement_Upward(Yellow_Robot, Yellow_Robot_time, Yellow_Robot_clock, Yellow_Robot_position, Yellow_Robot_size, Yellow_Robot_speed);
  629.  
  630.             }
  631.             else
  632.             {
  633.                 Yellow_Robot_Counter = 250;
  634.             }
  635.  
  636.         }
  637.  
  638.  
  639.         else if (Yellow_Robot_Rand_motion == 2)                                 // Moving Down => Rand_motion == 2
  640.         {
  641.             Yellow_Robot_Counter++;
  642.             if (Grid[down.i][down.j].getTexture() == &ground || Grid[down.i][down.j].getTexture() == &ground2)
  643.             {
  644.                 Movement_Downward(Yellow_Robot, Yellow_Robot_time, Yellow_Robot_clock, Yellow_Robot_position, Yellow_Robot_size, Yellow_Robot_speed);
  645.             }
  646.  
  647.             else
  648.             {
  649.                 Yellow_Robot_Counter = 250;
  650.             }
  651.         }
  652.  
  653.  
  654.         else if (Yellow_Robot_Rand_motion == 3)                                 // Moving Right => Rand_motion == 3
  655.         {
  656.             Yellow_Robot_Counter++;
  657.             if (Grid[right.i][right.j].getTexture() == &ground || Grid[right.i][right.j].getTexture() == &ground2)
  658.             {
  659.                 Movement_Right(Yellow_Robot, Yellow_Robot_time, Yellow_Robot_clock, Yellow_Robot_position, Yellow_Robot_size, Yellow_Robot_speed);
  660.             }
  661.             else
  662.             {
  663.                 Yellow_Robot_Counter = 250;
  664.             }
  665.         }
  666.  
  667.  
  668.         else if (Yellow_Robot_Rand_motion == 4)                                 // Moving Left => Rand_motion == 4
  669.         {
  670.             Yellow_Robot_Counter++;
  671.             if (Grid[left.i][left.j].getTexture() == &ground || Grid[left.i][left.j].getTexture() == &ground2)
  672.             {
  673.                 Movement_Left(Yellow_Robot, Yellow_Robot_time, Yellow_Robot_clock, Yellow_Robot_position, Yellow_Robot_size, Yellow_Robot_speed);
  674.             }
  675.             else
  676.             {
  677.                 Yellow_Robot_Counter = 250;
  678.             }
  679.  
  680.         }
  681.  
  682.         // Skeleton movement
  683.         Skeleton_xindx = (float)((float)(Skeleton.getPosition().x - 183) / 53 + 2);
  684.         Skeleton_yindx = (float)((float)(Skeleton.getPosition().y - 74) / 48 + 2);
  685.         right.i = GetXindx(Skeleton.getPosition().x + 20); right.j = Skeleton_yindx;
  686.         left.i = GetXindx(Skeleton.getPosition().x - 20); left.j = Skeleton_yindx;
  687.         up.i = Skeleton_xindx; up.j = GetYindx(Skeleton.getPosition().y - 7);
  688.         down.i = Skeleton_xindx; down.j = GetYindx(Skeleton.getPosition().y + 7);
  689.  
  690.         // Skeleton Movement
  691.         if (Skeleton_counter >= 250)
  692.         {
  693.             Skeleton_Rand_motion = rand() % 4 + 1;
  694.             Skeleton_counter = 0;
  695.         }
  696.  
  697.         if (Skeleton_Rand_motion == 1)                                          // Moving UP => Rand_motion == 1
  698.         {
  699.             Skeleton_counter++;
  700.             if (Grid[up.i][up.j].getTexture() == &ground || Grid[up.i][up.j].getTexture() == &ground2)
  701.             {
  702.                 Movement_Upward(Skeleton, Skeleton_time, Skeleton_clock, Skeleton_position, Skeleton_size, Random_Monsters_Speed);
  703.             }
  704.             else
  705.             {
  706.                 Skeleton_counter = 250;
  707.             }
  708.  
  709.         }
  710.  
  711.  
  712.         else if (Skeleton_Rand_motion == 2)                                 // Moving Down => Rand_motion == 2
  713.         {
  714.             Skeleton_counter++;
  715.             if (Grid[down.i][down.j].getTexture() == &ground || Grid[down.i][down.j].getTexture() == &ground2)
  716.             {
  717.                 Movement_Downward(Skeleton, Skeleton_time, Skeleton_clock, Skeleton_position, Skeleton_size, Random_Monsters_Speed);
  718.             }
  719.  
  720.             else
  721.             {
  722.                 Skeleton_counter = 250;
  723.             }
  724.         }
  725.  
  726.  
  727.         else if (Skeleton_Rand_motion == 3)                                 // Moving Right => Rand_motion == 3
  728.         {
  729.             Skeleton_counter++;
  730.             if (Grid[right.i][right.j].getTexture() == &ground || Grid[right.i][right.j].getTexture() == &ground2)
  731.             {
  732.                 Movement_Right(Skeleton, Skeleton_time, Skeleton_clock, Skeleton_position, Skeleton_size, Random_Monsters_Speed);
  733.  
  734.  
  735.             }
  736.             else
  737.             {
  738.                 Skeleton_counter = 250;
  739.             }
  740.         }
  741.  
  742.  
  743.         else if (Skeleton_Rand_motion == 4)                                 // Moving Left => Rand_motion == 4
  744.         {
  745.             Skeleton_counter++;
  746.             if (Grid[left.i][left.j].getTexture() == &ground || Grid[left.i][left.j].getTexture() == &ground2)
  747.             {
  748.  
  749.                 Movement_Left(Skeleton, Skeleton_time, Skeleton_clock, Skeleton_position, Skeleton_size, Random_Monsters_Speed);
  750.  
  751.             }
  752.             else
  753.             {
  754.                 Skeleton_counter = 250;
  755.             }
  756.  
  757.         }
  758.  
  759.         //######################################################################################################
  760.         // White_Robot movement
  761.         White_Robot_xindx = (float)((float)(White_Robot.getPosition().x - 183) / 53 + 2);
  762.         White_Robot_yindx = (float)((float)(White_Robot.getPosition().y - 74) / 48 + 2);
  763.         right.i = GetXindx(White_Robot.getPosition().x + 20); right.j = White_Robot_yindx;
  764.         left.i = GetXindx(White_Robot.getPosition().x - 20); left.j = White_Robot_yindx;
  765.         up.i = White_Robot_xindx; up.j = GetYindx(White_Robot.getPosition().y - 7);
  766.         down.i = White_Robot_xindx; down.j = GetYindx(White_Robot.getPosition().y + 7);
  767.         //######################################################################################################
  768.  
  769.         //######################################################################################################
  770.         // White_Robot Movement
  771.         if (White_Robot_counter >= 250)
  772.         {
  773.             White_Robot_Rand_motion = rand() % 4 + 1;
  774.             White_Robot_counter = 0;
  775.         }
  776.  
  777.         if (White_Robot_Rand_motion == 1)                                           // Moving UP => Rand_motion == 1
  778.         {
  779.             White_Robot_counter++;
  780.             if (Grid[up.i][up.j].getTexture() == &ground || Grid[up.i][up.j].getTexture() == &ground2)
  781.             {
  782.                 Movement_Upward(White_Robot, White_Robot_time, White_Robot_clock, White_Robot_position, White_Robot_size, Random_Monsters_Speed);
  783.             }
  784.             else
  785.             {
  786.                 White_Robot_counter = 250;
  787.             }
  788.  
  789.         }
  790.  
  791.  
  792.         else if (White_Robot_Rand_motion == 2)                                  // Moving Down => Rand_motion == 2
  793.         {
  794.             White_Robot_counter++;
  795.             if (Grid[down.i][down.j].getTexture() == &ground || Grid[down.i][down.j].getTexture() == &ground2)
  796.             {
  797.                 Movement_Downward(White_Robot, White_Robot_time, White_Robot_clock, White_Robot_position, White_Robot_size, Random_Monsters_Speed);
  798.             }
  799.  
  800.             else
  801.             {
  802.                 White_Robot_counter = 250;
  803.             }
  804.         }
  805.  
  806.  
  807.         else if (White_Robot_Rand_motion == 3)                                  // Moving Right => Rand_motion == 3
  808.         {
  809.             White_Robot_counter++;
  810.             if (Grid[right.i][right.j].getTexture() == &ground || Grid[right.i][right.j].getTexture() == &ground2)
  811.             {
  812.                 Movement_Right(White_Robot, White_Robot_time, White_Robot_clock, White_Robot_position, White_Robot_size, Random_Monsters_Speed);
  813.  
  814.             }
  815.             else
  816.             {
  817.                 White_Robot_counter = 250;
  818.             }
  819.         }
  820.  
  821.  
  822.         else if (White_Robot_Rand_motion == 4)                                  // Moving Left => Rand_motion == 4
  823.         {
  824.             White_Robot_counter++;
  825.             if (Grid[left.i][left.j].getTexture() == &ground || Grid[left.i][left.j].getTexture() == &ground2)
  826.             {
  827.                 Movement_Left(White_Robot, White_Robot_time, White_Robot_clock, White_Robot_position, White_Robot_size, Random_Monsters_Speed);
  828.             }
  829.             else
  830.             {
  831.                 White_Robot_counter = 250;
  832.             }
  833.  
  834.         }
  835.  
  836.         //######################################################################################################
  837.  
  838.         // Player Movement
  839.         Player_xindx = (float)((float)(player.getPosition().x - 183) / 53 + 2);
  840.         Player_yindx = (float)((float)(player.getPosition().y - 74) / 48 + 2);
  841.         right.i = GetXindx(player.getPosition().x + 20); right.j = Player_yindx;
  842.         left.i = GetXindx(player.getPosition().x - 20); left.j = Player_yindx;
  843.         up.i = Player_xindx; up.j = GetYindx(player.getPosition().y - 7);
  844.         down.i = Player_xindx; down.j = GetYindx(player.getPosition().y + 7);
  845.  
  846.         if (Keyboard::isKeyPressed(Keyboard::Key::Right) && (Grid[right.i][right.j].getTexture() == &ground || Grid[right.i][right.j].getTexture() == &ground2))      // Moving Right
  847.         {
  848.             Movement_Right(player, player_time, player_clock, player_position, player_size, player_speed);
  849.         }
  850.         else if (Keyboard::isKeyPressed(Keyboard::Key::Left) && (Grid[left.i][left.j].getTexture() == &ground || Grid[left.i][left.j].getTexture() == &ground2))         // Moving Left
  851.         {
  852.             Movement_Left(player, player_time, player_clock, player_position, player_size, player_speed);
  853.         }
  854.         else if (Keyboard::isKeyPressed(Keyboard::Key::Up) && (Grid[up.i][up.j].getTexture() == &ground || Grid[up.i][up.j].getTexture() == &ground2))           // Moving Up
  855.         {
  856.             Movement_Upward(player, player_time, player_clock, player_position, player_size, player_speed);
  857.         }
  858.         else if (Keyboard::isKeyPressed(Keyboard::Key::Down) && (Grid[down.i][down.j].getTexture() == &ground || Grid[down.i][down.j].getTexture() == &ground2))         // Moving Down
  859.         {
  860.             Movement_Downward(player, player_time, player_clock, player_position, player_size, player_speed);
  861.         }
  862.  
  863.         //######################################################################################################
  864.  
  865.         Event event;
  866.         while (Level_1.pollEvent(event))
  867.         {
  868.             if (event.type == sf::Event::Closed || Keyboard::isKeyPressed(Keyboard::Enter))
  869.                 Level_1.close();
  870.  
  871.         }
  872.         Level_1.clear();
  873.         // Drawing of the Wallpaper
  874.         Level_1.draw(Wallpaper);
  875.         //#####################################################################################################
  876.         // Bombing stuff
  877.         // bombing
  878.         if (bomb_placement_timer < 200)
  879.         {
  880.             bomb_placement_timer++;
  881.         }
  882.  
  883.         if (Keyboard::isKeyPressed(Keyboard::Key::Space) && bomb_placement_timer == 200) {
  884.  
  885.             bombs.push_back(bomb_template);
  886.  
  887.  
  888.             bombs[bombs.size() - 1].bomb_clock.restart();
  889.             bombs[bombs.size() - 1].explosion_clock.restart();
  890.             bombs[bombs.size() - 1].start_clock.restart();
  891.  
  892.  
  893.  
  894.             bombs[bombs.size() - 1].bomb_placed = 1;
  895.             bombs[bombs.size() - 1].x_pos = player.getPosition().x;
  896.             bombs[bombs.size() - 1].y_pos = player.getPosition().y;
  897.             bombs[bombs.size() - 1].x_index = GetXindx(bombs[bombs.size() - 1].x_pos);
  898.             bombs[bombs.size() - 1].y_index = GetYindx(bombs[bombs.size() - 1].y_pos);
  899.             bomb_placement_timer = 0;
  900.         }
  901.  
  902.         //if (bombs.size()>0){
  903.         for (int io = 0; io < bombs.size(); io++)
  904.         {
  905.  
  906.             if (bombs[io].bomb_placed == 1) {
  907.                 bombs[io].bomb_time = bombs[io].bomb_clock.getElapsedTime();
  908.                 bombs[io].start_explosion = bombs[io].start_clock.getElapsedTime();
  909.                 if (bombs[io].bomb_time.asSeconds() >= 0.2) {
  910.                     bombs[io].bomb_clock.restart();
  911.                     bombs[io].sprt.setPosition(bombs[io].x_pos, bombs[io].y_pos + 25);
  912.                     bombs[io].sprt.setTextureRect(IntRect(0, text_size_bomb.y*bombs[io].bomb_animation_y, text_size_bomb.x, text_size_bomb.y));
  913.                     bombs[io].bomb_animation_y += 2;
  914.                     if (bombs[io].bomb_animation_y > 2)
  915.                         bombs[io].bomb_animation_y = 0;
  916.                 }
  917.                 if (bombs[io].start_explosion.asSeconds() >= 3) {
  918.                     bombs[io].bomb_exploded = 1;
  919.                     bombs[io].bomb_placed = 0;
  920.                     //                bombs[number_of_bombs].sprt.setColor(Color::Transparent);
  921.                     for (int k = 0; k <= range_of_bomb; k++)
  922.                     {
  923.                         bombs[io].range_right.push_back(exp);
  924.                         bombs[io].range_left.push_back(exp);
  925.                         bombs[io].range_up.push_back(exp);
  926.                         bombs[io].range_down.push_back(exp);
  927.                         //                     v[z].push_back(exp);
  928.                     }
  929.                 }
  930.             }
  931.             //cout<<player.getPosition().x<<' '<<player.getPosition().y<<endl;
  932.             if (bombs[io].bomb_exploded) {
  933.                 bombs[io].explosion_time = bombs[io].explosion_clock.getElapsedTime();
  934.                 if (bombs[io].explosion_time.asSeconds() >= 0.3) {
  935.                     bombs[io].explosion_clock.restart();
  936.  
  937.                     for (int n = 0, k = 0; k <= range_of_bomb, n <= range_of_bomb * 50; k++, n += 50)
  938.                         bombs[io].range_right[k].setPosition(bombs[io].x_pos + n, bombs[io].y_pos);
  939.  
  940.                     for (int n = 0, k = 0; k <= range_of_bomb, n <= range_of_bomb * 50; k++, n += 50)
  941.                         bombs[io].range_right[k].setTextureRect(IntRect(text_size_exp.x*bombs[io].exp_animation_x, text_size_bomb.y*bombs[io].exp_animation_y, text_size_exp.x, text_size_exp.y));
  942.  
  943.                     for (int n = 0, k = 0; k <= range_of_bomb, n <= range_of_bomb * 50; k++, n += 50)
  944.                         bombs[io].range_left[k].setPosition(bombs[io].x_pos - n, bombs[io].y_pos);
  945.  
  946.                     for (int n = 0, k = 0; k <= range_of_bomb, n <= range_of_bomb * 50; k++, n += 50)
  947.                         bombs[io].range_left[k].setTextureRect(IntRect(text_size_exp.x*bombs[io].exp_animation_x, text_size_bomb.y*bombs[io].exp_animation_y, text_size_exp.x, text_size_exp.y));
  948.  
  949.                     for (int n = 0, k = 0; k <= range_of_bomb, n <= range_of_bomb * 50; k++, n += 50)
  950.                         bombs[io].range_up[k].setPosition(bombs[io].x_pos, bombs[io].y_pos - n);
  951.  
  952.                     for (int n = 0, k = 0; k <= range_of_bomb, n <= range_of_bomb * 50; k++, n += 50)
  953.                         bombs[io].range_up[k].setTextureRect(IntRect(text_size_exp.x*bombs[io].exp_animation_x, text_size_bomb.y*bombs[io].exp_animation_y, text_size_exp.x, text_size_exp.y));
  954.  
  955.                     for (int n = 0, k = 0; k <= range_of_bomb, n <= range_of_bomb * 50; k++, n += 50)
  956.                         bombs[io].range_down[k].setPosition(bombs[io].x_pos, bombs[io].y_pos + n);
  957.  
  958.                     for (int n = 0, k = 0; k <= range_of_bomb, n <= range_of_bomb * 50; k++, n += 50)
  959.                         bombs[io].range_down[k].setTextureRect(IntRect(text_size_exp.x*bombs[io].exp_animation_x, text_size_bomb.y*bombs[io].exp_animation_y, text_size_exp.x, text_size_exp.y));
  960.  
  961.                     /*if(Grid[a][b+1].getTexture()==&breakable)
  962.                         {
  963.                             if (a%2==(b+1)%2) {Grid[a][b+1].setTexture(ground);}
  964.                             else {Grid[a][b+1].setTexture(ground2);}
  965.                         }
  966.                      else if(Grid[a+1][b].getTexture()==&breakable)
  967.                         {
  968.                             if ((a+1)%2==b%2) {Grid[a+1][b].setTexture(ground);}
  969.                             else {Grid[a+1][b].setTexture(ground2);}
  970.                         }
  971.                     else if(Grid[a-1][b].getTexture()==&breakable)
  972.                         {
  973.                             if ((a-1)%2==b%2) {Grid[a-1][b].setTexture(ground);}
  974.                             else {Grid[a-1][b].setTexture(ground2);}
  975.                         }
  976.                     else if(Grid[a][b-1].getTexture()==&breakable)
  977.                         {
  978.                             if (a%2==(b-1)%2) {Grid[a][b-1].setTexture(ground);}
  979.                             else {Grid[a][b-1].setTexture(ground2);}
  980.                         }*/
  981.                     cout << bombs[io].exp_animation_x << "          " << bombs[io].exp_animation_y << endl;
  982.                     bombs[io].exp_animation_x++;
  983.                     if (bombs[io].exp_animation_x == 3) {
  984.                         bombs[io].exp_animation_x = 0, bombs[io].exp_animation_y++;
  985.                         if (bombs[io].exp_animation_y == 3) {
  986.                             bombs[io].bomb_exploded = 0;
  987.                             //  bombs[io].explosion_clock.restart();
  988.                                   /*for(int z=0;z<=3;z++)
  989.                               {
  990.                                       bombs[number_of_bombs].range_right[z].setColor(Color::Transparent);
  991.                                       bombs[number_of_bombs].range_left[z].setColor(Color::Transparent);
  992.                                       bombs[number_of_bombs].range_up[z].setColor(Color::Transparent);
  993.                                       bombs[number_of_bombs].range_down[z].setColor(Color::Transparent);
  994.  
  995.                               }*/
  996.                             bombs.erase(bombs.begin() + 1);
  997.  
  998.                         }
  999.                     }
  1000.                 }
  1001.             }
  1002.         }
  1003.         //}
  1004.         //#####################################################################################################
  1005.         bool death_flag = 0;
  1006.  
  1007.  
  1008.    
  1009.  
  1010.         //Drawing of The Map
  1011.         for (int i = 2; i < width; i++)
  1012.         {
  1013.             for (int j = 2; j < length; j++)
  1014.             {
  1015.                 if (Grid[i][j].getTexture() == &ground || Grid[i][j].getTexture() == &ground2)
  1016.                 {
  1017.                     Level_1.draw(Grid[i][j]);
  1018.                 }
  1019.             }
  1020.  
  1021.         }
  1022.  
  1023.         for (int j = 1; j <= length; j++)
  1024.         {
  1025.             for (int i = 1; i <= width; i++)
  1026.             {
  1027.                 if (Grid[i][j].getTexture() == &ground || Grid[i][j].getTexture() == &ground2)
  1028.                 {
  1029.                     continue;
  1030.                 }
  1031.  
  1032.                 Level_1.draw(Grid[i][j]);
  1033.  
  1034.                 if (GetYindx(player.getPosition().y) >= j)
  1035.                 {
  1036.                     Level_1.draw(player);
  1037.                 }
  1038.  
  1039.                 if (GetYindx(Yellow_Robot.getPosition().y) >= j)
  1040.                 {
  1041.                     Level_1.draw(Yellow_Robot);
  1042.                 }
  1043.                 if (GetYindx(Skeleton.getPosition().y) >= j)
  1044.                 {
  1045.                     Level_1.draw(Skeleton);
  1046.                 }
  1047.                 if (GetYindx(White_Robot.getPosition().y) >= j)
  1048.                 {
  1049.                     Level_1.draw(White_Robot);
  1050.                 }
  1051.  
  1052.             }
  1053.         }
  1054.         //############################################################################################
  1055.         // Drawing Bombs
  1056.          //if (bombs.size()>0)
  1057.     //{
  1058.         for (int io = 0; io < bombs.size(); io++)
  1059.         {
  1060.             if (bombs[io].bomb_placed)
  1061.                 Level_1.draw(bombs[io].sprt);
  1062.             if (bombs[io].bomb_exploded)
  1063.             {
  1064.                 //for(int h=0;h<=3;h++)
  1065.                 for (int g = 0; g <= range_of_bomb && bombs[io].flag_range_right; g++)
  1066.                 {
  1067.  
  1068.                     Level_1.draw(bombs[io].range_right[g]);
  1069.  
  1070.                     if ((Grid[bombs[io].x_index + g][bombs[io].y_index].getTexture() == &breakable))
  1071.                     {
  1072.  
  1073.  
  1074.                         destroy_breakable_walls(bombs[io].x_index + g, bombs[io].y_index, Grid, ground, ground2);
  1075.  
  1076.                         bombs[io].flag_range_right = 0;
  1077.                         break;
  1078.  
  1079.  
  1080.                     }
  1081.                     else if (Grid[bombs[io].x_index + g][bombs[io].y_index].getTexture() == &wall)
  1082.                     {
  1083.  
  1084.                         bombs[io].flag_range_right = 0;
  1085.                         break;
  1086.                     }
  1087.                 }
  1088.  
  1089.                 for (int g = 0; g <= range_of_bomb && bombs[io].flag_range_left; g++)
  1090.                 {
  1091.  
  1092.  
  1093.  
  1094.                     Level_1.draw(bombs[io].range_left[g]);
  1095.  
  1096.                     if ((Grid[bombs[io].x_index - g][bombs[io].y_index].getTexture() == &breakable))
  1097.                     {
  1098.  
  1099.  
  1100.                         destroy_breakable_walls(bombs[io].x_index - g, bombs[io].y_index, Grid, ground, ground2);
  1101.  
  1102.                         bombs[io].flag_range_left = 0;
  1103.                         break;
  1104.  
  1105.  
  1106.                     }
  1107.                     else if (Grid[bombs[io].x_index - g][bombs[io].y_index].getTexture() == &wall)
  1108.                     {
  1109.  
  1110.                         bombs[io].flag_range_left = 0;
  1111.                         break;
  1112.                     }
  1113.  
  1114.  
  1115.  
  1116.                 }
  1117.  
  1118.                 for (int g = 0; g <= range_of_bomb && bombs[io].flag_range_up; g++)
  1119.                 {
  1120.  
  1121.                     Level_1.draw(bombs[io].range_up[g]);
  1122.  
  1123.                     if ((Grid[bombs[io].x_index][bombs[io].y_index - g].getTexture() == &breakable))
  1124.                     {
  1125.  
  1126.  
  1127.                         destroy_breakable_walls(bombs[io].x_index, bombs[io].y_index - g, Grid, ground, ground2);
  1128.  
  1129.                         bombs[io].flag_range_up = 0;
  1130.                         break;
  1131.  
  1132.  
  1133.                     }
  1134.                     else if (Grid[bombs[io].x_index][bombs[io].y_index - g].getTexture() == &wall)
  1135.                     {
  1136.  
  1137.                         bombs[io].flag_range_up = 0;
  1138.                         break;
  1139.                     }
  1140.  
  1141.  
  1142.                 }
  1143.  
  1144.  
  1145.  
  1146.  
  1147.  
  1148.                 for (int g = 0; g <= range_of_bomb && bombs[io].flag_range_down; g++)
  1149.                 {
  1150.  
  1151.  
  1152.  
  1153.                     Level_1.draw(bombs[io].range_down[g]);
  1154.                     if ((Grid[bombs[io].x_index][bombs[io].y_index + g].getTexture() == &breakable))
  1155.                     {
  1156.  
  1157.  
  1158.                         destroy_breakable_walls(bombs[io].x_index, bombs[io].y_index + g, Grid, ground, ground2);
  1159.  
  1160.                         bombs[io].flag_range_down = 0;
  1161.                         break;
  1162.  
  1163.  
  1164.                     }
  1165.                     else if (Grid[bombs[io].x_index][bombs[io].y_index + g].getTexture() == &wall)
  1166.                     {
  1167.  
  1168.                         bombs[io].flag_range_down = 0;
  1169.                         break;
  1170.                     }
  1171.  
  1172.  
  1173.                 }
  1174.  
  1175.             }
  1176.         }
  1177.         //############################################################################################
  1178.  
  1179.         if (player_status.lives == 2) {
  1180.            
  1181.         }
  1182.         else if (player_status.lives == 1) {
  1183.            
  1184.         }
  1185.         else if (player_status.lives <= 0) { // player dead
  1186.             ingame.stop();
  1187.             Level_1.draw(RIP_Photo);
  1188.             death_flag = 1;
  1189.         }
  1190.  
  1191.  
  1192.         if ((GetXindx(player.getPosition().x) == GetXindx(White_Robot.getPosition().x) && GetYindx(player.getPosition().y) == GetYindx(White_Robot.getPosition().y))) {
  1193.             if (Clock_Damgae.getElapsedTime().asSeconds() >= 1) {
  1194.                 --player_status.lives;
  1195.                 Clock_Damgae.restart();
  1196.             }
  1197.             Level_1.draw(Hurt);
  1198.  
  1199.         }
  1200.  
  1201.         if (GetXindx(player.getPosition().x) == GetXindx(Yellow_Robot.getPosition().x) && GetYindx(player.getPosition().y) == GetYindx(Yellow_Robot.getPosition().y))
  1202.         {
  1203.             if (Clock_Damgae.getElapsedTime().asSeconds() >= 1) {
  1204.                 --player_status.lives;
  1205.                 Clock_Damgae.restart();
  1206.             }
  1207.             Level_1.draw(Hurt);
  1208.         }
  1209.  
  1210.         if (GetXindx(player.getPosition().x) == GetXindx(Skeleton.getPosition().x) && GetYindx(player.getPosition().y) == GetYindx(Skeleton.getPosition().y))
  1211.         {
  1212.             if (Clock_Damgae.getElapsedTime().asSeconds() >= 1) {
  1213.                 --player_status.lives;
  1214.                 Clock_Damgae.restart();
  1215.             }
  1216.             Level_1.draw(Hurt);
  1217.         }
  1218.  
  1219.         for (int i = 0; i < 2; i++) {
  1220.             Level_1.draw(timebombS[i]);
  1221.         }
  1222.  
  1223.         if (death_flag) {
  1224.             // player dead reactions
  1225.         }
  1226.            
  1227.        
  1228.    
  1229.        
  1230.         Level_1.draw(lifeS);
  1231.         Level_1.draw(rangeS);
  1232.         Level_1.draw(bombS);
  1233.         Level_1.display();
  1234.  
  1235.  
  1236.     }
  1237.  
  1238. }
  1239. void Advanced_Level()
  1240. {
  1241.     Music ingame; ingame.openFromFile("ingame.wav");
  1242.     ingame.play();
  1243.     //======================================================================//
  1244.                         // Making of Player //
  1245.     RectangleShape player(Vector2f(100, 120));
  1246.     Texture player_texture;
  1247.     Vector2u player_size;
  1248.     Clock player_clock;
  1249.     Time player_time;
  1250.     float player_position = 0;
  1251.     const int player_speed = 2;
  1252.     Generate_Charcter(player, player_texture, player_size, "mainplayer.png", 10, 2);
  1253.     //======================================================================//
  1254.     Texture healskill, bombskill, rangeskill;
  1255.     healskill.loadFromFile("Heal .png");
  1256.     bombskill.loadFromFile("bomb skill .png");
  1257.     rangeskill.loadFromFile("Range skill.png");
  1258.     Sprite healS2[3], bombskillS2[9], rangeskillS2[10];//superpowers level2
  1259.    
  1260.  
  1261.     //======================================================================//
  1262.                         // Player abilities //
  1263.  
  1264.     // Making of Grid
  1265.     Texture wall, ground, wallpaper, ground2, breakable, life, bomb, range, hurt, one, two, three, choice;
  1266.     if (!breakable.loadFromFile("breakable.png"))
  1267.     {
  1268.         cout << "error loading breakable wall pic";
  1269.     }
  1270.     if (!wallpaper.loadFromFile("wallpaper.jpg"))
  1271.     {
  1272.         cout << "error loading wallpaper pic";
  1273.     }
  1274.     if (!wall.loadFromFile("3d wall.png"))
  1275.     {
  1276.         cout << "error loading wall pic";
  1277.     }
  1278.  
  1279.     if (!ground.loadFromFile("ground 1.png"))
  1280.     {
  1281.         cout << "error loading ground pic";
  1282.     }
  1283.     if (!ground2.loadFromFile("grass.png"))
  1284.     {
  1285.         cout << "error loading grass pic";
  1286.     }
  1287.  
  1288.     if (!life.loadFromFile("flife.png"))
  1289.     {
  1290.         cout << "error loading life pic";
  1291.     }
  1292.     if (!range.loadFromFile("frange.png"))
  1293.     {
  1294.  
  1295.         cout << "error loading range pic";
  1296.     }
  1297.     if (!bomb.loadFromFile("fbomb.png"))
  1298.     {
  1299.         cout << "error loading bomb pic";
  1300.     }
  1301.  
  1302.     if (!hurt.loadFromFile("hurt.png"))
  1303.     {
  1304.         cout << "error loading  hurt pic";
  1305.     }
  1306.     if (!one.loadFromFile("one.png"))
  1307.     {
  1308.  
  1309.         cout << "error loading range pic";
  1310.     }
  1311.     if (!two.loadFromFile("two.png"))
  1312.     {
  1313.  
  1314.         cout << "error loading range pic";
  1315.     }
  1316.     if (!three.loadFromFile("three.png"))
  1317.     {
  1318.  
  1319.         cout << "error loading range pic";
  1320.     }
  1321.  
  1322.  
  1323.     life.setSmooth(1);
  1324.     bomb.setSmooth(1);
  1325.     hurt.setSmooth(1);
  1326.     range.setSmooth(1);
  1327.     // player stuff
  1328.     Clock Clock_Damgae;
  1329.     Sprite lifeS, bombS, rangeS, Hurt;
  1330.     lifeS.setTexture(life);
  1331.     lifeS.setPosition(0, 180);
  1332.     lifeS.setScale(0.3f, 0.3f);
  1333.  
  1334.     rangeS.setTexture(range);
  1335.     rangeS.setPosition(0, 250);
  1336.     rangeS.setScale(0.3f, 0.3f);
  1337.  
  1338.     bombS.setTexture(bomb);
  1339.     bombS.setPosition(0, 320);
  1340.     bombS.setScale(0.3f, 0.3f);
  1341.  
  1342.     Hurt.setTexture(hurt);
  1343.  
  1344.     //======================================================================//
  1345.  
  1346.     //======================================================================//
  1347.                      // Making of Yellow Robot //
  1348.  
  1349.     RectangleShape Yellow_Robot(Vector2f(100, 120));
  1350.     Texture Yellow_Robot_text;
  1351.     Vector2u Yellow_Robot_size;
  1352.     Clock Yellow_Robot_clock;
  1353.     Time Yellow_Robot_time;
  1354.     float Yellow_Robot_speed = 1;
  1355.     float Yellow_Robot_position = 0;
  1356.     int Yellow_Robot_Counter = 0;
  1357.     int Yellow_Robot_Rand_motion = rand() % 4 + 1;
  1358.     Generate_Charcter(Yellow_Robot, Yellow_Robot_text, Yellow_Robot_size, "yellow_robot.png", 10, 7);
  1359.     //======================================================================//
  1360.  
  1361.  
  1362.     //======================================================================//
  1363.                       // Making of White Robot //
  1364.  
  1365.     RectangleShape  White_Robot(Vector2f(100, 120));
  1366.     Texture  White_Robot_text;
  1367.     Vector2u  White_Robot_size;
  1368.     Clock  White_Robot_clock;
  1369.     Time  White_Robot_time;
  1370.     float White_Robot_speed = 1;
  1371.     float White_Robot_position = 0;
  1372.     int White_Robot_Counter = 0;
  1373.     int White_Robot_Rand_motion = rand() % 4 + 1;
  1374.     Generate_Charcter(White_Robot, White_Robot_text, White_Robot_size, "white_robot.png", 10, 2);
  1375.     //======================================================================//
  1376.  
  1377.  
  1378.     //======================================================================//
  1379.                 // Making of  Blue Skeleton  //
  1380.  
  1381.     RectangleShape Blue_Skeleton(Vector2f(100, 120));
  1382.     Texture Blue_Skeleton_text;
  1383.     Vector2u Blue_Skeleton_size;
  1384.     Clock Blue_Skeleton_clock;
  1385.     Time Blue_Skeleton_time;
  1386.     float Blue_Skeleton_speed = 0.5;
  1387.     float Blue_Skeleton_position = 0;
  1388.     Generate_Charcter(Blue_Skeleton, Blue_Skeleton_text, Blue_Skeleton_size, "smart_skeleton.png", 3, 7);
  1389.     //======================================================================//
  1390.  
  1391.  
  1392.  
  1393.     //======================================================================//
  1394.                     // Making of White Skeleton //  
  1395.  
  1396.     RectangleShape White_Skeleton(Vector2f(100, 120));
  1397.     Texture White_Skeleton_text;
  1398.     Vector2u White_Skeleton_text_size;
  1399.     Clock White_Skeleton_clock;
  1400.     Time White_Skeleton_time;
  1401.     float White_Skeleton_speed = 1;
  1402.     float  White_Skeleton_position = 0;
  1403.     int White_Skeleton_Counter = 0;
  1404.     int White_Skeleton_Rand_motion = rand() % 4 + 1;
  1405.     Generate_Charcter(White_Skeleton, White_Skeleton_text, White_Skeleton_text_size, "monster (5).png", 10, 2);
  1406.     //======================================================================//
  1407.  
  1408.  
  1409.     //###############################################################################
  1410.     // Movement stuff
  1411.     leftmovement left; rightmovement right; upmovement up; downmovement down;
  1412.     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;
  1413.     //###############################################################################
  1414.  
  1415.  
  1416.  
  1417.  
  1418.                        // Making of Grid //
  1419.     //======================================================================//
  1420.                        // MAP DEFINATION //
  1421.  
  1422.     Sprite Wallpaper;
  1423.     Wallpaper.setTexture(wallpaper);
  1424.     //======================================================================//
  1425.  
  1426.     //======================================================================//
  1427.           // Distribution of wall ,breakable and ground on the Grid //
  1428.  
  1429.  
  1430.     Sprite Grid[width + 1][length + 1];
  1431.  
  1432.     for (int i = 1; i <= width; i++)      //  Distribution of wall and ground
  1433.     {
  1434.         for (int j = 1; j <= length; j++)
  1435.         {
  1436.             if (i % 2 != 0 && j % 2 != 0)
  1437.             {
  1438.  
  1439.                 Grid[i][j].setTexture(wall);
  1440.                 Grid[i][j].setPosition((i + 1.97)*53.15, (j + 0.255) * 48);
  1441.                 Grid[i][j].setScale(Vector2f(0.1009, 0.165));
  1442.  
  1443.             }
  1444.  
  1445.             else if (i == 1 || i == width)
  1446.             {
  1447.                 Grid[i][j].setTexture(wall);
  1448.                 Grid[i][j].setPosition((i + 1.97)*53.15, (j + 0.255) * 48);
  1449.                 Grid[i][j].setScale(Vector2f(0.1009, 0.165));
  1450.             }
  1451.             else if (j == 1 || j == length)
  1452.             {
  1453.                 Grid[i][j].setTexture(wall);
  1454.                 Grid[i][j].setPosition((i + 1.97)*53.15, (j + 0.255) * 48);
  1455.                 Grid[i][j].setScale(Vector2f(0.1009, 0.165));
  1456.             }
  1457.             else
  1458.             {
  1459.                 if (i % 2 == j % 2) { Grid[i][j].setTexture(ground); }
  1460.                 else { Grid[i][j].setTexture(ground2); }
  1461.                 Grid[i][j].setPosition((i + 2) * 53, (j + 0.8) * 48);
  1462.                 Grid[i][j].setScale(0.1, 0.101);
  1463.             }
  1464.         }
  1465.     }
  1466.  
  1467.     for (int i = 1; i <= 40; i++)       //  Distribution of breakable
  1468.     {
  1469.         int x = rand() % 16 + 2, y = rand() % 9 + 2;
  1470.         if (x % 2 != 0 && y % 2 != 0)
  1471.         {
  1472.             x++;
  1473.         }
  1474.         Grid[x][y].setTexture(breakable);
  1475.         Grid[x][y].setPosition((x + 1.97)*53.15, (y + 0.255) * 48);
  1476.         Grid[x][y].setScale(Vector2f(0.1009, 0.165));
  1477.     }
  1478.  
  1479.  
  1480.  
  1481.     int l = 9;
  1482.     for (int i = 0; i < l; i++)
  1483.     {
  1484.  
  1485.         int x = rand() % 16 + 2, y = rand() % 8 + 2;
  1486.         if (Grid[x][y].getTexture() != &breakable || x % 2 != 0 || y % 2 == 0)
  1487.         {
  1488.  
  1489.             l++;
  1490.             continue;
  1491.  
  1492.         }
  1493.  
  1494.         rangeskillS2[l - i].setTexture(rangeskill);
  1495.         rangeskillS2[l - i].setScale(0.5, 0.3);
  1496.         rangeskillS2[l - i].setPosition((x + 2.065)*53.15, (y + 0.43)*50.5);
  1497.     }
  1498.     int f = 8;
  1499.     for (int i = 0; i < f; i++)
  1500.     {
  1501.  
  1502.         int x = rand() % 16 + 2, y = rand() % 8 + 2;
  1503.         if (Grid[x][y].getTexture() != &breakable || x % 2 != 0 || y % 2 == 0)
  1504.         {
  1505.  
  1506.             f++;
  1507.             continue;
  1508.  
  1509.         }
  1510.  
  1511.         bombskillS2[f - i].setTexture(bombskill);
  1512.         bombskillS2[f - i].setScale(0.5, 0.3);
  1513.         bombskillS2[f - i].setPosition((x + 2.065)*53.15, (y + 0.43)*50.5);
  1514.  
  1515.     }
  1516.  
  1517.     int h = 2;
  1518.     for (int i = 0; i < h; i++)
  1519.     {
  1520.  
  1521.         int x = rand() % 16 + 2, y = rand() % 8 + 2;
  1522.         if (Grid[x][y].getTexture() != &breakable || x % 2 != 0 || y % 2 == 0)
  1523.         {
  1524.  
  1525.             h++;
  1526.             continue;
  1527.  
  1528.         }
  1529.  
  1530.         healS2[h - i].setTexture(healskill);
  1531.         healS2[h - i].setScale(0.5, 0.3);
  1532.         healS2[h - i].setPosition((x + 2.065)*53.15, (y + 0.43)*50.5);
  1533.  
  1534.     }
  1535.  
  1536.     Texture Timer_Bomb;
  1537.     if (!Timer_Bomb.loadFromFile("time-bomb.png"))
  1538.     {
  1539.         cout << "fuckssssss" << endl;
  1540.     }
  1541.     Sprite TIMER_BOMB;
  1542.     TIMER_BOMB.setTexture(Timer_Bomb);
  1543.     TIMER_BOMB.setPosition(GetXpostion(2), GetYpostion(2));
  1544.     TIMER_BOMB.setScale(0.05, 0.05);
  1545.     //=======================================================================================//
  1546.  
  1547.     //=======================================================================================//
  1548.  
  1549.     RenderWindow window(VideoMode(1280, 768), "Advanced Level");
  1550.  
  1551.     while (window.isOpen())
  1552.     {
  1553.         //=======================================================================================//
  1554.                             // Random Movment of Yellow Robot //
  1555.         if (Yellow_Robot_Counter >= 5000)
  1556.         {
  1557.             Yellow_Robot_Rand_motion = rand() % 4 + 1;
  1558.             Yellow_Robot_Counter = 0;
  1559.         }
  1560.  
  1561.         if (Yellow_Robot_Rand_motion == 1)                                          // Moving UP => Rand_motion == 1
  1562.         {
  1563.             Yellow_Robot_Counter++;
  1564.             if (Grid[GetXindx(Yellow_Robot.getPosition().x)][GetYindx(Yellow_Robot.getPosition().y - 7)].getTexture() == &ground || Grid[GetXindx(Yellow_Robot.getPosition().x)][GetYindx(Yellow_Robot.getPosition().y - 7)].getTexture() == &ground2)
  1565.             {
  1566.                 Movement_Upward(Yellow_Robot, Yellow_Robot_time, Yellow_Robot_clock, Yellow_Robot_position, Yellow_Robot_size, Yellow_Robot_speed);
  1567.             }
  1568.             else
  1569.             {
  1570.                 Yellow_Robot_Counter = 5000;
  1571.             }
  1572.  
  1573.         }
  1574.         else if (Yellow_Robot_Rand_motion == 2)                                 // Moving Down => Rand_motion == 2
  1575.         {
  1576.             Yellow_Robot_Counter++;
  1577.             if (Grid[GetXindx(Yellow_Robot.getPosition().x)][GetYindx(Yellow_Robot.getPosition().y + 7)].getTexture() == &ground || Grid[GetXindx(Yellow_Robot.getPosition().x)][GetYindx(Yellow_Robot.getPosition().y + 7)].getTexture() == &ground2)
  1578.             {
  1579.                 Movement_Downward(Yellow_Robot, Yellow_Robot_time, Yellow_Robot_clock, Yellow_Robot_position, Yellow_Robot_size, Yellow_Robot_speed);
  1580.             }
  1581.  
  1582.             else
  1583.             {
  1584.                 Yellow_Robot_Counter = 5000;
  1585.             }
  1586.         }
  1587.  
  1588.  
  1589.         else if (Yellow_Robot_Rand_motion == 3)                                 // Moving Right => Rand_motion == 3
  1590.         {
  1591.             Yellow_Robot_Counter++;
  1592.             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)
  1593.             {
  1594.                 Movement_Right(Yellow_Robot, Yellow_Robot_time, Yellow_Robot_clock, Yellow_Robot_position, Yellow_Robot_size, Yellow_Robot_speed);
  1595.             }
  1596.             else
  1597.             {
  1598.                 Yellow_Robot_Counter = 5000;
  1599.             }
  1600.         }
  1601.  
  1602.  
  1603.         else if (Yellow_Robot_Rand_motion == 4)                                 // Moving Left => Rand_motion == 4
  1604.         {
  1605.             Yellow_Robot_Counter++;
  1606.             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)
  1607.             {
  1608.                 Movement_Left(Yellow_Robot, Yellow_Robot_time, Yellow_Robot_clock, Yellow_Robot_position, Yellow_Robot_size, Yellow_Robot_speed);
  1609.             }
  1610.             else
  1611.             {
  1612.                 Yellow_Robot_Counter = 5000;
  1613.             }
  1614.  
  1615.         }
  1616.         //=======================================================================================//
  1617.  
  1618.         //=======================================================================================//
  1619.                                 // Random Movment of White Robot //
  1620.         if (White_Robot_Counter >= 5000)
  1621.         {
  1622.             White_Robot_Rand_motion = rand() % 4 + 1;
  1623.             White_Robot_Counter = 0;
  1624.         }
  1625.  
  1626.         if (White_Robot_Rand_motion == 1)                                           // Moving UP => Rand_motion == 1
  1627.         {
  1628.             White_Robot_Counter++;
  1629.             if (Grid[GetXindx(White_Robot.getPosition().x)][GetYindx(White_Robot.getPosition().y - 7)].getTexture() == &ground || Grid[GetXindx(White_Robot.getPosition().x)][GetYindx(White_Robot.getPosition().y - 7)].getTexture() == &ground2)
  1630.             {
  1631.                 Movement_Upward(White_Robot, White_Robot_time, White_Robot_clock, White_Robot_position, White_Robot_size, White_Robot_speed);
  1632.             }
  1633.             else
  1634.             {
  1635.                 White_Robot_Counter = 5000;
  1636.             }
  1637.  
  1638.         }
  1639.         else if (White_Robot_Rand_motion == 2)                                  // Moving Down => Rand_motion == 2
  1640.         {
  1641.             White_Robot_Counter++;
  1642.             if (Grid[GetXindx(White_Robot.getPosition().x)][GetYindx(White_Robot.getPosition().y + 7)].getTexture() == &ground || Grid[GetXindx(White_Robot.getPosition().x)][GetYindx(White_Robot.getPosition().y + 7)].getTexture() == &ground2)
  1643.             {
  1644.                 Movement_Downward(White_Robot, White_Robot_time, White_Robot_clock, White_Robot_position, White_Robot_size, White_Robot_speed);
  1645.             }
  1646.  
  1647.             else
  1648.             {
  1649.                 White_Robot_Counter = 5000;
  1650.             }
  1651.         }
  1652.  
  1653.  
  1654.         else if (White_Robot_Rand_motion == 3)                                  // Moving Right => Rand_motion == 3
  1655.         {
  1656.             White_Robot_Counter++;
  1657.             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)
  1658.             {
  1659.                 Movement_Right(White_Robot, White_Robot_time, White_Robot_clock, White_Robot_position, White_Robot_size, White_Robot_speed);
  1660.             }
  1661.             else
  1662.             {
  1663.                 White_Robot_Counter = 5000;
  1664.             }
  1665.         }
  1666.  
  1667.  
  1668.         else if (White_Robot_Rand_motion == 4)                                  // Moving Left => Rand_motion == 4
  1669.         {
  1670.             White_Robot_Counter++;
  1671.             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)
  1672.             {
  1673.                 Movement_Left(White_Robot, White_Robot_time, White_Robot_clock, White_Robot_position, White_Robot_size, White_Robot_speed);
  1674.             }
  1675.             else
  1676.             {
  1677.                 White_Robot_Counter = 5000;
  1678.             }
  1679.  
  1680.         }
  1681.         //=======================================================================================//
  1682.  
  1683.  
  1684.         //=======================================================================================//
  1685.                             // Random Movment of White Skeleton //  
  1686.         if (White_Skeleton_Counter >= 5000)
  1687.         {
  1688.             White_Skeleton_Rand_motion = rand() % 4 + 1;
  1689.             White_Skeleton_Counter = 0;
  1690.         }
  1691.  
  1692.         if (White_Skeleton_Rand_motion == 1)                                            // Moving UP => Rand_motion == 1
  1693.         {
  1694.             White_Skeleton_Counter++;
  1695.             if (Grid[GetXindx(White_Skeleton.getPosition().x)][GetYindx(White_Skeleton.getPosition().y - 7)].getTexture() == &ground || Grid[GetXindx(White_Skeleton.getPosition().x)][GetYindx(White_Skeleton.getPosition().y - 7)].getTexture() == &ground2)
  1696.             {
  1697.                 Movement_Upward(White_Skeleton, White_Skeleton_time, White_Skeleton_clock, White_Skeleton_position, White_Skeleton_text_size, White_Skeleton_speed);
  1698.             }
  1699.             else
  1700.             {
  1701.                 White_Skeleton_Counter = 5000;
  1702.             }
  1703.  
  1704.         }
  1705.         else if (White_Skeleton_Rand_motion == 2)                                   // Moving Down => Rand_motion == 2
  1706.         {
  1707.             White_Skeleton_Counter++;
  1708.             if (Grid[GetXindx(White_Skeleton.getPosition().x)][GetYindx(White_Skeleton.getPosition().y + 7)].getTexture() == &ground || Grid[GetXindx(White_Skeleton.getPosition().x)][GetYindx(White_Skeleton.getPosition().y + 7)].getTexture() == &ground2)
  1709.             {
  1710.                 Movement_Downward(White_Skeleton, White_Skeleton_time, White_Skeleton_clock, White_Skeleton_position, White_Skeleton_text_size, White_Skeleton_speed);
  1711.             }
  1712.  
  1713.             else
  1714.             {
  1715.                 White_Skeleton_Counter = 5000;
  1716.             }
  1717.         }
  1718.  
  1719.  
  1720.         else if (White_Skeleton_Rand_motion == 3)                                   // Moving Right => Rand_motion == 3
  1721.         {
  1722.             White_Skeleton_Counter++;
  1723.             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)
  1724.             {
  1725.                 Movement_Right(White_Skeleton, White_Skeleton_time, White_Skeleton_clock, White_Skeleton_position, White_Skeleton_text_size, White_Skeleton_speed);
  1726.             }
  1727.             else
  1728.             {
  1729.                 White_Skeleton_Counter = 5000;
  1730.             }
  1731.         }
  1732.  
  1733.  
  1734.         else if (White_Skeleton_Rand_motion == 4)                                   // Moving Left => Rand_motion == 4
  1735.         {
  1736.             White_Skeleton_Counter++;
  1737.             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)
  1738.             {
  1739.                 Movement_Left(White_Skeleton, White_Skeleton_time, White_Skeleton_clock, White_Skeleton_position, White_Skeleton_text_size, White_Skeleton_speed);
  1740.             }
  1741.             else
  1742.             {
  1743.                 White_Skeleton_Counter = 5000;
  1744.             }
  1745.  
  1746.         }
  1747.         //=======================================================================================//
  1748.  
  1749.  
  1750.         //=======================================================================================//
  1751.                             // BFS Movement of Blue Skeleton
  1752.  
  1753.         BFS(GetXindx(player.getPosition().x), GetYindx(player.getPosition().y), GetXindx(Blue_Skeleton.getPosition().x), GetYindx(Blue_Skeleton.getPosition().y), Grid, ground, ground2);
  1754.         if (Smart_Skeleton_Movement.i == GetXindx(Blue_Skeleton.getPosition().x) && Smart_Skeleton_Movement.j - GetYindx(Blue_Skeleton.getPosition().y) == 1)
  1755.         {
  1756.             Movement_Downward(Blue_Skeleton, Blue_Skeleton_time, Blue_Skeleton_clock, Blue_Skeleton_position, Blue_Skeleton_size, Blue_Skeleton_speed); // Moving Downward
  1757.         }
  1758.         else if (Smart_Skeleton_Movement.i == GetXindx(Blue_Skeleton.getPosition().x) && Smart_Skeleton_Movement.j - GetYindx(Blue_Skeleton.getPosition().y) == -1)
  1759.         {
  1760.             Movement_Upward(Blue_Skeleton, Blue_Skeleton_time, Blue_Skeleton_clock, Blue_Skeleton_position, Blue_Skeleton_size, Blue_Skeleton_speed);       // Moving Upward
  1761.         }
  1762.         else if (Smart_Skeleton_Movement.i - GetXindx(Blue_Skeleton.getPosition().x) == 1 && Smart_Skeleton_Movement.j == GetYindx(Blue_Skeleton.getPosition().y))
  1763.         {
  1764.             Movement_Right(Blue_Skeleton, Blue_Skeleton_time, Blue_Skeleton_clock, Blue_Skeleton_position, Blue_Skeleton_size, Blue_Skeleton_speed);        // Moving Right
  1765.         }
  1766.         else if (Smart_Skeleton_Movement.i - GetXindx(Blue_Skeleton.getPosition().x) == -1 && Smart_Skeleton_Movement.j == GetYindx(Blue_Skeleton.getPosition().y))
  1767.         {
  1768.             Movement_Left(Blue_Skeleton, Blue_Skeleton_time, Blue_Skeleton_clock, Blue_Skeleton_position, Blue_Skeleton_size, Blue_Skeleton_speed);     // Moving Left
  1769.         }
  1770.  
  1771.         //=======================================================================================//
  1772.  
  1773.         //=======================================================================================//
  1774.         // Player Movement
  1775.         Player_xindx = (float)((float)(player.getPosition().x - 183) / 53 + 2);
  1776.         Player_yindx = (float)((float)(player.getPosition().y - 74) / 48 + 2);
  1777.         right.i = GetXindx(player.getPosition().x + 20); right.j = Player_yindx;
  1778.         left.i = GetXindx(player.getPosition().x - 20); left.j = Player_yindx;
  1779.         up.i = Player_xindx; up.j = GetYindx(player.getPosition().y - 7);
  1780.         down.i = Player_xindx; down.j = GetYindx(player.getPosition().y + 7);
  1781.  
  1782.         if (Keyboard::isKeyPressed(Keyboard::Key::Right) && (Grid[right.i][right.j].getTexture() == &ground || Grid[right.i][right.j].getTexture() == &ground2))      // Moving Right
  1783.         {
  1784.             Movement_Right(player, player_time, player_clock, player_position, player_size, player_speed);
  1785.         }
  1786.         else if (Keyboard::isKeyPressed(Keyboard::Key::Left) && (Grid[left.i][left.j].getTexture() == &ground || Grid[left.i][left.j].getTexture() == &ground2))         // Moving Left
  1787.         {
  1788.             Movement_Left(player, player_time, player_clock, player_position, player_size, player_speed);
  1789.         }
  1790.         else if (Keyboard::isKeyPressed(Keyboard::Key::Up) && (Grid[up.i][up.j].getTexture() == &ground || Grid[up.i][up.j].getTexture() == &ground2))           // Moving Up
  1791.         {
  1792.             Movement_Upward(player, player_time, player_clock, player_position, player_size, player_speed);
  1793.         }
  1794.         else if (Keyboard::isKeyPressed(Keyboard::Key::Down) && (Grid[down.i][down.j].getTexture() == &ground || Grid[down.i][down.j].getTexture() == &ground2))         // Moving Down
  1795.         {
  1796.             Movement_Downward(player, player_time, player_clock, player_position, player_size, player_speed);
  1797.         }
  1798.  
  1799.         //=======================================================================================//
  1800.  
  1801.  
  1802.         //=======================================================================================//
  1803.         Event event;
  1804.         while (window.pollEvent(event))
  1805.         {
  1806.             if (event.type == sf::Event::Closed || Keyboard::isKeyPressed(Keyboard::Enter))
  1807.                 window.close();
  1808.         }
  1809.         window.clear();
  1810.         // Drawing of the Wallpaper
  1811.         window.draw(Wallpaper);
  1812.  
  1813.         // Drawing of The Map //
  1814.  
  1815.     // super with player   
  1816.         for (int i = 0; i < 10; i++) {
  1817.             int sumP = 0; int sumR = 0;
  1818.             sumP = GetXindx(player.getPosition().x) + GetYindx(player.getPosition().y);
  1819.  
  1820.             sumR = GetXindx(rangeskillS2[i].getPosition().x) + GetYindx(rangeskillS2[i].getPosition().y);
  1821.  
  1822.             if (sumR == sumP + 1 && (GetXindx(rangeskillS2[i].getPosition().x) == GetXindx(player.getPosition().x))) {
  1823.  
  1824.                 rangeskillS2[i].setColor(Color::Transparent);
  1825.  
  1826.  
  1827.             }
  1828.         }
  1829.         for (int i = 0; i < 9; i++) {
  1830.             int sumP = 0; int sumB = 0;
  1831.             sumP = GetXindx(player.getPosition().x) + GetYindx(player.getPosition().y);
  1832.  
  1833.             sumB = GetXindx(bombskillS2[i].getPosition().x) + GetYindx(bombskillS2[i].getPosition().y);
  1834.             //cout << GetXindx(player.getPosition().x) << "\t" << GetYindx(player.getPosition().y) << endl;
  1835.             //cout << GetXindx(healS[i].getPosition().x) << "\t" << GetYindx(healS[i].getPosition().y) << endl;
  1836.  
  1837.             if (sumB == sumP + 1 && (GetXindx(bombskillS2[i].getPosition().x) == GetXindx(player.getPosition().x))) {
  1838.                 bombskillS2[i].setColor(Color::Transparent);
  1839.  
  1840.  
  1841.  
  1842.             }
  1843.         }
  1844.  
  1845.         for (int i = 0; i < 3; i++) {
  1846.             int sumP = 0; int sumH = 0;
  1847.             sumP = GetXindx(player.getPosition().x) + GetYindx(player.getPosition().y);
  1848.  
  1849.             sumH = GetXindx(healS2[i].getPosition().x) + GetYindx(healS2[i].getPosition().y);
  1850.  
  1851.             if (sumH == sumP + 1 && (GetXindx(healS2[i].getPosition().x) == GetXindx(player.getPosition().x))) {
  1852.  
  1853.                 healS2[i].setColor(Color::Transparent);
  1854.  
  1855.             }
  1856.         }
  1857. //=======================================================================================//
  1858.                         // Drawing of The Ground //
  1859.  
  1860.         for (int i = 2; i < width; i++)
  1861.         {
  1862.             for (int j = 2; j < length; j++)
  1863.             {
  1864.                 if (Grid[i][j].getTexture() == &ground || Grid[i][j].getTexture() == &ground2)
  1865.                 {
  1866.                     window.draw(Grid[i][j]);
  1867.                 }
  1868.             }
  1869.  
  1870.         }
  1871.  
  1872.         //=======================================================================================//
  1873.  
  1874.         //=======================================================================================//
  1875.                                     // Drawing of Wall and Breakable //
  1876.         for (int j = 1; j <= length; j++)
  1877.         {
  1878.             for (int i = 1; i <= width; i++)
  1879.             {
  1880.                 if (Grid[i][j].getTexture() == &ground || Grid[i][j].getTexture() == &ground2)
  1881.                 {
  1882.                     continue;
  1883.                 }
  1884.  
  1885.                 window.draw(Grid[i][j]);
  1886.  
  1887.                 if (GetYindx(player.getPosition().y) >= j)              // Drawing of Player //
  1888.                 {
  1889.                     window.draw(player);
  1890.                 }
  1891.                 if (GetYindx(White_Robot.getPosition().y) >= j)         // Drawing of White_Robot //
  1892.                 {
  1893.                     window.draw(White_Robot);
  1894.                 }
  1895.                 if (GetYindx(Yellow_Robot.getPosition().y) >= j)        // Drawing of Yellow_Robot //
  1896.                 {
  1897.                     window.draw(Yellow_Robot);
  1898.                 }
  1899.                 if (GetYindx(White_Skeleton.getPosition().y) >= j)      // Drawing of White_Skeleton //
  1900.                 {
  1901.                     window.draw(White_Skeleton);
  1902.                 }
  1903.                 if (GetYindx(Blue_Skeleton.getPosition().y) >= j)       // Drawing of Blue_Skeleton //
  1904.                 {
  1905.                     window.draw(Blue_Skeleton);
  1906.                 }
  1907.             }
  1908.         }
  1909.         //=======================================================================================//
  1910.         for (int i = 0; i < 10; i++) {
  1911.             window.draw(rangeskillS2[i]);
  1912.         }
  1913.         for (int i = 0; i < 9; i++) {
  1914.             window.draw(bombskillS2[i]);
  1915.         }
  1916.         for (int i = 0; i < 3; i++) {
  1917.             window.draw(healS2[i]);
  1918.         }
  1919.        
  1920.         // player damage
  1921.         if (GetXindx(player.getPosition().x) == GetXindx(White_Robot.getPosition().x) && GetYindx(player.getPosition().y) == GetYindx(White_Robot.getPosition().y))
  1922.         {
  1923.             if (Clock_Damgae.getElapsedTime().asSeconds() >= 1) {
  1924.                 --player_status.lives;
  1925.                 Clock_Damgae.restart();
  1926.             }
  1927.             window.draw(Hurt);
  1928.  
  1929.         }
  1930.  
  1931.         if (GetXindx(player.getPosition().x) == GetXindx(White_Robot.getPosition().x) && GetYindx(player.getPosition().y) == GetYindx(White_Robot.getPosition().y))
  1932.         {
  1933.             if (Clock_Damgae.getElapsedTime().asSeconds() >= 1) {
  1934.                 --player_status.lives;
  1935.                 Clock_Damgae.restart();
  1936.             }
  1937.             window.draw(Hurt);
  1938.         }
  1939.  
  1940.         if (GetXindx(player.getPosition().x) == GetXindx(Blue_Skeleton.getPosition().x) && GetYindx(player.getPosition().y) == GetYindx(Blue_Skeleton.getPosition().y))
  1941.         {
  1942.             if (Clock_Damgae.getElapsedTime().asSeconds() >= 1) {
  1943.                 --player_status.lives;
  1944.                 Clock_Damgae.restart();
  1945.             }
  1946.             window.draw(Hurt);
  1947.         }
  1948.  
  1949.         if (GetXindx(player.getPosition().x) == GetXindx(Yellow_Robot.getPosition().x) && GetYindx(player.getPosition().y) == GetYindx(Yellow_Robot.getPosition().y))
  1950.         {
  1951.             if (Clock_Damgae.getElapsedTime().asSeconds() >= 1) {
  1952.                 --player_status.lives;
  1953.                 Clock_Damgae.restart();
  1954.             }
  1955.             window.draw(Hurt);
  1956.         }
  1957.  
  1958.         cout << player_status.lives << endl;
  1959.         window.draw(TIMER_BOMB);
  1960.         window.draw(lifeS);
  1961.         window.draw(rangeS);
  1962.         window.draw(bombS);
  1963.         window.display();
  1964.     }
  1965. }
  1966. void Legendary_Mode() {
  1967.    
  1968.     Music ingame; ingame.openFromFile("ingame.wav");
  1969.     ingame.play();
  1970.     //###############################################################################
  1971.     // Making of Player
  1972.     RectangleShape player(Vector2f(100, 120));
  1973.     Texture player_texture;
  1974.     Vector2u player_size;
  1975.     Clock player_clock;
  1976.     Time player_time;
  1977.     float player_position = 0;
  1978.     const int player_speed = 2;
  1979.     Generate_Charcter(player, player_texture, player_size, "mainplayer.png", 10, 2);
  1980.     //###############################################################################
  1981.  
  1982.     //###############################################################################
  1983.     // Making of Red_Monster(Smart)
  1984.     RectangleShape Red_Robot(Vector2f(100, 120));
  1985.     Texture Red_Robot_texture;
  1986.     Vector2u Red_Robot_size;
  1987.     Clock Red_Robot_clock;
  1988.     Time Red_Robot_time;
  1989.     float Red_Robot_position = 0;
  1990.     float Red_Robot_Speed = 0.6;
  1991.     Generate_Charcter(Red_Robot, Red_Robot_texture, Red_Robot_size, "red_robot.png", 10, 2);
  1992.     //###############################################################################
  1993.  
  1994.     //###############################################################################
  1995.     // Making of Blue_Skeleton(smart)
  1996.     RectangleShape Blue_Skeleton(Vector2f(100, 120));
  1997.     Texture Blue_Skeleton_text;
  1998.     Vector2u Blue_Skeleton_text_size;
  1999.     Clock Blue_Skeleton_clock;
  2000.     Time Blue_Skeleton_time;
  2001.     float Blue_Skeleton_speed = 0.3;
  2002.     float Blue_Skeleton_position = 0;
  2003.     Generate_Charcter(Blue_Skeleton, Blue_Skeleton_text, Blue_Skeleton_text_size, "smart_skeleton.png", 10, 2);
  2004.     //###############################################################################
  2005.  
  2006.     //###############################################################################
  2007.     // Making of Skeleton
  2008.     RectangleShape Skeleton(Vector2f(100, 120));
  2009.     Texture Skeleton_texture;
  2010.     Vector2u Skeleton_size;
  2011.     Clock Skeleton_clock;
  2012.     Time Skeleton_time;
  2013.     int Skeleton_Rand_motion = rand() % 4 + 1;
  2014.     int Skeleton_counter = 0;
  2015.     float Skeleton_position = 0;
  2016.     Generate_Charcter(Skeleton, Skeleton_texture, Skeleton_size, "monster (5).png", 7, 8);
  2017.     //###############################################################################
  2018.  
  2019.     //###############################################################################
  2020.     // Making of White_Robot
  2021.     RectangleShape White_Robot(Vector2f(100, 120));
  2022.     Texture White_Robot_texture;
  2023.     Vector2u White_Robot_size;
  2024.     Clock White_Robot_clock;
  2025.     Time White_Robot_time;
  2026.     int White_Robot_Rand_motion = rand() % 4 + 1;
  2027.     int White_Robot_counter = 0;
  2028.     float White_Robot_position = 0;
  2029.     Generate_Charcter(White_Robot, White_Robot_texture, White_Robot_size, "white_robot.png", 14, 8);
  2030.     //###############################################################################
  2031.  
  2032.     //###############################################################################
  2033.     // Movement stuff
  2034.     leftmovement left; rightmovement right; upmovement up; downmovement down;
  2035.     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;
  2036.     //###############################################################################
  2037.  
  2038.  // Making of Grid
  2039.     Texture wall, ground, wallpaper, ground2, breakable, life, bomb, range, hurt, one, two, three, choice;
  2040.     if (!breakable.loadFromFile("breakable.png"))
  2041.     {
  2042.         cout << "error loading breakable wall pic";
  2043.     }
  2044.     if (!wallpaper.loadFromFile("wallpaper.jpg"))
  2045.     {
  2046.         cout << "error loading wallpaper pic";
  2047.     }
  2048.     if (!wall.loadFromFile("3d wall.png"))
  2049.     {
  2050.         cout << "error loading wall pic";
  2051.     }
  2052.  
  2053.     if (!ground.loadFromFile("ground 1.png"))
  2054.     {
  2055.         cout << "error loading ground pic";
  2056.     }
  2057.     if (!ground2.loadFromFile("grass.png"))
  2058.     {
  2059.         cout << "error loading grass pic";
  2060.     }
  2061.  
  2062.     if (!life.loadFromFile("flife.png"))
  2063.     {
  2064.         cout << "error loading life pic";
  2065.     }
  2066.     if (!range.loadFromFile("frange.png"))
  2067.     {
  2068.  
  2069.         cout << "error loading range pic";
  2070.     }
  2071.     if (!bomb.loadFromFile("fbomb.png"))
  2072.     {
  2073.         cout << "error loading bomb pic";
  2074.     }
  2075.  
  2076.     if (!hurt.loadFromFile("hurt.png"))
  2077.     {
  2078.         cout << "error loading  hurt pic";
  2079.     }
  2080.     if (!one.loadFromFile("one.png"))
  2081.     {
  2082.  
  2083.         cout << "error loading range pic";
  2084.     }
  2085.     if (!two.loadFromFile("two.png"))
  2086.     {
  2087.  
  2088.         cout << "error loading range pic";
  2089.     }
  2090.     if (!three.loadFromFile("three.png"))
  2091.     {
  2092.  
  2093.         cout << "error loading range pic";
  2094.     }
  2095.  
  2096.     Texture timebomb;
  2097.     timebomb.loadFromFile("time-bomb.png");
  2098.     Sprite timebombS[2];
  2099.  
  2100.  
  2101.     life.setSmooth(1);
  2102.     bomb.setSmooth(1);
  2103.     hurt.setSmooth(1);
  2104.     range.setSmooth(1);
  2105.  
  2106.  
  2107.     //###############################################################################
  2108.     // Player abilities
  2109.     Sprite lifeS, bombS, rangeS, Hurt, Wallpaper;
  2110.     lifeS.setTexture(life);
  2111.     lifeS.setPosition(0, 180);
  2112.     lifeS.setScale(0.4, 0.4);
  2113.  
  2114.     rangeS.setTexture(range);
  2115.     rangeS.setPosition(0, 250);
  2116.     rangeS.setScale(0.4, 0.4);
  2117.  
  2118.     bombS.setTexture(bomb);
  2119.     bombS.setPosition(0, 330);
  2120.     bombS.setScale(0.4, 0.4);
  2121.  
  2122.     Hurt.setTexture(hurt);
  2123.     Wallpaper.setTexture(wallpaper);
  2124.     // Numbers
  2125.     Clock Clock_Damgae;
  2126.     //###############################################################################
  2127.  
  2128.  
  2129.     // Distribution of wall & ground on the Grid
  2130.  
  2131.     Sprite Grid[width + 1][length + 1];
  2132.  
  2133.     for (int i = 1; i <= width; i++)
  2134.     {
  2135.         for (int j = 1; j <= length; j++)
  2136.         {
  2137.             if (i % 2 != 0 && j % 2 != 0)
  2138.             {
  2139.  
  2140.                 Grid[i][j].setTexture(wall);
  2141.                 Grid[i][j].setPosition((i + 1.97)*53.15, (j + 0.255) * 48);
  2142.                 Grid[i][j].setScale(Vector2f(0.1009, 0.165));
  2143.  
  2144.             }
  2145.  
  2146.             else if (i == 1 || i == width)
  2147.             {
  2148.                 Grid[i][j].setTexture(wall);
  2149.                 Grid[i][j].setPosition((i + 1.97)*53.15, (j + 0.255) * 48);
  2150.                 Grid[i][j].setScale(Vector2f(0.1009, 0.165));
  2151.             }
  2152.             else if (j == 1 || j == length)
  2153.             {
  2154.                 Grid[i][j].setTexture(wall);
  2155.                 Grid[i][j].setPosition((i + 1.97)*53.15, (j + 0.255) * 48);
  2156.                 Grid[i][j].setScale(Vector2f(0.1009, 0.165));
  2157.             }
  2158.             else
  2159.             {
  2160.                 if (i % 2 == j % 2) { Grid[i][j].setTexture(ground); }
  2161.                 else { Grid[i][j].setTexture(ground2); }
  2162.                 Grid[i][j].setPosition((i + 2) * 53, (j + 0.8) * 48);
  2163.                 Grid[i][j].setScale(0.1, 0.101);
  2164.             }
  2165.         }
  2166.     }
  2167.  
  2168.  
  2169.  
  2170.     for (int i = 1; i <= 30; i++)
  2171.     {
  2172.         int x = rand() % 15 + 2, y = rand() % 9 + 2;
  2173.         if (x % 2 != 0 && y % 2 != 0)
  2174.         {
  2175.             x++;
  2176.         }
  2177.         Grid[x][y].setTexture(breakable);
  2178.         Grid[x][y].setPosition((x + 1.97)*53.15, (y + 0.255) * 48);
  2179.         Grid[x][y].setScale(Vector2f(0.1009, 0.165));
  2180.     }
  2181.  
  2182.     int z = 1;
  2183.     for (int i = 0; i < z; i++)
  2184.     {
  2185.  
  2186.         int x = rand() % 16 + 2, y = rand() % 8 + 2;
  2187.         if (Grid[x][y].getTexture() != &breakable || x % 2 != 0 || y % 2 == 0)
  2188.         {
  2189.  
  2190.             z++;
  2191.             continue;
  2192.  
  2193.         }
  2194.  
  2195.         timebombS[z - i].setTexture(timebomb);
  2196.         timebombS[z - i].setScale(0.05, 0.05);
  2197.         //  timebombS[z - i].setPosition((x + 2.065)*53.15, (y + 0.43)*50.5);
  2198.         timebombS[z - i].setPosition(GetXpostion(2), GetYpostion(2));
  2199.  
  2200.     }
  2201.     //###############################################################################
  2202.     // Game Window
  2203.     RenderWindow Level_3(VideoMode(1280, 768), "Fuck");
  2204.     while (Level_3.isOpen())
  2205.     {
  2206.  
  2207.         // Player Movement
  2208.         Player_xindx = (float)((float)(player.getPosition().x - 183) / 53 + 2);
  2209.         Player_yindx = (float)((float)(player.getPosition().y - 74) / 48 + 2);
  2210.         right.i = GetXindx(player.getPosition().x + 20); right.j = Player_yindx;
  2211.         left.i = GetXindx(player.getPosition().x - 20); left.j = Player_yindx;
  2212.         up.i = Player_xindx; up.j = GetYindx(player.getPosition().y - 7);
  2213.         down.i = Player_xindx; down.j = GetYindx(player.getPosition().y + 7);
  2214.  
  2215.         if (Keyboard::isKeyPressed(Keyboard::Key::Right) && (Grid[right.i][right.j].getTexture() == &ground || Grid[right.i][right.j].getTexture() == &ground2))      // Moving Right
  2216.         {
  2217.             Movement_Right(player, player_time, player_clock, player_position, player_size, player_speed);
  2218.         }
  2219.         else if (Keyboard::isKeyPressed(Keyboard::Key::Left) && (Grid[left.i][left.j].getTexture() == &ground || Grid[left.i][left.j].getTexture() == &ground2))         // Moving Left
  2220.         {
  2221.             Movement_Left(player, player_time, player_clock, player_position, player_size, player_speed);
  2222.         }
  2223.         else if (Keyboard::isKeyPressed(Keyboard::Key::Up) && (Grid[up.i][up.j].getTexture() == &ground || Grid[up.i][up.j].getTexture() == &ground2))           // Moving Up
  2224.         {
  2225.             Movement_Upward(player, player_time, player_clock, player_position, player_size, player_speed);
  2226.         }
  2227.         else if (Keyboard::isKeyPressed(Keyboard::Key::Down) && (Grid[down.i][down.j].getTexture() == &ground || Grid[down.i][down.j].getTexture() == &ground2))         // Moving Down
  2228.         {
  2229.             Movement_Downward(player, player_time, player_clock, player_position, player_size, player_speed);
  2230.         }
  2231.  
  2232.         //######################################################################################################
  2233.  
  2234.  
  2235.  
  2236.         //######################################################################################################
  2237.         // Smart_Skeleton movement
  2238.         Blue_Skeleton_xindx = (float)((float)(Blue_Skeleton.getPosition().x - 183) / 53 + 2);
  2239.         Blue_Skeleton_yindx = (float)((float)(Blue_Skeleton.getPosition().y - 74) / 48 + 2);
  2240.         right.i = GetXindx(Blue_Skeleton.getPosition().x + 20); right.j = Blue_Skeleton_yindx;
  2241.         left.i = GetXindx(Blue_Skeleton.getPosition().x - 20); left.j = Blue_Skeleton_yindx;
  2242.         up.i = Blue_Skeleton_xindx; up.j = GetYindx(Blue_Skeleton.getPosition().y - 7);
  2243.         down.i = Blue_Skeleton_xindx; down.j = GetYindx(Blue_Skeleton.getPosition().y + 7);
  2244.  
  2245.         // Call BFS
  2246.         BFS(Player_xindx, Player_yindx, Blue_Skeleton_xindx, Blue_Skeleton_yindx, Grid, ground, ground2);
  2247.  
  2248.         // Movement
  2249.         if (Smart_Skeleton_Movement.i == Blue_Skeleton_xindx && Smart_Skeleton_Movement.j - Blue_Skeleton_yindx == 1) {
  2250.             Movement_Downward(Blue_Skeleton, Blue_Skeleton_time, Blue_Skeleton_clock, Blue_Skeleton_position, Blue_Skeleton_text_size, Blue_Skeleton_speed);    // Moving Downward
  2251.         }
  2252.         else if (Smart_Skeleton_Movement.i == Blue_Skeleton_xindx && Smart_Skeleton_Movement.j - Blue_Skeleton_yindx == -1) {
  2253.             Movement_Upward(Blue_Skeleton, Blue_Skeleton_time, Blue_Skeleton_clock, Blue_Skeleton_position, Blue_Skeleton_text_size, Blue_Skeleton_speed);      // Moving Upward
  2254.         }
  2255.         else if (Smart_Skeleton_Movement.i - Blue_Skeleton_xindx == 1 && Smart_Skeleton_Movement.j == Blue_Skeleton_yindx) {
  2256.             Movement_Right(Blue_Skeleton, Blue_Skeleton_time, Blue_Skeleton_clock, Blue_Skeleton_position, Blue_Skeleton_text_size, Blue_Skeleton_speed);       // Moving Right
  2257.         }
  2258.         else if (Smart_Skeleton_Movement.i - Blue_Skeleton_xindx == -1 && Smart_Skeleton_Movement.j == Blue_Skeleton_yindx) {
  2259.             Movement_Left(Blue_Skeleton, Blue_Skeleton_time, Blue_Skeleton_clock, Blue_Skeleton_position, Blue_Skeleton_text_size, Blue_Skeleton_speed);        // Moving Left
  2260.         }
  2261.  
  2262.         //######################################################################################################
  2263.  
  2264.  
  2265.         //######################################################################################################
  2266.         // Red_Robot movement
  2267.         Red_Robot_xindx = (float)((float)(Red_Robot.getPosition().x - 183) / 53 + 2);
  2268.         Red_Robot_yindx = (float)((float)(Red_Robot.getPosition().y - 74) / 48 + 2);
  2269.         right.i = GetXindx(Red_Robot.getPosition().x + 20); right.j = Red_Robot_yindx;
  2270.         left.i = GetXindx(Red_Robot.getPosition().x - 20); left.j = Red_Robot_yindx;
  2271.         up.i = Red_Robot_xindx; up.j = GetYindx(Red_Robot.getPosition().y - 7);
  2272.         down.i = Red_Robot_xindx; down.j = GetYindx(Red_Robot.getPosition().y + 7);
  2273.  
  2274.         // Call BFS
  2275.         BFS(Player_xindx, Player_yindx, Red_Robot_xindx, Red_Robot_yindx, Grid, ground, ground2);
  2276.  
  2277.         // Movement
  2278.         if (Red_Robot_Movement.i == Red_Robot_xindx && Red_Robot_Movement.j - Red_Robot_yindx == 1) {
  2279.             Movement_Downward(Red_Robot, Red_Robot_time, Red_Robot_clock, Red_Robot_position, Red_Robot_size, Red_Robot_Speed); // Moving Downward
  2280.         }
  2281.         else if (Red_Robot_Movement.i == Red_Robot_xindx && Red_Robot_Movement.j - Red_Robot_yindx == -1) {
  2282.             Movement_Upward(Red_Robot, Red_Robot_time, Red_Robot_clock, Red_Robot_position, Red_Robot_size, Red_Robot_Speed);   // Moving Upward
  2283.         }
  2284.         else if (Red_Robot_Movement.i - Red_Robot_xindx == 1 && Red_Robot_Movement.j == Red_Robot_yindx) {
  2285.             Movement_Right(Red_Robot, Red_Robot_time, Red_Robot_clock, Red_Robot_position, Red_Robot_size, Red_Robot_Speed);    // Movement Right
  2286.         }
  2287.         else if (Red_Robot_Movement.i - Red_Robot_xindx == -1 && Red_Robot_Movement.j == Red_Robot_yindx) {
  2288.             Movement_Left(Red_Robot, Red_Robot_time, Red_Robot_clock, Red_Robot_position, Red_Robot_size, Red_Robot_Speed); // Moving left
  2289.         }
  2290.  
  2291.         //######################################################################################################
  2292.  
  2293.  
  2294.  
  2295.  
  2296.         // Skeleton movement
  2297.         Skeleton_xindx = (float)((float)(Skeleton.getPosition().x - 183) / 53 + 2);
  2298.         Skeleton_yindx = (float)((float)(Skeleton.getPosition().y - 74) / 48 + 2);
  2299.         right.i = GetXindx(Skeleton.getPosition().x + 20); right.j = Skeleton_yindx;
  2300.         left.i = GetXindx(Skeleton.getPosition().x - 20); left.j = Skeleton_yindx;
  2301.         up.i = Skeleton_xindx; up.j = GetYindx(Skeleton.getPosition().y - 7);
  2302.         down.i = Skeleton_xindx; down.j = GetYindx(Skeleton.getPosition().y + 7);
  2303.         //######################################################################################################
  2304.  
  2305.         //######################################################################################################
  2306.         // Skeleton Movement
  2307.         if (Skeleton_counter >= 250)
  2308.         {
  2309.             Skeleton_Rand_motion = rand() % 4 + 1;
  2310.             Skeleton_counter = 0;
  2311.         }
  2312.  
  2313.         if (Skeleton_Rand_motion == 1)                                          // Moving UP => Rand_motion == 1
  2314.         {
  2315.             Skeleton_counter++;
  2316.             if (Grid[up.i][up.j].getTexture() == &ground || Grid[up.i][up.j].getTexture() == &ground2)
  2317.             {
  2318.  
  2319.                 Movement_Upward(Skeleton, Skeleton_time, Skeleton_clock, Skeleton_position, Skeleton_size, Random_Monsters_Speed);
  2320.  
  2321.             }
  2322.             else
  2323.             {
  2324.                 Skeleton_counter = 250;
  2325.             }
  2326.  
  2327.         }
  2328.  
  2329.  
  2330.         else if (Skeleton_Rand_motion == 2)                                 // Moving Down => Rand_motion == 2
  2331.         {
  2332.             Skeleton_counter++;
  2333.             if (Grid[down.i][down.j].getTexture() == &ground || Grid[down.i][down.j].getTexture() == &ground2)
  2334.             {
  2335.                 Movement_Downward(Skeleton, Skeleton_time, Skeleton_clock, Skeleton_position, Skeleton_size, Random_Monsters_Speed);
  2336.  
  2337.             }
  2338.  
  2339.             else
  2340.             {
  2341.                 Skeleton_counter = 250;
  2342.             }
  2343.         }
  2344.  
  2345.  
  2346.         else if (Skeleton_Rand_motion == 3)                                 // Moving Right => Rand_motion == 3
  2347.         {
  2348.             Skeleton_counter++;
  2349.             if (Grid[right.i][right.j].getTexture() == &ground || Grid[right.i][right.j].getTexture() == &ground2)
  2350.             {
  2351.                 Movement_Right(Skeleton, Skeleton_time, Skeleton_clock, Skeleton_position, Skeleton_size, Random_Monsters_Speed);
  2352.  
  2353.             }
  2354.             else
  2355.             {
  2356.                 Skeleton_counter = 250;
  2357.             }
  2358.         }
  2359.  
  2360.  
  2361.         else if (Skeleton_Rand_motion == 4)                                 // Moving Left => Rand_motion == 4
  2362.         {
  2363.             Skeleton_counter++;
  2364.             if (Grid[left.i][left.j].getTexture() == &ground || Grid[left.i][left.j].getTexture() == &ground2)
  2365.             {
  2366.                 Movement_Left(Skeleton, Skeleton_time, Skeleton_clock, Skeleton_position, Skeleton_size, Random_Monsters_Speed);
  2367.  
  2368.             }
  2369.             else
  2370.             {
  2371.                 Skeleton_counter = 250;
  2372.             }
  2373.  
  2374.         }
  2375.  
  2376.         //######################################################################################################
  2377.         // White_Robot movement
  2378.         White_Robot_xindx = (float)((float)(White_Robot.getPosition().x - 183) / 53 + 2);
  2379.         White_Robot_yindx = (float)((float)(White_Robot.getPosition().y - 74) / 48 + 2);
  2380.         right.i = GetXindx(White_Robot.getPosition().x + 20); right.j = White_Robot_yindx;
  2381.         left.i = GetXindx(White_Robot.getPosition().x - 20); left.j = White_Robot_yindx;
  2382.         up.i = White_Robot_xindx; up.j = GetYindx(White_Robot.getPosition().y - 7);
  2383.         down.i = White_Robot_xindx; down.j = GetYindx(White_Robot.getPosition().y + 7);
  2384.         //######################################################################################################
  2385.  
  2386.         //######################################################################################################
  2387.         // White_Robot Movement
  2388.         if (White_Robot_counter >= 250)
  2389.         {
  2390.             White_Robot_Rand_motion = rand() % 4 + 1;
  2391.             White_Robot_counter = 0;
  2392.         }
  2393.  
  2394.         if (White_Robot_Rand_motion == 1)                                           // Moving UP => Rand_motion == 1
  2395.         {
  2396.             White_Robot_counter++;
  2397.             if (Grid[up.i][up.j].getTexture() == &ground || Grid[up.i][up.j].getTexture() == &ground2)
  2398.             {
  2399.  
  2400.                 Movement_Upward(White_Robot, White_Robot_time, White_Robot_clock, White_Robot_position, White_Robot_size, Random_Monsters_Speed);
  2401.  
  2402.             }
  2403.             else
  2404.             {
  2405.                 White_Robot_counter = 250;
  2406.             }
  2407.  
  2408.         }
  2409.  
  2410.  
  2411.         else if (White_Robot_Rand_motion == 2)                                  // Moving Down => Rand_motion == 2
  2412.         {
  2413.             White_Robot_counter++;
  2414.             if (Grid[down.i][down.j].getTexture() == &ground || Grid[down.i][down.j].getTexture() == &ground2)
  2415.             {
  2416.                 Movement_Downward(White_Robot, White_Robot_time, White_Robot_clock, White_Robot_position, White_Robot_size, Random_Monsters_Speed);
  2417.             }
  2418.  
  2419.             else
  2420.             {
  2421.                 White_Robot_counter = 250;
  2422.             }
  2423.         }
  2424.  
  2425.  
  2426.         else if (White_Robot_Rand_motion == 3)                                  // Moving Right => Rand_motion == 3
  2427.         {
  2428.             White_Robot_counter++;
  2429.             if (Grid[right.i][right.j].getTexture() == &ground || Grid[right.i][right.j].getTexture() == &ground2)
  2430.             {
  2431.                 Movement_Right(White_Robot, White_Robot_time, White_Robot_clock, White_Robot_position, White_Robot_size, Random_Monsters_Speed);
  2432.             }
  2433.             else
  2434.             {
  2435.                 White_Robot_counter = 250;
  2436.             }
  2437.         }
  2438.  
  2439.  
  2440.         else if (White_Robot_Rand_motion == 4)                                  // Moving Left => Rand_motion == 4
  2441.         {
  2442.             White_Robot_counter++;
  2443.             if (Grid[left.i][left.j].getTexture() == &ground || Grid[left.i][left.j].getTexture() == &ground2)
  2444.             {
  2445.                 Movement_Left(White_Robot, White_Robot_time, White_Robot_clock, White_Robot_position, White_Robot_size, Random_Monsters_Speed);
  2446.             }
  2447.             else
  2448.             {
  2449.                 White_Robot_counter = 250;
  2450.             }
  2451.  
  2452.         }
  2453.  
  2454.         //######################################################################################################
  2455.  
  2456.  
  2457.  
  2458.         Event event;
  2459.         while (Level_3.pollEvent(event))
  2460.         {
  2461.             if (event.type == sf::Event::Closed || Keyboard::isKeyPressed(Keyboard::Enter))
  2462.                 Level_3.close();
  2463.  
  2464.         }
  2465.         Level_3.clear();
  2466.  
  2467.         // Drawing of the Wallpaper
  2468.         Level_3.draw(Wallpaper);
  2469.  
  2470.         //Drawing of The Map
  2471.         for (int i = 2; i < width; i++)
  2472.         {
  2473.             for (int j = 2; j < length; j++)
  2474.             {
  2475.                 if (Grid[i][j].getTexture() == &ground || Grid[i][j].getTexture() == &ground2)
  2476.                 {
  2477.                     Level_3.draw(Grid[i][j]);
  2478.                 }
  2479.             }
  2480.  
  2481.         }
  2482.  
  2483.         for (int j = 1; j <= length; j++)
  2484.         {
  2485.             for (int i = 1; i <= width; i++)
  2486.             {
  2487.                 if (Grid[i][j].getTexture() == &ground || Grid[i][j].getTexture() == &ground2)
  2488.                 {
  2489.                     continue;
  2490.                 }
  2491.  
  2492.                 Level_3.draw(Grid[i][j]);
  2493.  
  2494.                 if (GetYindx(player.getPosition().y) >= j)
  2495.                 {
  2496.                     Level_3.draw(player);
  2497.                 }
  2498.  
  2499.                 if (GetYindx(Skeleton.getPosition().y) >= j)
  2500.                 {
  2501.                     Level_3.draw(Skeleton);
  2502.                 }
  2503.  
  2504.                 if (GetYindx(White_Robot.getPosition().y) >= j)
  2505.                 {
  2506.                     Level_3.draw(White_Robot);
  2507.                 }
  2508.  
  2509.                 if (GetYindx(Blue_Skeleton.getPosition().y) >= j)
  2510.                 {
  2511.                     Level_3.draw(Blue_Skeleton);
  2512.                 }
  2513.  
  2514.                 if (GetYindx(Red_Robot.getPosition().y) >= j)
  2515.                 {
  2516.                     Level_3.draw(Red_Robot);
  2517.                 }
  2518.             }
  2519.         }
  2520.         if (player_status.lives == 2) {
  2521.            
  2522.         }
  2523.         else if (player_status.lives == 1) {
  2524.         }
  2525.         else if (player_status.lives <= 0) {
  2526.             // start lay lay (you are fucked up)
  2527.             // show game over screen
  2528.             // what else ?!!
  2529.             cout << "you are fucked uppp" << endl;
  2530.         }
  2531.  
  2532.  
  2533.         // player damage
  2534.         if (GetXindx(player.getPosition().x) == GetXindx(White_Robot.getPosition().x) && GetYindx(player.getPosition().y) == GetYindx(White_Robot.getPosition().y))
  2535.         {
  2536.             if (Clock_Damgae.getElapsedTime().asSeconds() >= 1) {
  2537.                 --player_status.lives;
  2538.                 Clock_Damgae.restart();
  2539.             }
  2540.             Level_3.draw(Hurt);
  2541.  
  2542.         }
  2543.  
  2544.         if (GetXindx(player.getPosition().x) == GetXindx(Skeleton.getPosition().x) && GetYindx(player.getPosition().y) == GetYindx(Skeleton.getPosition().y))
  2545.         {
  2546.             if (Clock_Damgae.getElapsedTime().asSeconds() >= 1) {
  2547.                 --player_status.lives;
  2548.                 Clock_Damgae.restart();
  2549.             }
  2550.             Level_3.draw(Hurt);
  2551.         }
  2552.  
  2553.         if (GetXindx(player.getPosition().x) == GetXindx(Blue_Skeleton.getPosition().x) && GetYindx(player.getPosition().y) == GetYindx(Blue_Skeleton.getPosition().y))
  2554.         {
  2555.             if (Clock_Damgae.getElapsedTime().asSeconds() >= 1) {
  2556.                 --player_status.lives;
  2557.                 Clock_Damgae.restart();
  2558.             }
  2559.             Level_3.draw(Hurt);
  2560.         }
  2561.  
  2562.         if (GetXindx(player.getPosition().x) == GetXindx(Red_Robot.getPosition().x) && GetYindx(player.getPosition().y) == GetYindx(Red_Robot.getPosition().y))
  2563.         {
  2564.             if (Clock_Damgae.getElapsedTime().asSeconds() >= 1) {
  2565.                 --player_status.lives;
  2566.                 Clock_Damgae.restart();
  2567.             }
  2568.             Level_3.draw(Hurt);
  2569.         }
  2570.  
  2571.         cout << player_status.lives << endl;
  2572.         for (int i = 0; i < 2; i++)
  2573.         {
  2574.             Level_3.draw(timebombS[i]);
  2575.         }
  2576.         Level_3.draw(lifeS);
  2577.         Level_3.draw(rangeS);
  2578.         Level_3.draw(bombS);
  2579.         Level_3.display();
  2580.  
  2581.  
  2582.     }
  2583.  
  2584. }
  2585.  
  2586. void Multiplayer()
  2587. {
  2588.  
  2589.     Font dis_time;
  2590.     if (!dis_time.loadFromFile("Chocolate Bar Demo.otf"))
  2591.     {
  2592.         cout << "error font";
  2593.     }
  2594.     //timer stuff
  2595.     int display_timer;
  2596.     Clock c, timer_clock;
  2597.     Time times, timer;
  2598.     //map stuff
  2599.     Texture wall, ground, wallpaper, ground2, breakable, zone_warning_text, hurt;
  2600.     Texture death;
  2601.     Sprite Death;
  2602.     if (!death.loadFromFile("death.png"))
  2603.         cout << "error to load death " << endl;
  2604.  
  2605.     Death.setTexture(death);
  2606.     // songs load
  2607.     Music ingame; ingame.openFromFile("ingame.wav");
  2608.     ingame.play();
  2609.     Music lost;
  2610.     lost.openFromFile("For the Damaged Coda.wav");
  2611.     // zone stuff
  2612.     Sprite zone_warning_sprt, Hurt;
  2613.     if (!zone_warning_text.loadFromFile("zone.png")) {
  2614.         cout << "error to load zone " << endl;
  2615.     }
  2616.     zone_warning_sprt.setTexture(zone_warning_text);
  2617.     zone_warning_sprt.setScale(0.5, 0.5);
  2618.     zone_warning_sprt.setPosition(440, 520);
  2619.     int zone_limit = 1;
  2620.     if (!breakable.loadFromFile("breakable.png")) {
  2621.         cout << "error to load breakable " << endl;
  2622.     }
  2623.     if (!hurt.loadFromFile("hurt.png")) {
  2624.         cout << "error to load breakable " << endl;
  2625.     }
  2626.     Hurt.setTexture(hurt);
  2627.     if (!wallpaper.loadFromFile("wallpaper.jpg")) {
  2628.         cout << "error to load wallpaper " << endl;
  2629.     }
  2630.  
  2631.     if (!wall.loadFromFile("3d wall.png")) {
  2632.         cout << "error to load 3d wall " << endl;
  2633.     }
  2634.     if (!ground.loadFromFile("ground 1.png")) {
  2635.         cout << "error to load ground " << endl;
  2636.     }
  2637.  
  2638.  
  2639.  
  2640.  
  2641.     if (!ground2.loadFromFile("grass.png")) {
  2642.         cout << "error to load grass " << endl;
  2643.     }
  2644.  
  2645.  
  2646.     Sprite lifeS, rangeS, bombS, Wallpaper;
  2647.  
  2648.     Wallpaper.setTexture(wallpaper);
  2649.  
  2650.  
  2651.     // Distribution of wall & ground on the Grid
  2652.  
  2653.     const int length = 9, width = 17;
  2654.  
  2655.     Sprite Grid[width + 1][length + 1];
  2656.  
  2657.     for (int i = 1; i <= width; i++)
  2658.     {
  2659.         for (int j = 1; j <= length; j++)
  2660.         {
  2661.             if (i % 2 != 0 && j % 2 != 0)
  2662.             {
  2663.  
  2664.                 Grid[i][j].setTexture(wall);
  2665.                 Grid[i][j].setPosition((i + 1.97) * 53, (j + 0.255) * 48);
  2666.                 Grid[i][j].setScale(Vector2f(0.1009, 0.165));
  2667.  
  2668.             }
  2669.  
  2670.             else if (i == 1 || i == width)
  2671.             {
  2672.                 Grid[i][j].setTexture(wall);
  2673.                 Grid[i][j].setPosition((i + 1.97) * 53, (j + 0.255) * 48);
  2674.                 Grid[i][j].setScale(Vector2f(0.1009, 0.165));
  2675.             }
  2676.             else if (j == 1 || j == length)
  2677.             {
  2678.                 Grid[i][j].setTexture(wall);
  2679.                 Grid[i][j].setPosition((i + 1.97) * 53, (j + 0.255) * 48);
  2680.                 Grid[i][j].setScale(Vector2f(0.1009, 0.165));
  2681.             }
  2682.             else
  2683.             {
  2684.                 if (i % 2 == j % 2)
  2685.                 {
  2686.                     Grid[i][j].setTexture(ground);
  2687.                 }
  2688.                 else
  2689.                 {
  2690.                     Grid[i][j].setTexture(ground2);
  2691.                 }
  2692.                 Grid[i][j].setPosition((i + 2) * 53, (j + 0.8) * 48);
  2693.                 Grid[i][j].setScale(0.1009, 0.101);
  2694.             }
  2695.         }
  2696.     }
  2697.     for (int i = 1; i <= 30; i++)
  2698.     {
  2699.         int x = rand() % 14 + 2, y = rand() % 7 + 2;
  2700.         if (x % 2 != 0 && y % 2 != 0)
  2701.         {
  2702.             x++;
  2703.         }
  2704.         Grid[x][y].setTexture(breakable);
  2705.         Grid[x][y].setPosition((x + 1.97) * 53, (y + 0.255) * 48);
  2706.         Grid[x][y].setScale(Vector2f(0.1009, 0.165));
  2707.     }
  2708.  
  2709.     // player 1 creation
  2710.     const int players_speed = 2;
  2711.     //###############################################################################
  2712.     // Making of Player1
  2713.     RectangleShape player1(Vector2f(100, 120));
  2714.     Texture player1_texture;
  2715.     Vector2u player1_size;
  2716.     Clock player1_clock;
  2717.     Time player1_time;
  2718.     float player1_position = 0;
  2719.     Generate_Charcter(player1, player1_texture, player1_size, "mainplayer.png", 2, 2);
  2720.  
  2721.     //###############################################################################
  2722.   // Making of Player2
  2723.     RectangleShape player2(Vector2f(100, 120));
  2724.     Texture player2_texture;
  2725.     Vector2u player2_size;
  2726.     Clock player2_clock;
  2727.     Time player2_time;
  2728.     float player2_position = 0;
  2729.     Generate_Charcter(player2, player2_texture, player2_size, "mainplayer.png", 10, 2);
  2730.  
  2731.  
  2732.     //###############################################################################
  2733.    // Movement stuff
  2734.     leftmovement left; rightmovement right; upmovement up; downmovement down;
  2735.     int player1_xindx = 0, player1_yindx = 0, player2_xindx = 0, player2_yindx = 0;
  2736.     //###############################################################################
  2737.  
  2738.  
  2739.  
  2740.     //bomb stuff
  2741.  
  2742.     Time times2, t, ti;
  2743.     Clock clocks2, cs, clocks;
  2744.  
  2745.     Time music_time;
  2746.     Clock music_clock;
  2747.  
  2748.     int death_music_duration = 0;
  2749.  
  2750.     bool death_flag = 0;
  2751.     //Game Window
  2752.     RenderWindow window(VideoMode(1280, 768), "our first try with SFML");
  2753.     while (window.isOpen())
  2754.     {
  2755.  
  2756.  
  2757.  
  2758.         Event event;
  2759.         while (window.pollEvent(event))
  2760.         {
  2761.             if (event.type == sf::Event::Closed || Keyboard::isKeyPressed(Keyboard::Enter))
  2762.                 window.close();
  2763.         }
  2764.  
  2765.  
  2766.         if (Keyboard::isKeyPressed(Keyboard::N))
  2767.         {
  2768.             death_flag = 1;
  2769.             music_clock.restart();
  2770.             lost.play();
  2771.         }
  2772.  
  2773.         music_time = music_clock.getElapsedTime();
  2774.         death_music_duration = music_time.asSeconds();
  2775.  
  2776.  
  2777.  
  2778.  
  2779.         // Timer
  2780.         Text txt;
  2781.         timer = timer_clock.getElapsedTime();
  2782.         display_timer = timer.asSeconds();
  2783.         string s1, s2;
  2784.         //int  minu=display_timer/60;
  2785.         s1 = to_string(30 - (display_timer));
  2786.         //s2=to_string(1-minu);
  2787.         //s2+=" : ";
  2788.         //s2+=s1;
  2789.  
  2790.         txt.setFont(dis_time);
  2791.         txt.setString("0:" + s1);
  2792.         txt.setPosition(512, 22);
  2793.  
  2794.  
  2795.         if (display_timer >= 30)
  2796.         {
  2797.             timer_clock.restart();
  2798.  
  2799.  
  2800.             for (int j = 2; j < length; j++)
  2801.             {
  2802.                 Grid[zone_limit + 1][j].setTexture(wall);
  2803.  
  2804.                 Grid[width - zone_limit][j].setTexture(wall);
  2805.  
  2806.                 Grid[zone_limit + 1][j].setPosition((zone_limit + 1 + 1.97) * 53, (j + 0.255) * 48);
  2807.  
  2808.                 if ((GetXindx(player1.getPosition().x)) == zone_limit + 1) {
  2809.                     death_flag = 1;
  2810.                     music_clock.restart();
  2811.                     ingame.stop();
  2812.                     lost.play();
  2813.                 }
  2814.  
  2815.                 if ((GetXindx(player2.getPosition().x)) == zone_limit + 1) {
  2816.                     death_flag = 1;
  2817.                     music_clock.restart();
  2818.                     ingame.stop();
  2819.                     lost.play();
  2820.                 }
  2821.  
  2822.                 Grid[width - zone_limit][j].setPosition((width - zone_limit + 1.97) * 53, (j + 0.255) * 48);
  2823.  
  2824.                 Grid[zone_limit + 1][j].setScale(Vector2f(0.1009, 0.165));
  2825.  
  2826.                 Grid[width - zone_limit][j].setScale(Vector2f(0.1009, 0.165));
  2827.  
  2828.  
  2829.  
  2830.                 if ((GetXindx(player1.getPosition().x)) == width - zone_limit) {
  2831.                     death_flag = 1;
  2832.                     music_clock.restart();
  2833.                     ingame.stop();
  2834.                     lost.play();
  2835.  
  2836.                 }
  2837.  
  2838.                 if ((GetXindx(player2.getPosition().x)) == width - zone_limit) {
  2839.                     death_flag = 1;
  2840.                     music_clock.restart();
  2841.                     ingame.stop();
  2842.                     lost.play();
  2843.  
  2844.                 }
  2845.  
  2846.  
  2847.  
  2848.  
  2849.  
  2850.  
  2851.             }
  2852.             zone_limit++;
  2853.         }
  2854.  
  2855.  
  2856.  
  2857.  
  2858.  
  2859.         // player1 1 Movement
  2860.         player1_xindx = (float)((float)(player1.getPosition().x - 183) / 53 + 2);
  2861.         player1_yindx = (float)((float)(player1.getPosition().y - 74) / 48 + 2);
  2862.         right.i = GetXindx(player1.getPosition().x + 20); right.j = player1_yindx;
  2863.         left.i = GetXindx(player1.getPosition().x - 20); left.j = player1_yindx;
  2864.         up.i = player1_xindx; up.j = GetYindx(player1.getPosition().y - 7);
  2865.         down.i = player1_xindx; down.j = GetYindx(player1.getPosition().y + 7);
  2866.  
  2867.         if (Keyboard::isKeyPressed(Keyboard::Key::Right) && (Grid[right.i][right.j].getTexture() == &ground || Grid[right.i][right.j].getTexture() == &ground2))      // Moving Right
  2868.         {
  2869.             Movement_Right(player1, player1_time, player1_clock, player1_position, player1_size, players_speed);
  2870.         }
  2871.         else if (Keyboard::isKeyPressed(Keyboard::Key::Left) && (Grid[left.i][left.j].getTexture() == &ground || Grid[left.i][left.j].getTexture() == &ground2))         // Moving Left
  2872.         {
  2873.             Movement_Left(player1, player1_time, player1_clock, player1_position, player1_size, players_speed);
  2874.         }
  2875.         else if (Keyboard::isKeyPressed(Keyboard::Key::Up) && (Grid[up.i][up.j].getTexture() == &ground || Grid[up.i][up.j].getTexture() == &ground2))           // Moving Up
  2876.         {
  2877.             Movement_Upward(player1, player1_time, player1_clock, player1_position, player1_size, players_speed);
  2878.         }
  2879.         else if (Keyboard::isKeyPressed(Keyboard::Key::Down) && (Grid[down.i][down.j].getTexture() == &ground || Grid[down.i][down.j].getTexture() == &ground2))         // Moving Down
  2880.         {
  2881.             Movement_Downward(player1, player1_time, player1_clock, player1_position, player1_size, players_speed);
  2882.         }
  2883.        
  2884.  
  2885.         // Player 2 Movement
  2886.         player2_xindx = (float)((float)(player2.getPosition().x - 183) / 53 + 2);
  2887.         player2_yindx = (float)((float)(player2.getPosition().y - 74) / 48 + 2);
  2888.         right.i = GetXindx(player2.getPosition().x + 20); right.j = player2_yindx;
  2889.         left.i = GetXindx(player2.getPosition().x - 20); left.j = player2_yindx;
  2890.         up.i = player2_xindx; up.j = GetYindx(player2.getPosition().y - 7);
  2891.         down.i = player2_xindx; down.j = GetYindx(player2.getPosition().y + 7);
  2892.  
  2893.         if (Keyboard::isKeyPressed(Keyboard::Key::D) && (Grid[right.i][right.j].getTexture() == &ground || Grid[right.i][right.j].getTexture() == &ground2))      // Moving Right
  2894.         {
  2895.             Movement_Right(player2, player2_time, player2_clock, player2_position, player2_size, players_speed);
  2896.         }
  2897.         else if (Keyboard::isKeyPressed(Keyboard::Key::A) && (Grid[left.i][left.j].getTexture() == &ground || Grid[left.i][left.j].getTexture() == &ground2))         // Moving Left
  2898.         {
  2899.             Movement_Left(player2, player2_time, player2_clock, player2_position, player2_size, players_speed);
  2900.         }
  2901.         else if (Keyboard::isKeyPressed(Keyboard::Key::W) && (Grid[up.i][up.j].getTexture() == &ground || Grid[up.i][up.j].getTexture() == &ground2))           // Moving Up
  2902.         {
  2903.             Movement_Upward(player2, player2_time, player2_clock, player2_position, player2_size, players_speed);
  2904.         }
  2905.         else if (Keyboard::isKeyPressed(Keyboard::Key::S) && (Grid[down.i][down.j].getTexture() == &ground || Grid[down.i][down.j].getTexture() == &ground2))         // Moving Down
  2906.         {
  2907.             Movement_Downward(player2, player2_time, player2_clock, player2_position, player2_size, players_speed);
  2908.         }
  2909.  
  2910.    
  2911.  
  2912.         window.clear();
  2913.         // Drawing of the Wallpaper
  2914.         window.draw(Wallpaper);
  2915.  
  2916.         //Drawing of The Map
  2917.         for (int i = 2; i < width; i++)
  2918.         {
  2919.             for (int j = 2; j < length; j++)
  2920.             {
  2921.                 if (Grid[i][j].getTexture() == &ground || Grid[i][j].getTexture() == &ground2)
  2922.                 {
  2923.                     window.draw(Grid[i][j]);
  2924.                 }
  2925.             }
  2926.  
  2927.         }
  2928.  
  2929.         for (int j = 1; j <= length; j++)
  2930.         {
  2931.             for (int i = 1; i <= width; i++)
  2932.             {
  2933.                 if (Grid[i][j].getTexture() == &ground || Grid[i][j].getTexture() == &ground2)
  2934.                 {
  2935.                     continue;
  2936.                 }
  2937.  
  2938.                 window.draw(Grid[i][j]);
  2939.  
  2940.                 if (GetYindx(player1.getPosition().y) >= j)
  2941.                 {
  2942.                     window.draw(player1);
  2943.                 }
  2944.  
  2945.  
  2946.                 if (GetYindx(player2.getPosition().y) >= j)
  2947.                 {
  2948.                     window.draw(player2);
  2949.                 }
  2950.             }
  2951.         }
  2952.  
  2953.         window.draw(txt);
  2954.         if (display_timer >= 25)
  2955.         {
  2956.             window.draw(zone_warning_sprt); window.draw(Hurt);
  2957.         }
  2958.         //window.draw(Death);
  2959.         if (death_flag && death_music_duration <= 16) {
  2960.             window.draw(Death);
  2961.             if (death_music_duration == 16)
  2962.                 exit(0);
  2963.         }
  2964.         //if (death_flag && death_music_duration>16) {exit(0);}
  2965.         window.display();
  2966.  
  2967.     }
  2968.  
  2969.  
  2970.  
  2971. }
  2972. int main()
  2973. {
  2974.     Music outgame; outgame.openFromFile("Main menu.wav");
  2975.     outgame.play();
  2976.     //###############################################################################
  2977.     // Menu Shits
  2978.     RenderWindow background(VideoMode(1024, 680), "Fuck");
  2979.     setmenustatus(background.getSize().x, background.getSize().y);
  2980.     Texture backgroundwall;
  2981.     backgroundwall.loadFromFile("FantasyLand.png");
  2982.     Sprite Menuwall; Menuwall.setTexture(backgroundwall);
  2983.     //Menu choices
  2984.     Sprite Choice, Choice2;
  2985.     Texture choice;
  2986.     if (!choice.loadFromFile("Untitled-1-Recovered.png"))
  2987.     {
  2988.         cout << "choice not found";
  2989.     }
  2990.     Choice.setTexture(choice);
  2991.     Choice.setPosition(0, 415);
  2992.     Choice.setScale(0.3, 0.27);
  2993.  
  2994.     Choice2.setTexture(choice);
  2995.     Choice2.setPosition(1024 - (0.3 * 1307), 315);
  2996.     Choice2.setScale(0.3, 0.27);
  2997.     //###############################################################################
  2998.    
  2999.     bool singleplayer = 0;
  3000.  
  3001.     while (background.isOpen())
  3002.     {
  3003.         // Menu choices Animation
  3004.         if (Choice.getPosition().x < 310)
  3005.         {
  3006.             Choice.move(0.5, 0);
  3007.         }
  3008.         if (Choice2.getPosition().x > 310)
  3009.         {
  3010.             Choice2.move(-0.5, 0);
  3011.         }
  3012.  
  3013.         Event evnt;
  3014.         while (background.pollEvent(evnt))
  3015.         {
  3016.             switch (evnt.type)
  3017.             {
  3018.             case sf::Event::KeyReleased:
  3019.                 switch (evnt.key.code)
  3020.                 {
  3021.                 case sf::Keyboard::Up:
  3022.                     MoveUp();
  3023.                     break;
  3024.  
  3025.                 case sf::Keyboard::Down:
  3026.                     MoveDown();
  3027.                     break;
  3028.  
  3029.                 case sf::Keyboard::Return:
  3030.                     switch (GetPressedItem())
  3031.                     {
  3032.                     case 0:
  3033.                         singleplayer = 1;
  3034.                         background.close();
  3035.                         break;
  3036.                     case 1:
  3037.                         outgame.stop();
  3038.                         background.close();
  3039.                         Multiplayer();
  3040.                         break;
  3041.                     case 2:
  3042.                         cout << "About Us button has been pressed \n";
  3043.                     case 3:
  3044.                         background.close();
  3045.                         //window.close();
  3046.                         return(0);
  3047.                         break;
  3048.                     }
  3049.  
  3050.                     break;
  3051.                 }
  3052.  
  3053.                 break;
  3054.             case Event::Closed:
  3055.                 background.close();
  3056.                 return 0;
  3057.                 break;
  3058.             }
  3059.         }
  3060.  
  3061.         if ((Mouse::isButtonPressed(Mouse::Left)) && (Mouse::getPosition().x >= 615 && Mouse::getPosition().x <= 680)) {
  3062.             background.close();
  3063.             break;
  3064.  
  3065.         }
  3066.         background.clear();
  3067.         background.draw(Menuwall);
  3068.         background.draw(Choice);
  3069.         background.draw(Choice2);
  3070.         drawmenu(background);
  3071.         background.display();
  3072.  
  3073.     }
  3074.     RenderWindow levels(VideoMode(1024, 680), "levels");
  3075.     setlevelsstatus(levels.getSize().x, levels.getSize().y);
  3076.     Texture levelwall;
  3077.     levelwall.loadFromFile("levelwall.png");
  3078.     Sprite levelwallS; levelwallS.setTexture(levelwall);
  3079.     Choice2.setPosition(1024 - (0.3 * 1307), 315); Choice.setPosition(0, 415);
  3080.     while (levels.isOpen()&&singleplayer)
  3081.     {
  3082.         // Menu choices Animation
  3083.         if (Choice.getPosition().x < 310)
  3084.         {
  3085.             Choice.move(0.5, 0);
  3086.         }
  3087.         if (Choice2.getPosition().x > 310)
  3088.         {
  3089.             Choice2.move(-0.5, 0);
  3090.         }
  3091.  
  3092.         Event evntlev;
  3093.         while (levels.pollEvent(evntlev))
  3094.         {
  3095.             switch (evntlev.type)
  3096.             {
  3097.             case Event::KeyReleased:
  3098.                 switch (evntlev.key.code)
  3099.                 {
  3100.                 case Keyboard::Up:
  3101.                     MoveUplev();
  3102.                     break;
  3103.  
  3104.                 case Keyboard::Down:
  3105.                     MoveDownlev();
  3106.                     break;
  3107.  
  3108.                 case Keyboard::Return:
  3109.                     switch (GetPressedlevel())
  3110.                     {
  3111.                     case 0:
  3112.                         outgame.stop();
  3113.                         levels.close();
  3114.                         Beginner_Mode();
  3115.                         break;
  3116.                     case 1:
  3117.                         outgame.stop();
  3118.                         levels.close();
  3119.                         Advanced_Level();
  3120.                         break;
  3121.                     case 2:
  3122.                         outgame.stop();
  3123.                         levels.close();
  3124.                         Legendary_Mode();
  3125.                         break;
  3126.                     }
  3127.  
  3128.                     break;
  3129.                 }
  3130.  
  3131.                 break;
  3132.             case Event::Closed:
  3133.                 background.close();
  3134.                 return 0;
  3135.                 break;
  3136.             }
  3137.  
  3138.  
  3139.         }
  3140.         if ((Mouse::isButtonPressed(Mouse::Left)) && (Mouse::getPosition().x >= 615 && Mouse::getPosition().x <= 680)) {
  3141.             background.close();
  3142.             break;
  3143.  
  3144.         }
  3145.  
  3146.         levels.clear();
  3147.         levels.draw(levelwallS);
  3148.         levels.draw(Choice);
  3149.         levels.draw(Choice2);
  3150.         drawlev(levels);
  3151.         levels.display();
  3152.  
  3153.     }
  3154.  
  3155.  
  3156.  
  3157.  
  3158. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement