Advertisement
sebasvp2005

Untitled

Apr 30th, 2024
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. #include "pch.h"
  2. #include <iostream>
  3.  
  4. using namespace System;
  5. using namespace std;
  6.  
  7. int x1 = 10, y1 = 10;
  8. int x2= 50 , y2 = 15;
  9. int x3 = 100, y3 = 4;
  10.  
  11. bool a = false;
  12. bool b = false;
  13. bool c = false;
  14.  
  15. int da = 1;
  16. int db = 1;
  17. int dxc = 1, dyc = 1;
  18.  
  19.  
  20.  
  21.  
  22. void dibujar() {
  23. Console::SetCursorPosition(x1, y1);
  24. cout << "*";
  25. Console::SetCursorPosition(x2, y2);
  26. cout << "*";
  27. Console::SetCursorPosition(x3, y3);
  28. cout << "*";
  29. }
  30.  
  31. void actualizar() {
  32. if (a) {
  33. y1 += da;
  34. if (y1 == 0 || y1 == 15) da *= -1;
  35. }
  36. if (b) {
  37. x2 += db;
  38. if (x2 == 0 || x2 == 115) db *= -1;
  39. }
  40. if (c) {
  41. x3 += dxc;
  42. y3 += dyc;
  43. if (y3 == 0 || y3 == 15) dyc *= -1;
  44. if (x3 == 0 || x3 == 115) dxc *= -1;
  45. }
  46. }
  47.  
  48. void borrar() {
  49. Console::SetCursorPosition(x1, y1);
  50. cout << " ";
  51. Console::SetCursorPosition(x2, y2);
  52. cout << " ";
  53. Console::SetCursorPosition(x3, y3);
  54. cout << " ";
  55. }
  56.  
  57.  
  58.  
  59.  
  60.  
  61. int main()
  62. {
  63. while (1) {
  64.  
  65. borrar();
  66. actualizar();
  67. dibujar();
  68.  
  69. _sleep(50);
  70. }
  71.  
  72. return 0;
  73. }
  74.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement