Всем привет, это простое видео где вы увидите как создать консольное приложение на C++ (В котором можно сделать падение любого текста, так же матрицу и многое другое, + смена цвета!Код оставил под видео!!
Код:
Код
#include "stdafx.h"
#include <iostream>
#include <ctime>
#include <Windows.h>
using namespace std;
void gotoXY(int x, int y)
{
HANDLE hConsole;
COORD cursorLoc;
cout.flush();
cursorLoc.X = x;
cursorLoc.Y = y;
hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorPosition(hConsole, cursorLoc);
}
class Snow
{
public:
Snow(){ pos(); }
~Snow() { }
const int NotUsed = system("color 3");// смена цвета
void setPoint()
{
gotoXY(x, y);
cout << "$$$";// Надпись
}
void erasePoint()
{
gotoXY(x, y);
cout << ""; // Ну это как бы конец)
}
void movePoint(int ax)
{
x += ax;
y++;
if (x<1 || x>79 || y>24)
pos();
}
private:
int x, y;
void pos()
{
x = rand() % 80;// ну тут понятно что это
y = rand() % 24;
}
};
int main()
{
const int JLH_SNOW = 40;
int i, ax = 1;
srand((unsigned int)time(NULL));
Snow s[JLH_SNOW];
do
{
for (i = 0; i<JLH_SNOW; i++)
s[i].setPoint();
Sleep(100);// скорость падения
for (i = 0; i<JLH_SNOW; i++)
{
s[i].erasePoint();
s[i].movePoint(ax);
}
} while (1);
return 0;
}