Advertisement
Guest User

Untitled

a guest
Mar 25th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 13.00 KB | None | 0 0
  1. #include <iostream>
  2. #include <conio.h>
  3. #include <windows.h>
  4. #include <string>
  5.  
  6.  
  7. const int h = 20;
  8. const int w = 20;
  9.    char town[w][h]   ={{'#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#'},
  10.                        {'#','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','#'},
  11.                        {'#','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','#'},
  12.                        {'#','.','.','.','.','.','.','.','.','H','.','.','.','.','.','.','.','.','.','#'},
  13.                        {'#','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','#'},
  14.                        {'#','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','S','.','#'},
  15.                        {'#','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','#'},
  16.                        {'#','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','#'},
  17.                        {'#','.','.','.','.','.','.','#','#','#','#','#','.','.','.','.','.','.','.','#'},
  18.                        {'#','T','.','.','.','.','.','#','~','~','~','#','.','.','.','.','.','Z','.','#'},
  19.                        {'#','T','.','.','.','.','.','#','~','~','~','#','.','.','.','.','.','.','.','#'},
  20.                        {'#','.','.','.','.','.','.','#','#','#','#','#','.','.','.','.','.','.','.','#'},
  21.                        {'#','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','#'},
  22.                        {'#','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','#'},
  23.                        {'#','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','#'},
  24.                        {'#','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','K','.','#'},
  25.                        {'#','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','#'},
  26.                        {'#','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','#'},
  27.                        {'#','.','.','.','.','.','.','G','.','.','G','.','.','.','.','.','.','.','.','#'},
  28.                        {'#','#','#','#','#','#','#','#','D','D','#','#','#','#','#','#','#','#','#','#'}};
  29.  
  30.       char pub[w][h]= {{'#','#','#','#','#','#','#','#','#','D','D','#','#','#','#','#','#','#','#','#'},
  31.                        {'#','.','.','.','#','.','.','.','.','.','.','.','.','#','.','.','.','.','.','#'},
  32.                        {'#','.','.','.','#','.','.','.','.','.','.','.','.','#','.','.','.','.','.','#'},
  33.                        {'#','.','.','.','#','.','.','.','B','.','.','.','.','#','.','.','.','.','.','#'},
  34.                        {'#','.','.','.','#','#','#','#','#','#','#','#','#','#','.','.','.','.','.','#'},
  35.                        {'#','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','#'},
  36.                        {'#','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','#'},
  37.                        {'#','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','#'},
  38.                        {'#','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','#'},
  39.                        {'#','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','#'},
  40.                        {'#','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','#'},
  41.                        {'#','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','#'},
  42.                        {'#','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','#'},
  43.                        {'#','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','#'},
  44.                        {'#','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','#'},
  45.                        {'#','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','#'},
  46.                        {'#','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','#'},
  47.                        {'#','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','#'},
  48.                        {'#','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','#'},
  49.                        {'#','#','#','#','#','#','#','#','#','G','G','#','#','#','#','#','#','#','#','#'}};
  50.  
  51. char button;
  52. int time = 3000;
  53. int playerArea = 1;
  54. struct Creation
  55. {
  56.     int age;
  57.     int strength;
  58.     int agility;
  59.     int inteligent;
  60.     std::string kingdom;
  61.     std::string name;
  62.     int x = 8;
  63.     int y = 18;
  64. };
  65.  
  66. Creation player;
  67.  
  68.  
  69. void character()
  70. {
  71.     std::cout << "Welcome in ToroTomo!" << std::endl;
  72.     Sleep(time);
  73.     system("cls");
  74.     std::cout << "I think you have arrived here on.." << std::endl;
  75.     Sleep(time);
  76.     system("cls");
  77.     std::cout << "GLADIATOR TOURNAMENT!!" << std::endl;
  78.     Sleep(time);
  79.     system("cls");
  80.     std::cout << "Alright, what is your name?" << std::endl;
  81.     std::cin >> player.name;
  82.     system("cls");
  83.     std::cout << "My name is " << player.name << std::endl;
  84.     Sleep(time);
  85.     system("cls");
  86.     std::cout << "Your age?" <<std::endl;
  87.     std::cin >> player.age;
  88.     Sleep(time);
  89.     system("cls");
  90.     std::cout << "So " << player.name << " from which kingdom you are?" << std::endl;
  91.     std::cout << std::endl;
  92.     std::cin >> player.kingdom;
  93.     system("cls");
  94.     std::cout << "I'm from " << player.kingdom << std::endl;
  95.     Sleep(time);
  96.     system("cls");
  97.     std::cout << "Now take this list and fill it" << std::endl;
  98.     Sleep(time);
  99.     system("cls");
  100.     int points = 13;
  101.     int str = 0;
  102.     int inte = 0;
  103.     int agil = 0;
  104.     do
  105.     {
  106.         std::cout << "You have "<< points << " points to expand" << std::endl;
  107.         std::cout << "Press 1 - 3 to add points" << std::endl;
  108.         std::cout << "**********************************************" << std::endl;
  109.         std::cout << "1.Strength = " << player.strength << std::endl;
  110.         std::cout << "2.Intelligent = " << player.inteligent << std::endl;
  111.         std::cout << "3.Agility = " << player.agility << std::endl;
  112.         std::cout << "5.Age = " << player.age << std::endl;
  113.         std::cout << "6.Name = " << player.name << std::endl;
  114.         std::cout << "7.Kingdom = " << player.kingdom << std::endl;
  115.         button = getch();
  116.         switch(button)
  117.         {
  118.         case '1':
  119.             {
  120.                 system("cls");
  121.                 std::cout << "How strong you are?" << std::endl;
  122.                 std::cout << "Remember you have only " << points << " points" << std::endl;
  123.                 std::cin >> str;
  124.                 if(str > points)
  125.                 {
  126.                     std::cout << "Only "<< points << " points!!" << std::endl;
  127.                     break;
  128.                 } else if(str <= points )
  129.                 {
  130.                     player.strength = str;
  131.                     points -= str;
  132.                 }
  133.                 break;
  134.             }
  135.         case '2':
  136.             {
  137.                 system("cls");
  138.                 std::cout << "How strong your brain is?" <<std::endl;
  139.                 std::cout << "Remember you have only " << points << " points" << std::endl;
  140.                 std::cin >> inte;
  141.                 if(inte > points)
  142.                 {
  143.                     std::cout << "Only " << points << " points!!" << std::endl;
  144.                     break;
  145.                 } else if(inte <= points )
  146.                 {
  147.                     player.inteligent = inte;
  148.                     points -= inte;
  149.                 }
  150.                 break;
  151.             }
  152.         case '3':
  153.             {
  154.                 system("cls");
  155.                 std::cout << "How fast your legs move?" <<std::endl;
  156.                 std::cout << "Remember you have only " << points << " points" << std::endl;
  157.                 std::cin >> agil;
  158.                 if(inte > agil)
  159.                 {
  160.                     std::cout << "Only " << points << " points!!" << std::endl;
  161.                     break;
  162.                 } else if(agil <= points )
  163.                 {
  164.                     player.agility = agil;
  165.                     points -= agil;
  166.                 }
  167.                 break;
  168.             }
  169.         default:
  170.             {
  171.                 break;
  172.             }
  173.         }
  174.         system("cls");
  175.  
  176.     }while(points > 0);
  177.     std::cout << "Open gates!" << std::endl;
  178.     Sleep(time);
  179.     system("cls");
  180.     std::cout << "Next!" << std::endl;
  181.     Sleep(time);
  182.     system("cls");
  183.  
  184.  
  185. }
  186. void world(char (&city)[w][h])
  187. {
  188.     for(int iH = 0; iH < h; iH++)
  189.     {
  190.         for(int iW = 0; iW < w; iW++)
  191.         {
  192.             if(iW == player.y && iH == player.x)
  193.             {
  194.                 std::cout << "@";
  195.             }
  196.             else
  197.             {
  198.                 std::cout << city[iW][iH];
  199.             }
  200.         }
  201.         std::cout << std::endl;
  202.     }
  203.  
  204.  
  205. }
  206.  
  207. void render()
  208. {
  209.     if(playerArea == 1)
  210.     {
  211.         world(town);
  212.     }
  213.     if(playerArea == 2)
  214.     {
  215.         world(pub);
  216.     }
  217. }
  218.  
  219. void choice(int cor)
  220. {
  221.     system("cls");
  222.     if(cor == 'D')
  223.     {
  224.         std::cout << "*CLOSED GATE*" << std::endl;
  225.         Sleep(time);
  226.     }
  227.     if(cor == 'G')
  228.     {
  229.         std::cout << "What are you trying to do!?" << std::endl;
  230.         Sleep(1000);
  231.         system("cls");
  232.         std::cout << "FUS!" << std::endl;
  233.         Sleep(500);
  234.         std::cout << "RO!" << std::endl;
  235.         Sleep(500);
  236.         std::cout << "DAH!" << std::endl;
  237.         Sleep(500);
  238.     }
  239.     if(cor == '~')
  240.     {
  241.         std::cout << "Just another boring game without swimming!";
  242.         Sleep(time);
  243.     }
  244.     if(cor == 'T')
  245.     {
  246.         std::cout << "*OLD DOORS*" << std::endl;
  247.         std::cout << "You want to open them?" << std::endl;
  248.         std::cout << "Y/N?" << std::endl;
  249.         button = getch();
  250.         switch(button)
  251.         {
  252.         case 'y':
  253.             {
  254.                 playerArea = 2;
  255.                 player.x = 8;
  256.                 player.y = 18;
  257.                 break;
  258.             }
  259.         case 'n':
  260.             {
  261.                 break;
  262.             }
  263.         default:
  264.             {
  265.                 break;
  266.             }
  267.         }
  268.     }
  269.     if(cor == 'K')
  270.     {
  271.         std::cout << "6\n";
  272.     }
  273.     if(cor == 'Z')
  274.     {
  275.         std::cout << "7\n";
  276.     }
  277.     if(cor == 'S')
  278.     {
  279.         std::cout << "8\n";
  280.     }
  281.     if(cor == 'H')
  282.     {
  283.         std::cout << "9\n";
  284.     }
  285.     if(cor == 10)
  286.     {
  287.         std::cout << "You want to leave pub?" << std::endl;
  288.         std::cout << "Y/N?" << std::endl;
  289.  
  290.         button = getch();
  291.         switch(button)
  292.         {
  293.         case 'y':
  294.             {
  295.                 playerArea = 1;
  296.                 break;
  297.             }
  298.         case 'n':
  299.             {
  300.                 break;
  301.             }
  302.         default:
  303.             {
  304.                 break;
  305.             }
  306.         }
  307.     }
  308.     if(cor == 11)
  309.     {
  310.         std::cout << "*" << player.name << " :" << std::endl;
  311.         std::cout << "Have you free rooms?" << std::endl;
  312.         Sleep(time);
  313.         system("cls");
  314.         std::cout << "*Stranger:" << std::endl;
  315.         std::cout << "Yes I have, 10 golden coins, 1 room for 5 nights" << std::endl;
  316.         Sleep(time);
  317.         system("cls");
  318.         std::cout << "One room" << std::endl;
  319.         std::cout << "*-10 golden coins" << std::endl;
  320.         Sleep(time);
  321.         system("cls");
  322.  
  323.     }
  324. }
  325.  
  326. void run()
  327. {
  328.     char cor;
  329.     button = getch();
  330.  
  331.     switch(button)
  332.     {
  333.     case 'w':
  334.         {
  335.             if(town[player.y][player.x - 1] == '#')
  336.             {
  337.                 break;
  338.             }
  339.             if(town[player.y][player.x - 1] != '#')
  340.             {
  341.                 cor = town[player.y][player.x - 1];
  342.                 choice(cor);
  343.             }
  344.             player.x --;
  345.             break;
  346.         }
  347.     case 's':
  348.         {
  349.             if(town[player.y][player.x + 1] == '#')
  350.             {
  351.                 break;
  352.             }
  353.             if(town[player.y][player.x + 1] != '#')
  354.             {
  355.                 cor = town[player.y][player.x + 1];
  356.                 choice(cor);
  357.             }
  358.             player.x ++;
  359.             break;
  360.         }
  361.     case 'a':
  362.         {
  363.             if(town[player.y - 1][player.x] == '#')
  364.             {
  365.                 break;
  366.             }
  367.             if(town[player.y - 1][player.x] != '#')
  368.             {
  369.                 cor = town[player.y - 1][player.x];
  370.                 choice(cor);
  371.             }
  372.             player.y --;
  373.             break;
  374.         }
  375.     case 'd':
  376.         {
  377.             if(town[player.y + 1][player.x] == '#')
  378.             {
  379.                 break;
  380.             }
  381.             if(town[player.y + 1][player.x] != '#')
  382.             {
  383.                 cor = town[player.y + 1][player.x];
  384.                 choice(cor);
  385.             }
  386.             player.y ++;
  387.             break;
  388.         }
  389.     }
  390. }
  391.  
  392. int main()
  393. {
  394.     bool Game = true;
  395.     while(Game == true)
  396.     {
  397.     //character();
  398.     render();
  399.     run();
  400.     system("cls");
  401.     }
  402.     return 0;
  403. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement