Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <time.h>
- using namespace std;
- using namespace System;
- void movil(int x, int y) {
- Console::SetCursorPosition(x, y);
- cout << (char)219;
- }
- int main() {
- srand(time(NULL));
- int x = 7, y = 7, dx=1, dy=1;
- Console::SetWindowSize(25, 11);
- Console::BackgroundColor = ConsoleColor::White;
- Console::ForegroundColor = ConsoleColor::Red;
- while(true) {
- Console::Clear();
- movil(x, y);
- if ((x + dx) < 0 || (x + dx) > 24) {
- dx *= -1;
- }
- if ((y + dy) < 0 || (y + dy) > 10) {
- dy *= -1;
- }
- x += dx;
- y += dy;
- _sleep(10);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement