Advertisement
Guest User

Untitled

a guest
May 22nd, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. #include <iostream>
  2. #include <time.h>
  3. using namespace std;
  4. using namespace System;
  5. void movil(int x, int y) {
  6. Console::SetCursorPosition(x, y);
  7. cout << (char)219;
  8. }
  9. int main() {
  10. srand(time(NULL));
  11. int x = 7, y = 7, dx=1, dy=1;
  12. Console::SetWindowSize(25, 11);
  13. Console::BackgroundColor = ConsoleColor::White;
  14. Console::ForegroundColor = ConsoleColor::Red;
  15. while(true) {
  16. Console::Clear();
  17. movil(x, y);
  18. if ((x + dx) < 0 || (x + dx) > 24) {
  19. dx *= -1;
  20. }
  21. if ((y + dy) < 0 || (y + dy) > 10) {
  22. dy *= -1;
  23. }
  24. x += dx;
  25. y += dy;
  26. _sleep(10);
  27. }
  28. return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement