Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Matrix in CMD [Source][C++]
#1
Thought I'd share this source with you guys, difficulty is... mediocre I guess, but it's very epic nonetheless .

Code:
#include <ctime>
#include <cstdlib>
#include <iostream>
#include <windows.h>
using namespace std;

int main()
{
   //green color for text
   system("color 0a");

   //random seed
   srand(time(0));

   char random_char = ((rand() % 127));
   bool going = true, checking = true;

   while (going = true)
   {
      //draw row of characters (38 characters)
      for (int x = 0; x < 38; x++)
      {
         //generate first char
         random_char = ((rand() % 127) + 50);
         checking = true;
         while (checking)
         {
            if  ( //check for:
               // Bad/Small characters.
                  (random_char == 32) || (random_char == 39) || (random_char == 46) ||
                  (random_char == 44) || (random_char == 34) || (random_char == 45) ||
                  (random_char == 58) || (random_char == 59) || (random_char == 94) ||
                  (random_char == 95) || (random_char == 96) || (random_char == 126)
               // If bad character is generated -> generate new random character and check if it is bad
                )
            random_char = ((rand() % 127) + 50);

            //Good character found -> Continue to print it
            else break;
         }
         //Print character + white space
         cout << random_char << " ";
      }
      //Full row of characters successfully printed -> continue for next row
      cout << endl;

      //Delay
      Sleep(20);
   }
   cin.get();
   return 0;
}
Victoire
Reply


Messages In This Thread
Matrix in CMD [Source][C++] - by devilishpsp - 09-15-2011, 04:39 AM
RE: Matrix in CMD [Source][C++] - by RiXXoN - 09-15-2011, 04:59 AM
RE: Matrix in CMD [Source][C++] - by devilishpsp - 09-15-2011, 05:13 AM
RE: Matrix in CMD [Source][C++] - by +Awesome - 09-20-2011, 01:39 AM
RE: Matrix in CMD [Source][C++] - by AceInfinity - 09-20-2011, 03:06 AM
RE: Matrix in CMD [Source][C++] - by AceInfinity - 01-08-2012, 07:11 AM
RE: Matrix in CMD [Source][C++] - by AlbinoShadow - 01-10-2012, 04:13 PM
RE: Matrix in CMD [Source][C++] - by AceInfinity - 01-10-2012, 06:05 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)