Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ConsoleApplication1.cpp : main project file.
- #include "stdafx.h"
- #include <conio.h>
- #include <iostream>
- using namespace std;
- using namespace System;
- struct Enemigo
- {
- int ex;
- int ey;
- int delx;
- int dely;
- };
- void playplayer(int &jx, int &jy)
- {
- int tecla;
- if (kbhit())//player
- {
- tecla = _getch();
- if (tecla == 224)
- {
- tecla = _getch();
- Console::SetCursorPosition(jx, jy);
- cout << ' ';
- switch (tecla)
- {
- case 72:jy--;break;
- }
- Console::SetCursorPosition(jx, jy);
- cout << 'F';
- }
- }
- }
- void moversmiley(int &ex, int &ey, int &dex, int &dey)
- {
- //esconder al enemigo
- Console::SetCursorPosition(ex, ey);
- cout << " ";
- if (ex == 53)//limite derecho
- {
- dex = -1;
- }
- if (ex == 3)//limite izquierdo
- {
- dex = 1;
- }
- if (ey == 20)//limite inferior
- ey = 1;
- //mover al enemigo
- ex += dex;
- ey += dey;
- //mostrar al enemigo de nuevo
- Console::SetCursorPosition(ex, ey);
- cout << (char)1 << (char)1 << (char)1 << (char)1;
- }
- int main()
- {
- int tecla;
- int ex, ey, dex, dey;
- int sx, sy, dsx, dsy;
- int jx, jy, djx, djy;
- dex = 1; dey = 1;
- dsx = 1; dsx = 1;
- djx = 1; djy = 1;
- //despalamiento enemigo
- ex = 3; ey = 10;
- sx = 5; sy = 6;
- jx = 1;jy = 2;
- //mostrar al enemigo
- Console::SetCursorPosition(ex, ey);
- cout << (char)1 << (char)1 << (char)1 << (char)1;
- while (1)
- {
- _sleep(50);
- moversmiley(ex, ey, dex, dey);
- moversmiley(sx, sy, dsx, dsy);
- playplayer(jx, jy);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment