Xavistian

Game

Jun 13th, 2018
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.48 KB | None | 0 0
  1. // ConsoleApplication1.cpp : main project file.
  2.  
  3. #include "stdafx.h"
  4. #include <conio.h>
  5. #include <iostream>
  6. using namespace std;
  7. using namespace System;
  8.  
  9. struct Enemigo
  10. {
  11.     int ex;
  12.     int ey;
  13.     int delx;
  14.     int dely;
  15. };
  16. void playplayer(int &jx, int &jy)
  17. {
  18.     int tecla;
  19.     if (kbhit())//player
  20.     {
  21.         tecla = _getch();
  22.         if (tecla == 224)
  23.         {
  24.             tecla = _getch();
  25.             Console::SetCursorPosition(jx, jy);
  26.             cout << ' ';
  27.             switch (tecla)
  28.             {
  29.             case 72:jy--;break;
  30.             }
  31.             Console::SetCursorPosition(jx, jy);
  32.             cout << 'F';
  33.         }
  34.     }
  35. }
  36. void moversmiley(int &ex, int &ey, int &dex, int &dey)
  37. {
  38.     //esconder al enemigo
  39.     Console::SetCursorPosition(ex, ey);
  40.     cout << "    ";
  41.     if (ex == 53)//limite derecho
  42.     {
  43.         dex = -1;
  44.     }
  45.     if (ex == 3)//limite izquierdo
  46.     {
  47.         dex = 1;
  48.     }
  49.     if (ey == 20)//limite inferior
  50.         ey = 1;
  51.     //mover al enemigo
  52.     ex += dex;
  53.     ey += dey;
  54.     //mostrar al enemigo de nuevo
  55.     Console::SetCursorPosition(ex, ey);
  56.     cout << (char)1 << (char)1 << (char)1 << (char)1;
  57. }
  58. int main()
  59. {
  60.     int tecla;
  61.     int ex, ey, dex, dey;
  62.     int sx, sy, dsx, dsy;
  63.     int jx, jy, djx, djy;
  64.     dex = 1; dey = 1;
  65.     dsx = 1; dsx = 1;
  66.     djx = 1; djy = 1;
  67.     //despalamiento enemigo
  68.     ex = 3; ey = 10;
  69.     sx = 5; sy = 6;
  70.     jx = 1;jy = 2;
  71.     //mostrar al enemigo
  72.     Console::SetCursorPosition(ex, ey);
  73.     cout << (char)1 << (char)1 << (char)1 << (char)1;
  74.     while (1)
  75.     {
  76.         _sleep(50);
  77.        
  78.         moversmiley(ex, ey, dex, dey);
  79.         moversmiley(sx, sy, dsx, dsy);
  80.         playplayer(jx, jy);
  81.     }
  82.  
  83.     return 0;
  84. }
Advertisement
Add Comment
Please, Sign In to add comment