Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "pch.h"
- #include <iostream>
- #include <time.h>
- using namespace System;
- using namespace std;
- int x = 10, y = 10;
- int dx = 1, dy = 1;
- int height = 30, width = 100;
- void borrar() {
- System::Console::SetCursorPosition(x, y);
- cout << "*";
- }
- void actualizar() {
- x += dx;
- y += dy;
- if (x == 0 || x == width - 1) dx *= -1;
- if (y == 0 || y == height - 1) dy *= -1;
- if (x == width / 2 && y == height / 2) {
- cout << "Done";
- }
- }
- void renderizar() {
- System::Console::SetCursorPosition(0, 0);
- cout << width / 2 << " " << height / 2 << endl;
- cout << x << " " << y;
- System::Console::SetCursorPosition(width / 2, height / 2);
- cout << "M";
- System::Console::SetCursorPosition(x, y);
- cout << "O";
- }
- int main()
- {
- System::Console::SetWindowSize(width, height);
- System::Console::CursorVisible = false;
- while (1) {
- borrar();
- actualizar();
- renderizar();
- _sleep(1);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement