Advertisement
appo

Source code matrix effect

Dec 27th, 2013
553
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.98 KB | None | 0 0
  1. #include <iostream>
  2. #include <windows.h>
  3.  
  4. int Modulus(int iN, int iMod) {
  5. int iQ = (iN/iMod);
  6. return iN - (iQ*iMod);
  7. }
  8.  
  9. char GetChar(int iGenerator, char cBase, int iRange) {
  10. return (cBase + Modulus(iGenerator, iRange));
  11. }
  12.  
  13. int main() {
  14. // reng kodu
  15. HANDLE  hConsole;
  16. hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
  17. SetConsoleTextAttribute(hConsole, 2);
  18.  
  19. char caRow[80];
  20. int j = 7;
  21. int k = 2;
  22. int l = 5;
  23. int m = 1;
  24. while (true) {
  25. int i = 0;
  26.  
  27. while (i < 80) {
  28. if (caRow[i] != ' ') {
  29. caRow[i] = GetChar(j + i*i, 33, 30);
  30. if (((i*i + k) % 71) == 0) {
  31. SetConsoleTextAttribute(hConsole,  7);
  32. } else {
  33. SetConsoleTextAttribute(hConsole,  2);
  34. }
  35. }
  36. std::cout << caRow[i];
  37. ++i;
  38. SetConsoleTextAttribute(hConsole,  2);
  39. }
  40. j = (j + 31);
  41. k = (k + 17);
  42. l = (l + 47);
  43. m = (m + 67);
  44. caRow[Modulus(j, 80)] = '-';
  45. caRow[Modulus(k, 80)] = ' ';
  46. caRow[Modulus(l, 80)] = '-';
  47. caRow[Modulus(m, 80)] = ' ';
  48.  
  49. Sleep(10);
  50. }
  51.     return 0;
  52. }
  53.  
  54. // IMG -->  http://i.imgur.com/xoYdOUi.jpg
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement