mirror of
https://github.com/PoetryInCode/matrix.git
synced 2026-08-13 11:24:40 -04:00
added functionality to reverse the directions of the streams
This commit is contained in:
parent
55eafb3988
commit
c9be7aa872
BIN
bin/matrix
BIN
bin/matrix
Binary file not shown.
24
src/main.c
24
src/main.c
@ -65,6 +65,8 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
int pause = 0;
|
int pause = 0;
|
||||||
int dir = DOWN;
|
int dir = DOWN;
|
||||||
|
int limit = maxY;
|
||||||
|
int startPos = 0;
|
||||||
int get = getch();
|
int get = getch();
|
||||||
while(get!='q') {
|
while(get!='q') {
|
||||||
if(get=='s') {
|
if(get=='s') {
|
||||||
@ -72,7 +74,7 @@ int main(int argc, char **argv) {
|
|||||||
}
|
}
|
||||||
int xPos = rand()%maxX;//get random x position for the stream
|
int xPos = rand()%maxX;//get random x position for the stream
|
||||||
if(cascade[xPos]==ERR) {//make sure the stream is set to active
|
if(cascade[xPos]==ERR) {//make sure the stream is set to active
|
||||||
cascade[xPos]=0;
|
cascade[xPos]=startPos;
|
||||||
}
|
}
|
||||||
//---------swich to weird format-----------
|
//---------swich to weird format-----------
|
||||||
for(int i=0; i<maxX; i++)
|
for(int i=0; i<maxX; i++)
|
||||||
@ -81,8 +83,12 @@ int main(int argc, char **argv) {
|
|||||||
{
|
{
|
||||||
if(cascade[i]!=ERR)
|
if(cascade[i]!=ERR)
|
||||||
{
|
{
|
||||||
tail[i] = cascade[i]-tailLen[i];
|
if(dir==DOWN) {
|
||||||
if(cascade[i]==maxY)
|
tail[i] = cascade[i]-tailLen[i];
|
||||||
|
} else {
|
||||||
|
tail[i] = cascade[i]+tailLen[i];
|
||||||
|
}
|
||||||
|
if(cascade[i]==limit)
|
||||||
{//check if the position is at the bottom of the screen
|
{//check if the position is at the bottom of the screen
|
||||||
cascade[i]=ERR;//set the position to ERR if it is at the bottom
|
cascade[i]=ERR;//set the position to ERR if it is at the bottom
|
||||||
}
|
}
|
||||||
@ -119,7 +125,7 @@ int main(int argc, char **argv) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//-------Back to normal format-------
|
//-------Back to normal format-------
|
||||||
if(tail[i]!=maxY) {//keep increasing the tail untill it is at the bottom
|
if(tail[i]!=limit) {//keep iterating the tail intill it is at the limit
|
||||||
if(dir==DOWN) {
|
if(dir==DOWN) {
|
||||||
tail[i]++;
|
tail[i]++;
|
||||||
} else {
|
} else {
|
||||||
@ -151,12 +157,14 @@ int main(int argc, char **argv) {
|
|||||||
break;
|
break;
|
||||||
case 'r':
|
case 'r':
|
||||||
pause=FALSE;
|
pause=FALSE;
|
||||||
if(dir=DOWN) {
|
if(dir==DOWN) {
|
||||||
dir=UP;
|
dir=UP;
|
||||||
|
limit=0;
|
||||||
|
startPos=maxY;
|
||||||
} else {
|
} else {
|
||||||
if(dir=UP) {
|
dir=DOWN;
|
||||||
dir=DOWN;
|
limit=maxY;
|
||||||
}
|
startPos=0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'q':
|
case 'q':
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user