Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "pch.h"
- #include <iostream>
- #include <conio.h>
- using namespace System;
- using namespace std;
- #define MAXWIDTH 200
- int x = 5, y = 5;
- int li = 27;
- int ls = 7;
- int ld = 100;
- int liz = 5;
- // 1= arriba , 2 = abajo, 3 = derecha , 4 = izquiera
- int orientacion = 3;
- bool start = false;
- void update() {
- if (!start) return;
- if (orientacion == 4 && x < liz) {
- return;
- }
- if (orientacion == 1) y--;
- if (orientacion == 2) y++;
- if (orientacion == 3) x++;
- if (orientacion == 4) x--;
- if (orientacion == 1 && y == ls) {
- orientacion = 3;
- ls += 2;
- }
- if (orientacion == 2 && y == li) {
- orientacion = 4;
- li -= 2;
- }
- if (orientacion == 3 && x == ld) {
- orientacion = 2;
- ld -= 10;
- }
- if (orientacion == 4 && x == liz) {
- orientacion = 1;
- liz += 10;
- }
- }
- void erase() {
- Console::SetCursorPosition(x, y);
- cout << " ";
- }
- void render() {
- Console::SetCursorPosition(x, y);
- cout << "@";
- }
- int main()
- {
- Console::SetWindowSize(110, 30);
- Console::CursorVisible = false;
- while (1) {
- if (_kbhit()) {
- switch (_getch())
- {
- case 'x':
- start = true;
- break;
- default:
- break;
- }
- }
- erase();
- update();
- render();
- _sleep(10);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement