|
Random Matrix char output
|
|
02-26-2010, 09:51 PM
(This post was last modified: 02-26-2010 09:54 PM by drdebcol.)
Post: #1
|
|||
|
|||
|
Random Matrix char output
This is interesting program, it actually makes some kind of movement in C++.
It is not perfect, but it can be considered as an introduction into core game programming in C++ (i mean manipulation with characters). It is not the same output as in Matrix movie, that kind i made here in Delphi : http://www.pro9ramming.com/new-matrix-sc...t-955.html It is output of random characters on random places. You can see it in the picture : ![]() I used 2-dimensional array or matrix "of unsigned short int". Time is set to 1/4 of a second or 250 mili-seconds. For that delay time i used sleep() function which i made, you have it here : http://www.pro9ramming.com/sleep-functio...t-965.html It generates random chars, or better said it generates numbers (0..255) and outputs them as chars. For generating them i used random() function, you have it here : http://www.pro9ramming.com/random-functi...-1140.html And for looping of frames or screens (every 1/4 seconds) i used label and goto, you have it here : http://www.pro9ramming.com/c-label-and-goto-t-961.html So it basically fills random chars on random places in 2-dimensional array or matrix every 1/4 seconds and outputs that on the screen. And another explanation would be width and height of screen. Well i just counted chars that can be outputted in one line and row. So there are 24 lines in which you can put 79 characters. That is standard size of Dev-Cpp window. Because i used system("cls") the command for cleaning screen, it can maybe look flashy because that is slow command. And for text color i used system() function and standard color method used in batch files (so this only works on Windows). color method is used like this : COLOR [attr] Sets the default console foreground and background colors. Color attributes are specified by TWO hex digits -- the first corresponds to the background; the second the foreground (text). Each digit can be any of the following values: Code: 0 = Black 8 = Graywhen CMD.EXE started. This value either comes from the current console window, the /T command line switch or from the DefaultColor registry value. That would be all about explanations and now the code : Code: # include <iostream>I hope that you like it ! "I dont know with what weapons World War 3 will be fought with, but i know World War 4 will be fought with stones and sticks" - Albert Einstein |
|||
|
02-27-2010, 04:16 PM
Post: #2
|
|||
|
|||
|
RE: Random Matrix char output
Nice share dude.
I definitely like it! |
|||
|
02-27-2010, 05:14 PM
Post: #3
|
|||
|
|||
|
RE: Random Matrix char output
If you like the way above, Maybe you'll like this too :
http://www.pro9ramming.com/something-rea...t-966.html It is not movement, just an ordinary picture, but it took me some time to make ! "I dont know with what weapons World War 3 will be fought with, but i know World War 4 will be fought with stones and sticks" - Albert Einstein |
|||
|
« Next Oldest | Next Newest »
|




![[Image: 42610_matrixrandomchars.jpg]](http://myph.us/pics/42610_matrixrandomchars.jpg)



