-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathThe_Matrix_Effect.cpp
50 lines (49 loc) · 1.12 KB
/
The_Matrix_Effect.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include<iostream>
#include<windows.h>
int Modulus(int iN, int iMod);
char GetChar(int iGenerator, char cBase, int iRange);
int main(){
// Color code
HANDLE hConsole;
hConsole=GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hConsole,2);
char caRow[80];
int j = 7;
int k = 2;
int l = 5;
int m = 1;
while (true) {
int i=0;
// Output a random row of characters
while (i<80) {
if (caRow[i] != ' ') {
caRow[i] = GetChar(j + i*i, 33, 30);
if (((i*i + k) % 71) == 0)
SetConsoleTextAttribute(hConsole, 7);
else
SetConsoleTextAttribute(hConsole, 2);
}
std::cout << caRow[i];
++i;
SetConsoleTextAttribute(hConsole, 2);
}
j = (j + 31);
k = (k + 17);
l = (l + 47);
m = (m + 67);
caRow[Modulus(j, 80)] = '-';
caRow[Modulus(k, 80)] = ' ';
caRow[Modulus(l, 80)] = '-';
caRow[Modulus(m, 80)] = ' ';
// Delay
Sleep(10);
}
return 0;
}
int Modulus(int iN, int iMod){
int iQ = (iN/iMod);
return iN - (iQ*iMod);
}
char GetChar(int iGenerator, char cBase, int iRange){
return (cBase + Modulus(iGenerator, iRange));
}