Advertisement
sebasvp2005

Untitled

May 22nd, 2024
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. #include "pch.h"
  2. #include <iostream>
  3. #include <conio.h>
  4. using namespace System;
  5. using namespace std;
  6.  
  7.  
  8. #define MAXWIDTH 200
  9.  
  10. int x = 5, y = 5;
  11. int li = 27;
  12. int ls = 7;
  13. int ld = 100;
  14. int liz = 5;
  15.  
  16. // 1= arriba , 2 = abajo, 3 = derecha , 4 = izquiera
  17.  
  18. int orientacion = 3;
  19.  
  20. bool start = false;
  21.  
  22. void update() {
  23. if (!start) return;
  24. if (orientacion == 4 && x < liz) {
  25. return;
  26. }
  27. if (orientacion == 1) y--;
  28. if (orientacion == 2) y++;
  29. if (orientacion == 3) x++;
  30. if (orientacion == 4) x--;
  31.  
  32. if (orientacion == 1 && y == ls) {
  33. orientacion = 3;
  34. ls += 2;
  35. }
  36. if (orientacion == 2 && y == li) {
  37. orientacion = 4;
  38. li -= 2;
  39. }
  40. if (orientacion == 3 && x == ld) {
  41. orientacion = 2;
  42. ld -= 10;
  43. }
  44. if (orientacion == 4 && x == liz) {
  45. orientacion = 1;
  46. liz += 10;
  47. }
  48.  
  49.  
  50. }
  51. void erase() {
  52.  
  53. Console::SetCursorPosition(x, y);
  54. cout << " ";
  55. }
  56. void render() {
  57. Console::SetCursorPosition(x, y);
  58. cout << "@";
  59. }
  60.  
  61. int main()
  62. {
  63. Console::SetWindowSize(110, 30);
  64. Console::CursorVisible = false;
  65. while (1) {
  66. if (_kbhit()) {
  67. switch (_getch())
  68. {
  69. case 'x':
  70. start = true;
  71. break;
  72. default:
  73. break;
  74. }
  75. }
  76. erase();
  77. update();
  78. render();
  79. _sleep(10);
  80. }
  81. return 0;
  82. }
  83.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement