Xavistian

Movimiento autónomo enemigo

Jun 13th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.79 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. int main()
  10. {
  11.     int ex, ey, dex, dey;
  12.     dex = 1; dey = 1;//despalamiento enemigo
  13.     ex = 3; ey = 10;
  14.     //mostrar al enemigo
  15.     Console::SetCursorPosition(ex, ey);
  16.     cout << "eeee";
  17.     while (1)
  18.     {
  19.         _sleep(50);
  20.         //esconder al enemigo
  21.         Console::SetCursorPosition(ex, ey);
  22.         cout << "    ";
  23.         if (ex == 53)//limite derecho
  24.             dex = -1;
  25.         if (ex == 3)//limite izquierdo
  26.             dex = 1;
  27.         if (ey == 20)//limite inferior
  28.             dey = -1;
  29.         if (ey == 1)//limite superior
  30.             dey = +1;
  31.         //mover al enemigo
  32.         ex += dex;
  33.         ey += dey;
  34.         //mostrar al enemigo de nuevo
  35.         Console::SetCursorPosition(ex, ey);
  36.         cout << "eeee";
  37.     }
  38.  
  39.     return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment