Advertisement
Guest User

Untitled

a guest
Jun 26th, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 25.56 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <conio.h>
  4. #include <time.h>
  5. #include <stdlib.h>
  6.  
  7. #define posX 40
  8. #define posY 7
  9.  
  10. using namespace System;
  11. using namespace std;
  12.  
  13. void niv_1()
  14. {
  15.     Console::SetCursorPosition(20, 11);
  16.     Console::ForegroundColor = ConsoleColor::Gray;
  17.     cout << "888b    888   8888888   888     888   8888888888   888          d888  " << endl;
  18.     cout << "\t\t    8888b   888     888     888     888   888          888         d8888  " << endl;
  19.     cout << "\t\t    88888b  888     888     888     888   888          888           888  " << endl;
  20.     cout << "\t\t    888Y88b 888     888     Y88b   d88P   8888888      888           888  " << endl;
  21.     cout << "\t\t    888 Y88b888     888      Y88b d88P    888          888           888  " << endl;
  22.     cout << "\t\t    888  Y88888     888       Y88o88P     888          888           888  " << endl;
  23.     cout << "\t\t    888   Y8888     888        Y888P      888          888           888  " << endl;
  24.     cout << "\t\t    888    Y888   8888888       Y8P       8888888888   88888888    8888888";
  25.     getch();
  26.     Console::Clear();
  27. }
  28. void niv_2()
  29. {
  30.     Console::SetCursorPosition(20, 11);
  31.     Console::ForegroundColor = ConsoleColor::Magenta;
  32.     cout << "888b    888   8888888   888     888   8888888888   888         .d8888b. " << endl;
  33.     cout << "\t\t    8888b   888     888     888     888   888          888        d88P  Y88b" << endl;
  34.     cout << "\t\t    88888b  888     888     888     888   888          888               888" << endl;
  35.     cout << "\t\t    888Y88b 888     888     Y88b   d88P   8888888      888             .d88P" << endl;
  36.     cout << "\t\t    888 Y88b888     888      Y88b d88P    888          888         .od888P' " << endl;
  37.     cout << "\t\t    888  Y88888     888       Y88o88P     888          888        d88P'     " << endl;
  38.     cout << "\t\t    888   Y8888     888        Y888P      888          888        888'      " << endl;
  39.     cout << "\t\t    888    Y888   8888888       Y8P       8888888888   88888888   888888888 ";
  40.     getch();
  41.     Console::Clear();
  42. }
  43. void niv_3()
  44. {
  45.     Console::SetCursorPosition(20, 11);
  46.     Console::ForegroundColor = ConsoleColor::White;
  47.     cout << "888b    888   8888888   888     888   8888888888   888         .d8888b. " << endl;
  48.     cout << "\t\t    8888b   888     888     888     888   888          888        d88P  Y88b" << endl;
  49.     cout << "\t\t    88888b  888     888     888     888   888          888             .d88P" << endl;
  50.     cout << "\t\t    888Y88b 888     888     Y88b   d88P   8888888      888            8888' " << endl;
  51.     cout << "\t\t    888 Y88b888     888      Y88b d88P    888          888             'Y8b." << endl;
  52.     cout << "\t\t    888  Y88888     888       Y88o88P     888          888        888    888" << endl;
  53.     cout << "\t\t    888   Y8888     888        Y888P      888          888        Y88b  d88P" << endl;
  54.     cout << "\t\t    888    Y888   8888888       Y8P       8888888888   88888888    'Y8888P' ";
  55.     getch();
  56.     Console::Clear();
  57. }
  58. void niv_4()
  59. {
  60.     Console::SetCursorPosition(20, 11);
  61.     Console::ForegroundColor = ConsoleColor::Cyan;
  62.     cout << "888b    888   8888888   888     888   8888888888   888           d8888 " << endl;
  63.     cout << "\t\t    8888b   888     888     888     888   888          888          d8P888 " << endl;
  64.     cout << "\t\t    88888b  888     888     888     888   888          888         d8P 888 " << endl;
  65.     cout << "\t\t    888Y88b 888     888     Y88b   d88P   8888888      888        d8P  888 " << endl;
  66.     cout << "\t\t    888 Y88b888     888      Y88b d88P    888          888       d88   888 " << endl;
  67.     cout << "\t\t    888  Y88888     888       Y88o88P     888          888       8888888888" << endl;
  68.     cout << "\t\t    888   Y8888     888        Y888P      888          888              888" << endl;
  69.     cout << "\t\t    888    Y888   8888888       Y8P       8888888888   88888888         888";
  70.     getch();
  71.     Console::Clear();
  72. }
  73. void niv_5()
  74. {
  75.     Console::SetCursorPosition(20, 11);
  76.     Console::ForegroundColor = ConsoleColor::Yellow;
  77.     cout << "888b    888   8888888   888     888   8888888888   888       888888888" << endl;
  78.     cout << "\t\t    8888b   888     888     888     888   888          888       888        " << endl;
  79.     cout << "\t\t    88888b  888     888     888     888   888          888       888        " << endl;
  80.     cout << "\t\t    888Y88b 888     888     Y88b   d88P   8888888      888       8888888b." << endl;
  81.     cout << "\t\t    888 Y88b888     888      Y88b d88P    888          888            'Y88b" << endl;
  82.     cout << "\t\t    888  Y88888     888       Y88o88P     888          888              888" << endl;
  83.     cout << "\t\t    888   Y8888     888        Y888P      888          888       Y88b  d88P" << endl;
  84.     cout << "\t\t    888    Y888   8888888       Y8P       8888888888   88888888   'Y8888P' ";
  85.     getch();
  86.     Console::Clear();
  87. }
  88. void niv_6()
  89. {
  90.     Console::SetCursorPosition(20, 11);
  91.     Console::ForegroundColor = ConsoleColor::Green;
  92.     cout << "888b    888   8888888   888     888   8888888888   888        .d8888b. " << endl;
  93.     cout << "\t\t    8888b   888     888     888     888   888          888       d88P  Y88b" << endl;
  94.     cout << "\t\t    88888b  888     888     888     888   888          888       888        " << endl;
  95.     cout << "\t\t    888Y88b 888     888     Y88b   d88P   8888888      888       888d888b. " << endl;
  96.     cout << "\t\t    888 Y88b888     888      Y88b d88P    888          888       888P 'Y88b" << endl;
  97.     cout << "\t\t    888  Y88888     888       Y88o88P     888          888       888    888" << endl;
  98.     cout << "\t\t    888   Y8888     888        Y888P      888          888       Y88b  d88P" << endl;
  99.     cout << "\t\t    888    Y888   8888888       Y8P       8888888888   88888888   'Y8888P' ";
  100.     getch();
  101.     Console::Clear();
  102. }
  103. void niv_7()
  104. {
  105.     Console::SetCursorPosition(20, 11);
  106.     Console::ForegroundColor = ConsoleColor::Blue;
  107.     cout << "888b    888   8888888   888     888   8888888888   888       8888888888 " << endl;
  108.     cout << "\t\t    8888b   888     888     888     888   888          888             d88P " << endl;
  109.     cout << "\t\t    88888b  888     888     888     888   888          888            d88P  " << endl;
  110.     cout << "\t\t    888Y88b 888     888     Y88b   d88P   8888888      888           d88P   " << endl;
  111.     cout << "\t\t    888 Y88b888     888      Y88b d88P    888          888        88888888  " << endl;
  112.     cout << "\t\t    888  Y88888     888       Y88o88P     888          888         d88P     " << endl;
  113.     cout << "\t\t    888   Y8888     888        Y888P      888          888        d88P      " << endl;
  114.     cout << "\t\t    888    Y888   8888888       Y8P       8888888888   88888888  d88P       ";
  115.     getch();
  116.     Console::Clear();
  117. }
  118. void niv_8()
  119. {
  120.     Console::SetCursorPosition(20, 11);
  121.     Console::ForegroundColor = ConsoleColor::Red;
  122.     cout << "888b    888   8888888   888     888   8888888888   888        .d8888b. " << endl;
  123.     cout << "\t\t    8888b   888     888     888     888   888          888       d88P  Y88b" << endl;
  124.     cout << "\t\t    88888b  888     888     888     888   888          888       Y88b. d88P" << endl;
  125.     cout << "\t\t    888Y88b 888     888     Y88b   d88P   8888888      888        'Y88888' " << endl;
  126.     cout << "\t\t    888 Y88b888     888      Y88b d88P    888          888       .d8P''Y8b." << endl;
  127.     cout << "\t\t    888  Y88888     888       Y88o88P     888          888       888    888" << endl;
  128.     cout << "\t\t    888   Y8888     888        Y888P      888          888       Y88b  d88P" << endl;
  129.     cout << "\t\t    888    Y888   8888888       Y8P       8888888888   88888888   'Y8888P'";
  130.     getch();
  131.     Console::Clear();
  132. }
  133. bool comprobarNivel(int **mapa)
  134. {
  135.     for (int i = 0; i < 20; ++i)
  136.     {
  137.         for (int j = 0; j < 25; ++j)
  138.         {
  139.             if (mapa[i][j] == 2)
  140.             {
  141.                 return false;
  142.             }
  143.         }
  144.     }
  145.     return true;
  146. }
  147.  
  148. void borrarEnemigo1(int **mapa, int *xe1, int *ye1)
  149. {
  150.     Console::SetCursorPosition(posX + *xe1, posY + *ye1);
  151.     cout << " ";
  152.     Console::SetCursorPosition(posX + *xe1, posY + *ye1);
  153.     if (mapa[*ye1][*xe1] == 2)//Comida
  154.     {
  155.         Console::ForegroundColor = ConsoleColor::Cyan;
  156.         cout << char(254);
  157.     }
  158.  
  159. }
  160. void dibujarEnemigo1(int *xe1, int *ye1)
  161. {
  162.     Console::ForegroundColor = ConsoleColor::Yellow;
  163.     Console::SetCursorPosition(posX + *xe1, posY + *ye1);
  164.     cout << char(2);
  165.     Console::ResetColor();
  166. }
  167. void moverEnemigo1(int **mapa, int *xe1, int *ye1, int *yei1, int *xei1)
  168. {
  169.     static int dx = 1;
  170.     if (*xe1 + dx >= 24 || *xe1 + dx <= 0)
  171.     {
  172.         dx *= -1;
  173.     }
  174.     borrarEnemigo1(mapa, xe1, ye1);
  175.     *xe1 += dx;
  176.     dibujarEnemigo1(xe1, ye1);
  177. }
  178.  
  179.  
  180. void borrarEnemigo2(int **mapa, int *xe2, int *ye2)
  181. {
  182.     Console::SetCursorPosition(posX + *xe2, posY + *ye2);
  183.     cout << " ";
  184.     Console::SetCursorPosition(posX + *xe2, posY + *ye2);
  185.     if (mapa[*ye2][*xe2] == 2)//Comida
  186.     {
  187.         Console::ForegroundColor = ConsoleColor::Cyan;
  188.         cout << char(254);
  189.     }
  190.  
  191. }
  192. void dibujarEnemigo2(int *xe2, int *ye2)
  193. {
  194.     Console::ForegroundColor = ConsoleColor::Yellow;
  195.     Console::SetCursorPosition(posX + *xe2, posY + *ye2);
  196.     cout << char(2);
  197.     Console::ResetColor();
  198. }
  199. void moverEnemigo2(int **mapa, int *xe2, int *ye2, int *yei2, int *xei2)
  200. {
  201.     static int dx = 1;
  202.     if (*xe2 + dx >= 24 || *xe2 + dx <= 0)
  203.     {
  204.         dx *= -1;
  205.     }
  206.     borrarEnemigo2(mapa, xe2, ye2);
  207.     *xe2 += dx;
  208.     dibujarEnemigo2(xe2, ye2);
  209. }
  210.  
  211.  
  212. void dibujaPersonaje(int *x, int*y)
  213. {
  214.     Console::SetCursorPosition(*x + posX, *y + posY);
  215.     Console::ForegroundColor = ConsoleColor::Magenta;
  216.     cout << (char)184;
  217. }
  218. void borrarPersonaje(int *x, int *y)
  219. {
  220.     Console::SetCursorPosition(*x + posX, *y + posY);
  221.     cout << " ";
  222. }
  223. void moverpersonaje(int **mapa, char *c, int *x, int *y, int *p, int *v, int*xi, int *yi)
  224. {
  225.     switch (*c)
  226.     {
  227.     case 'w':
  228.     {
  229.         if (mapa[*y - 1][*x] != 1 && mapa[*y - 1][*x] != 5)
  230.         {
  231.             borrarPersonaje(x, y);
  232.             --*y;
  233.         }
  234.         if (mapa[*y][*x] == 2)
  235.         {
  236.             *p += 10;
  237.             Console::SetCursorPosition(posX + 39, posY + 5);
  238.             Console::ForegroundColor = ConsoleColor::Green;
  239.             cout << *p;
  240.             mapa[*y][*x] = 9;
  241.         }
  242.         break;
  243.     }
  244.     case 's':
  245.     {
  246.         if (mapa[*y + 1][*x] != 1 && mapa[*y + 1][*x] != 5)
  247.         {
  248.             borrarPersonaje(x, y);
  249.             ++*y;
  250.         }
  251.         if (mapa[*y][*x] == 2)
  252.         {
  253.             *p += 10;
  254.             Console::SetCursorPosition(posX + 39, posY + 5);
  255.             Console::ForegroundColor = ConsoleColor::Green;
  256.             cout << *p;
  257.             mapa[*y][*x] = 9;
  258.         }
  259.         break;
  260.     }
  261.     case 'a':
  262.     {
  263.         if (mapa[*y][*x - 1] != 1 && mapa[*y][*x - 1] != 5)
  264.         {
  265.             borrarPersonaje(x, y);
  266.             --*x;
  267.         }
  268.         if (mapa[*y][*x] == 2)
  269.         {
  270.             *p += 10;
  271.             Console::SetCursorPosition(posX + 39, posY + 5);
  272.             Console::ForegroundColor = ConsoleColor::Green;
  273.             cout << *p;
  274.             mapa[*y][*x] = 9;
  275.         }
  276.         break;
  277.     }
  278.     case 'd':
  279.     {
  280.         if (mapa[*y][*x + 1] != 1 && mapa[*y][*x + 1] != 5)
  281.         {
  282.             borrarPersonaje(x, y);
  283.             ++*x;
  284.         }
  285.         if (mapa[*y][*x] == 2)
  286.         {
  287.             *p += 10;
  288.             Console::SetCursorPosition(posX + 39, posY + 5);
  289.             Console::ForegroundColor = ConsoleColor::Green;
  290.             cout << *p;
  291.             mapa[*y][*x] = 9;
  292.         }
  293.         break;
  294.     }
  295.     }
  296.     dibujaPersonaje(x, y);
  297. }
  298.  
  299. void dibujaMenuCarga(int *r)
  300. {
  301.     *r = 1 + rand() % 15;
  302.     Console::ForegroundColor = ConsoleColor(*r);
  303.     Console::SetCursorPosition(15, 2);
  304.     cout << "                  ::::::::  :::::::: :::           :::    ::::::::: " << endl;
  305.     cout << "\t\t               :+:    :+::+:    :+::+:         :+: :+:  :+:    :+:" << endl;
  306.     cout << "\t\t              +:+       +:+    +:++:+        +:+   +:+ +:+    +:+  " << endl;
  307.     cout << "\t\t             +#++:++#+++#+    +:++#+       +#++:++#++:+#++:++#:    " << endl;
  308.     cout << "\t\t                   +#++#+    +#++#+       +#+     +#++#+    +#+    " << endl;
  309.     cout << "\t\t           #+#    #+##+#    #+##+#       #+#     #+##+#    #+#     " << endl;
  310.     cout << "\t\t           ########  ######## #############     ######    ###      " << endl;
  311.     cout << "\t\t                           :::::::::::::::::: :::    ::: " << endl;
  312.     cout << "\t\t                          :+:      :+:    :+::+:    :+:  " << endl;
  313.     cout << "\t\t                         +:+      +:+    +:+ +:+  +:+    " << endl;
  314.     cout << "\t\t                        :#::+::# +#+    +:+  +#++:+      " << endl;
  315.     cout << "\t\t                       +#+      +#+    +#+ +#+  +#+      " << endl;
  316.     cout << "\t\t                      #+#      #+#    #+##+#    #+#      " << endl;
  317.     cout << "\t\t                     ###       ######## ###    ###       " << endl;
  318.     cout << endl << endl;
  319.     Console::ForegroundColor = ConsoleColor::Cyan;
  320.     cout << "\t\t\t\t\t   1.-Jugar" << endl;
  321.     Console::ForegroundColor = ConsoleColor::Green;
  322.     cout << "\t\t\t\t\t   2.-Instrucciones" << endl;
  323.     Console::ForegroundColor = ConsoleColor::Magenta;
  324.     cout << "\t\t\t\t\t   3.-Salir" << endl;
  325.     Console::ForegroundColor = ConsoleColor(*r);
  326.     cout << endl << endl << endl << "\t\t\t\t\t   *   * **** ****" << endl;
  327.     cout << "\t\t\t\t\t   *   * *  * *" << endl;
  328.     cout << "\t\t\t\t\t   *   * **** *" << endl;
  329.     cout << "\t\t\t\t\t   *   * *    *" << endl;
  330.     cout << "\t\t\t\t\t   ***** *    ****" << endl;
  331. }
  332. void borrarPersonajeMenu()
  333. {
  334.     Console::SetCursorPosition(15, 0);
  335.     cout << "                                                                                                              ";
  336. }
  337. void dibujarPersonajeMenu(int *xm, int *ym, int *v)
  338. {
  339.     Console::SetCursorPosition(*xm, *ym);
  340.     switch (*v)
  341.     {
  342.     case 0:
  343.         cout << "U";
  344.         break;
  345.     case 1:
  346.         cout << "P";
  347.         break;
  348.     case 2:
  349.         cout << "C";
  350.         break;
  351.     case 3:
  352.         cout << " ";
  353.         break;
  354.     }
  355.     *v += 1;
  356.     if (*v == 4)*v = 0;
  357. }
  358. void moverPersonajeMenu(int *xm, int *ym, int *v, int *r)
  359. {
  360.     _sleep(80);
  361.     if (*ym == 0 && *xm <= 91)
  362.     {
  363.         ++*xm;
  364.         if (*xm == 92)
  365.         {
  366.             borrarPersonajeMenu();
  367.             dibujaMenuCarga(r);
  368.             *xm = 15;
  369.             *v = 0;
  370.         }
  371.     }
  372.     dibujarPersonajeMenu(xm, ym, v);
  373. }
  374. void instrucciones(int *v, int *xm, int *ym)
  375. {
  376.     *v = *ym = 0;
  377.     *xm = 15;
  378.     getch();
  379. }
  380. void pu_vi(int *p, int *vi)
  381. {
  382.     Console::ForegroundColor = ConsoleColor::Red;
  383.     Console::SetCursorPosition(posX + 30, posY + 7);
  384.     cout << "Vida: ";
  385.     for (int i = 0; i < *vi; ++i)
  386.     {
  387.         cout << char(3);
  388.     }Console::ForegroundColor = ConsoleColor::White;
  389.     Console::SetCursorPosition(posX + 30, posY + 5);
  390.     cout << "Puntaje: " << *p;
  391. }
  392. void posicion(int *xe1, int *ye1, int *x, int *y, int *xi, int *yi, int *xei1, int *yei1, int *xe2, int *ye2, int *xei2, int *yei2)
  393. {
  394.     *xe1 = 1;
  395.     *ye1 = 14;
  396.     *xe2 = 1;
  397.     *ye2 = 6;
  398.     *x = 6;
  399.     *y = 5;
  400.     *xi = *x;
  401.     *yi = *y;
  402.     *xei1 = *xe1;
  403.     *yei1 = *ye1;
  404.     *xei2 = *xe2;
  405.     *yei2 = *ye2;
  406. }
  407. void generarmapa(int **mapa, int m[20][25], int *cmpM)
  408. {
  409.     for (int i = 0; i < 20; i++)
  410.     {
  411.         for (int j = 0; j < 25; ++j)
  412.         {
  413.             mapa[i][j] = m[i][j];
  414.         }
  415.     }
  416.     *cmpM += 1;
  417. }
  418. void dibujamapa(int **mapa)
  419. {
  420.     for (int i = 0; i < 20; ++i)
  421.     {
  422.         for (int j = 0; j < 25; ++j)
  423.         {
  424.             Console::SetCursorPosition(j + posX, i + posY);
  425.             if (mapa[i][j] == 1)//pared
  426.             {
  427.                 Console::ForegroundColor = ConsoleColor::Magenta;
  428.                 cout << char(219);
  429.             }
  430.             if (mapa[i][j] == 0)//espacios
  431.             {
  432.                 cout << " ";
  433.             }
  434.             if (mapa[i][j] == 2)//Comida
  435.             {
  436.                 Console::ForegroundColor = ConsoleColor::Cyan;
  437.                 cout << char(254);
  438.             }
  439.             if (mapa[i][j] == 5)//pared dentro
  440.             {
  441.                 Console::ForegroundColor = ConsoleColor::Magenta;
  442.                 cout << char(219);
  443.             }
  444.         }
  445.     }
  446. }
  447. void jugar(int *x, int *xe1, int *y, int *ye1, int *xi, int *yi, char*c, int*vi, bool *cmp, int **mapa, int *p, int *xei1, int *yei1, int *cmpM, int *xe2, int *ye2, int *xei2, int *yei2)
  448. {
  449.     do
  450.     {
  451.         if (*x == *xe1 && *y == *ye1 && *cmpM <= 5)
  452.         {
  453.             borrarEnemigo1(mapa, xe1, ye1);
  454.             *xe1 == *xei1;
  455.             Console::ForegroundColor = ConsoleColor::Red;
  456.             Console::SetCursorPosition(posX + 36, posY + 7);
  457.             for (int i = 0; i < *vi; i++)
  458.             {
  459.                 cout << " ";
  460.             }
  461.             --*vi;
  462.             Console::SetCursorPosition(posX + 36, posY + 7);
  463.             for (int i = 0; i < *vi; i++)
  464.             {
  465.                 cout << char(3);
  466.             }
  467.             *x = *xi;
  468.             *y = *yi;
  469.             dibujaPersonaje(x, y);
  470.         }
  471.         if (*x == *xe2 && *y == *ye2 && *cmpM > 2)
  472.         {
  473.             borrarEnemigo2(mapa, xe2, ye2);
  474.             *xe2 == *xei2;
  475.             Console::ForegroundColor = ConsoleColor::Red;
  476.             Console::SetCursorPosition(posX + 36, posY + 7);
  477.             for (int i = 0; i < *vi; i++)
  478.             {
  479.                 cout << " ";
  480.             }
  481.             --*vi;
  482.             Console::SetCursorPosition(posX + 36, posY + 7);
  483.             for (int i = 0; i < *vi; i++)
  484.             {
  485.                 cout << char(3);
  486.             }
  487.             *x = *xi;
  488.             *y = *yi;
  489.             dibujaPersonaje(x, y);
  490.         }
  491.         if (kbhit())
  492.         {
  493.             *c = getch();
  494.             *c = tolower(*c);
  495.             moverpersonaje(mapa, c, x, y, p, vi, xi, yi);
  496.         }
  497.         _sleep(100);
  498.         switch (*cmpM)
  499.         {
  500.         case 1:
  501.             moverEnemigo1(mapa, xe1, ye1, yei1, xei1); break;
  502.         case 2:
  503.             moverEnemigo1(mapa, xe1, ye1, yei1, xei1); break;
  504.         case 3:
  505.             moverEnemigo1(mapa, xe1, ye1, yei1, xei1); moverEnemigo2(mapa, xe2, ye2, yei2, xei2); break;
  506.         case 4:
  507.             moverEnemigo1(mapa, xe1, ye1, yei1, xei1); moverEnemigo2(mapa, xe2, ye2, yei2, xei2); break;
  508.         case 5:
  509.             moverEnemigo1(mapa, xe1, ye1, yei1, xei1); moverEnemigo2(mapa, xe2, ye2, yei2, xei2); break;
  510.         }
  511.         *cmp = comprobarNivel(mapa);
  512.     } while (*cmp == false && *vi != 0);//dos condiciones si la vida = 0 o termina el nivel
  513. }
  514. void main()
  515. {
  516.     Console::SetWindowSize(110, 30);//tamaño de la pantalla
  517.     Console::SetBufferSize(110, 30);//el tamaño que se vera cuando compile
  518.     srand(time(NULL));
  519.     Console::CursorVisible = false;
  520.     int *v = new int;
  521.     int *xm = new int;
  522.     int *ym = new int;
  523.     int *r = new int;
  524.     char *opc = new char;
  525.     *xm = 15;
  526.     *ym = 0;
  527.     *v = 0;
  528.     dibujaMenuCarga(r);
  529.     for (;;)
  530.     {
  531.         if (kbhit())
  532.         {
  533.             *opc = getch();
  534.             if (*opc == '1')
  535.             {
  536.                 Console::Clear();
  537.                 break;
  538.             }
  539.             else
  540.             {
  541.                 switch (*opc)
  542.                 {
  543.                 case '2':
  544.                     Console::Clear();
  545.                     instrucciones(v, xm, ym);
  546.                     dibujaMenuCarga(r);
  547.                     break;
  548.                 case '3':
  549.                     exit(0);
  550.                     break;
  551.                 }
  552.             }
  553.         }
  554.         moverPersonajeMenu(xm, ym, v, r);
  555.     }
  556.     int *xe1 = new int, *ye1 = new int;//posicion del enemigo 1
  557.     int *xei1 = new int, *yei1 = new int;//posiciones iniciales del enemigo
  558.     int *xe2 = new int, *ye2 = new int;//posicion del enemigo 2
  559.     int *xei2 = new int, *yei2 = new int;//posicion inicial del enemigo 2
  560.     int *x = new int, *y = new int;//posicion del jugador
  561.     int *xi = new int, *yi = new int;//posicion inicial del personaje
  562.     char *c = new char;//tecla del movimiento
  563.     bool *cmp = new bool;//comprobar si termina el nivel
  564.     int *p = new int, *vi = new int;//puntaje y vida
  565.     int *cmpM = new int; *cmpM = 0;//comprueba el mapa para el numero de enemigos
  566.     int **mapa = new int*[25];//crear la matriz del mapa todos del mismo tamaño
  567.     for (int i = 0; i < 20; ++i)
  568.     {
  569.         mapa[i] = new int[25];
  570.     }
  571.     int m1[20][25] = { { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 },
  572.     { 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,1 },
  573.     { 1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,1 },
  574.     { 1,0,0,0,2,0,0,0,2,0,0,0,0,0,2,0,0,0,0,0,0,0,0,2,1 },
  575.     { 1,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,1 },
  576.     { 1,0,0,0,0,0,0,0,0,0,2,0,2,0,0,0,0,0,0,0,0,0,0,0,1 },
  577.     { 1,0,2,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,2,0,0,1 },
  578.     { 1,0,0,0,2,0,0,2,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,2,1 },
  579.     { 1,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,1 },
  580.     { 1,2,0,0,0,2,0,0,0,0,0,0,0,0,0,2,0,2,0,0,0,0,0,0,1 },
  581.     { 1,0,0,0,0,0,0,0,0,2,0,2,0,0,0,0,0,0,0,0,2,0,2,0,1 },
  582.     { 1,0,0,0,2,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,1 },
  583.     { 1,2,0,0,0,0,2,0,0,0,0,0,0,0,0,2,0,2,0,0,0,0,0,0,1 },
  584.     { 1,0,0,2,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,2,0,2,0,1 },
  585.     { 1,0,0,0,0,0,0,0,2,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,1 },
  586.     { 1,0,2,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,2,0,0,0,0,0,1 },
  587.     { 1,0,0,0,2,0,2,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,2,1 },
  588.     { 1,2,0,0,0,0,0,0,2,0,0,0,0,0,0,2,0,0,2,0,0,0,0,0,1 },
  589.     { 1,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,2,0,0,1 },
  590.     { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 } };
  591.     int m2[20][25] = { { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 },
  592.     { 1,0,5,0,0,0,0,5,0,0,0,5,0,0,0,5,0,0,0,0,5,0,0,2,1 },
  593.     { 1,2,5,2,0,0,0,5,0,0,0,5,2,0,0,5,2,0,0,0,5,0,0,0,1 },
  594.     { 1,0,5,0,0,0,2,5,0,2,0,5,0,2,0,5,0,0,0,2,5,2,0,0,1 },
  595.     { 1,0,5,0,0,0,0,5,0,0,0,5,0,0,0,5,0,2,0,0,5,0,2,0,1 },
  596.     { 1,0,5,0,0,0,0,0,0,0,0,5,0,0,0,0,0,0,0,0,0,0,0,0,1 },
  597.     { 1,0,0,0,0,2,0,0,2,0,0,5,0,0,0,2,0,0,0,0,0,0,0,2,1 },
  598.     { 1,2,0,0,0,0,0,0,0,0,2,0,0,2,0,0,0,0,0,0,2,5,5,5,1 },
  599.     { 1,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,1 },
  600.     { 1,0,0,0,2,0,0,2,0,0,0,0,0,0,0,2,0,0,0,0,0,0,2,0,1 },
  601.     { 1,5,5,5,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,2,0,0,0,0,1 },
  602.     { 1,0,0,0,0,0,2,0,0,0,0,2,0,0,0,0,2,0,0,0,0,5,5,5,1 },
  603.     { 1,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,5,5,5,1 },
  604.     { 1,0,0,0,0,0,2,0,0,0,2,0,0,2,0,2,0,0,0,2,0,0,0,0,1 },
  605.     { 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
  606.     { 1,0,2,0,0,0,0,0,5,0,2,5,2,0,2,5,0,2,5,0,0,2,5,0,1 },
  607.     { 1,0,0,5,0,0,0,0,5,2,0,5,0,0,0,5,0,0,5,2,0,0,5,2,1 },
  608.     { 1,2,0,5,0,0,0,2,5,0,2,5,2,0,0,5,2,0,5,0,2,0,5,0,1 },
  609.     { 1,0,0,5,0,0,0,0,5,2,0,5,0,2,0,5,0,0,5,0,0,0,5,0,1 },
  610.     { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 } };
  611.     int m3[20][25] = { { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 },
  612.     { 1,0,2,0,1,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,1,1,0,0,1 },
  613.     { 1,2,1,2,1,0,0,0,2,0,2,0,1,2,0,1,0,2,0,0,1,1,0,2,1 },
  614.     { 1,0,1,0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,1 },
  615.     { 1,0,0,0,0,0,2,0,0,0,2,0,0,0,0,1,0,0,2,0,1,0,2,0,1 },
  616.     { 1,0,2,0,2,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,1 },
  617.     { 1,0,0,0,0,0,0,0,0,2,0,0,0,0,0,2,0,0,0,2,0,2,0,2,1 },
  618.     { 1,0,0,0,1,0,0,1,0,0,1,1,2,0,0,0,0,1,0,0,0,0,0,0,1 },
  619.     { 1,0,2,1,1,0,2,1,0,0,0,1,0,2,0,2,0,1,1,0,2,1,0,2,1 },
  620.     { 1,0,0,0,1,0,0,1,1,0,0,1,1,0,0,0,1,1,0,2,0,1,0,0,1 },
  621.     { 1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,1,1,2,1 },
  622.     { 1,2,0,0,0,0,2,0,0,2,0,0,0,0,0,2,0,0,2,2,0,2,0,0,1 },
  623.     { 1,0,0,0,2,0,0,0,0,0,0,0,0,2,0,0,2,0,0,0,0,0,0,0,1 },
  624.     { 1,0,0,2,0,0,0,0,2,0,0,2,0,0,0,0,0,0,2,0,0,0,2,0,1 },
  625.     { 1,2,0,0,0,0,0,0,0,2,0,0,0,2,0,0,0,0,0,0,2,0,0,0,1 },
  626.     { 1,0,0,0,2,1,0,0,1,0,0,0,0,0,1,2,0,1,0,0,0,2,0,2,1 },
  627.     { 1,0,1,0,0,1,2,0,1,0,0,2,1,0,1,0,0,1,0,0,1,0,1,0,1 },
  628.     { 1,2,1,0,0,1,0,2,1,0,0,0,1,2,1,0,0,1,2,1,1,0,1,0,1 },
  629.     { 1,0,1,0,0,1,0,0,1,2,2,0,1,0,1,0,2,1,0,1,2,2,1,2,1 },
  630.     { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 } };
  631.     int m4[20][25] = { { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 },
  632.     { 1,2,0,1,0,2,0,0,0,1,0,1,0,2,0,1,2,0,0,1,0,0,1,0,1 },
  633.     { 1,0,2,1,0,0,0,2,0,1,2,1,0,0,0,1,1,1,0,1,2,0,1,2,1 },
  634.     { 1,0,0,1,0,2,0,0,2,1,0,1,2,1,1,0,2,1,0,1,0,2,1,0,1 },
  635.     { 1,0,0,1,0,0,0,0,0,0,2,1,0,0,1,0,0,0,0,0,0,0,0,0,1 },
  636.     { 1,2,0,0,0,2,0,2,0,0,0,2,0,0,2,0,2,0,2,0,0,0,2,0,1 },
  637.     { 1,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,2,0,0,0,1 },
  638.     { 1,0,0,2,0,0,0,2,0,0,2,0,0,1,1,2,0,1,0,0,0,2,0,0,1 },
  639.     { 1,0,0,1,0,2,0,0,1,0,0,2,0,0,1,0,0,1,1,2,0,1,0,2,1 },
  640.     { 1,2,2,1,0,0,0,1,1,2,0,0,0,0,1,0,2,0,1,0,2,1,2,0,1 },
  641.     { 1,0,0,1,1,2,0,0,1,0,0,2,0,0,1,1,0,2,1,0,0,1,1,1,1 },
  642.     { 1,0,0,0,1,0,2,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1 },
  643.     { 1,0,0,0,0,0,0,0,2,0,2,0,0,2,0,0,2,0,0,0,2,0,0,2,1 },
  644.     { 1,2,0,0,2,0,0,2,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,1 },
  645.     { 1,0,0,0,0,2,0,0,0,0,0,2,0,0,2,0,2,0,0,0,0,2,0,2,1 },
  646.     { 1,0,0,1,0,0,1,2,1,2,0,0,1,0,0,0,0,0,2,1,1,0,2,0,1 },
  647.     { 1,2,1,1,0,1,1,0,1,1,0,0,1,1,0,0,1,1,0,0,1,0,0,0,1 },
  648.     { 1,0,1,0,2,0,1,2,0,1,1,2,0,1,2,1,1,0,0,0,1,1,0,2,1 },
  649.     { 1,2,1,2,0,2,1,0,0,0,1,0,2,1,0,1,0,2,0,0,0,1,2,0,1 },
  650.     { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 } };
  651.     int m5[20][25] = { { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 },
  652.     { 1,0,1,2,0,1,0,1,2,0,1,2,0,2,0,2,1,0,0,1,0,0,1,0,1 },
  653.     { 1,2,1,0,2,1,2,1,1,0,1,1,2,0,2,1,1,2,0,1,2,0,1,2,1 },
  654.     { 1,0,1,2,0,1,0,0,1,2,0,1,1,0,1,1,0,0,0,2,1,0,1,0,1 },
  655.     { 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,1 },
  656.     { 1,2,0,0,0,2,0,0,0,2,0,2,0,0,2,0,2,0,2,0,0,0,0,0,1 },
  657.     { 1,0,0,2,0,0,0,2,0,0,0,0,0,0,0,0,0,2,0,0,0,2,0,0,1 },
  658.     { 1,0,1,0,0,0,0,0,0,0,0,2,2,1,0,0,0,0,0,0,0,0,1,0,1 },
  659.     { 1,2,1,0,0,1,2,0,1,0,1,0,1,2,0,0,0,1,0,0,1,0,1,2,1 },
  660.     { 1,1,1,2,0,1,0,1,1,2,1,0,2,1,0,2,1,1,1,2,1,0,1,1,1 },
  661.     { 1,2,1,0,2,0,1,1,0,0,1,0,1,2,0,0,0,0,1,1,0,0,1,0,1 },
  662.     { 1,0,1,0,0,0,0,0,0,0,0,0,2,1,2,0,0,0,0,0,0,2,1,2,1 },
  663.     { 1,2,0,2,0,0,0,2,0,2,0,0,0,0,0,0,2,0,0,0,0,0,0,0,1 },
  664.     { 1,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,2,1 },
  665.     { 1,0,0,0,0,2,0,0,2,0,2,0,2,0,2,0,0,0,0,0,2,0,0,0,1 },
  666.     { 1,2,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,2,0,0,1 },
  667.     { 1,0,1,0,2,0,1,1,0,0,1,0,0,2,0,1,0,0,1,1,0,0,1,0,1 },
  668.     { 1,2,1,2,0,1,1,0,2,0,0,1,2,0,1,0,2,0,0,1,1,2,1,2,1 },
  669.     { 1,0,1,0,2,1,0,2,0,2,0,2,1,1,0,2,0,2,0,2,1,0,1,0,1 },
  670.     { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 } };
  671.     *p = 0;
  672.     *vi = 5;
  673.     niv_1();//escribe nivel uno
  674.     pu_vi(p, vi);//escribe los respectivos puntajes y vidas
  675.     posicion(xe1, ye1, x, y, xi, yi, xei1, yei1, xe2, ye2, xei2, yei2);//pocisiones iniciales de todos
  676.     generarmapa(mapa, m1, cmpM);//manda los datos del "mapa" a el mapa general
  677.     dibujamapa(mapa);//dibuja el mapa
  678.     dibujaPersonaje(x, y);//dibuja el personaje
  679.     jugar(x, xe1, y, ye1, xi, yi, c, vi, cmp, mapa, p, xei1, yei1, cmpM, xe2, ye2, xei2, yei2);//aca esta lo bueno
  680.     Console::Clear();
  681.     niv_2();
  682.     pu_vi(p, vi);
  683.     posicion(xe1, ye1, x, y, xi, yi, xei1, yei1, xe2, ye2, xei2, yei2);
  684.     generarmapa(mapa, m2, cmpM);
  685.     dibujamapa(mapa);
  686.     dibujaPersonaje(x, y);
  687.     jugar(x, xe1, y, ye1, xi, yi, c, vi, cmp, mapa, p, xei1, yei1, cmpM, xe2, ye2, xei2, yei2);
  688.     Console::Clear();
  689.     niv_3();
  690.     pu_vi(p, vi);
  691.     posicion(xe1, ye1, x, y, xi, yi, xei1, yei1, xe2, ye2, xei2, yei2);
  692.     generarmapa(mapa, m3, cmpM);
  693.     dibujamapa(mapa);
  694.     dibujaPersonaje(x, y);
  695.     jugar(x, xe1, y, ye1, xi, yi, c, vi, cmp, mapa, p, xei1, yei1, cmpM, xe2, ye2, xei2, yei2);
  696.     Console::Clear();
  697.     niv_4();
  698.     pu_vi(p, vi);
  699.     posicion(xe1, ye1, x, y, xi, yi, xei1, yei1, xe2, ye2, xei2, yei2);
  700.     generarmapa(mapa, m4, cmpM);
  701.     dibujamapa(mapa);
  702.     dibujaPersonaje(x, y);
  703.     jugar(x, xe1, y, ye1, xi, yi, c, vi, cmp, mapa, p, xei1, yei1, cmpM, xe2, ye2, xei2, yei2);
  704.     Console::Clear();
  705.     niv_5();
  706.     pu_vi(p, vi);
  707.     posicion(xe1, ye1, x, y, xi, yi, xei1, yei1, xe2, ye2, xei2, yei2);
  708.     generarmapa(mapa, m5, cmpM);
  709.     dibujamapa(mapa);
  710.     dibujaPersonaje(x, y);
  711.     jugar(x, xe1, y, ye1, xi, yi, c, vi, cmp, mapa, p, xei1, yei1, cmpM, xe2, ye2, xei2, yei2);
  712.     Console::Clear();
  713. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement