Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "pch.h"
- #include <iostream>
- #include <Windows.h>
- #include <conio.h>
- using namespace System;
- using namespace std;
- void dibujar(int x1, int y1, int x2, int y2, int x3, int y3 ) {
- Console::SetCursorPosition(x1, y1);
- cout << "*";
- Console::SetCursorPosition(x2, y2);
- cout << "*";
- Console::SetCursorPosition(x3, y3);
- cout << "*";
- }
- void actualizar(int &y1, int &x2, int &x3, int &y3, int &da, int &db, int &dxc, int &dyc, bool &a, bool &b, bool &c) {
- if (a) {
- y1 += da;
- if (y1 == 0 || y1 == 15) da *= -1;
- }
- if (b) {
- x2 += db;
- if (x2 == 0 || x2 == 115) db *= -1;
- }
- if (c) {
- x3 += dxc;
- y3 += dyc;
- if (y3 == 0 || y3 == 15) dyc *= -1;
- if (x3 == 0 || x3 == 115) dxc *= -1;
- }
- }
- void borrar(int x1, int y1, int x2, int y2, int x3, int y3) {
- Console::SetCursorPosition(x1, y1);
- cout << " ";
- Console::SetCursorPosition(x2, y2);
- cout << " ";
- Console::SetCursorPosition(x3, y3);
- cout << " ";
- }
- int main()
- {
- Console::CursorVisible = false;
- int x1 = 10, y1 = 10;
- int x2 = 50, y2 = 15;
- int x3 = 100, y3 = 4;
- bool a = false;
- bool b = false;
- bool c = false;
- int da = 1;
- int db = 1;
- int dxc = 1, dyc = 1;
- while (1) {
- if (_kbhit()) {
- switch (_getch())
- {
- case 'i':
- a = true;
- break;
- case 'c':
- b = true;
- break;
- case 'd':
- c = true;
- break;
- case 'p':
- a = false;
- b = false;
- c = false;
- break;
- }
- }
- borrar(x1, y1, x2, y2, x3, y3);
- actualizar( y1, x2, x3, y3, da, db, dxc, dyc, a, b, c);
- dibujar(x1,y1,x2,y2,x3,y3);
- _sleep(50);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement