mirror of
https://github.com/PoetryInCode/matrix.git
synced 2026-08-13 11:24:40 -04:00
fixed/unified formatting
This commit is contained in:
parent
d94bcdf287
commit
8ae935be78
@ -1,2 +1,5 @@
|
||||
[Buildset]
|
||||
BuildItems=@Variant(\x00\x00\x00\t\x00\x00\x00\x00\x01\x00\x00\x00\x0b\x00\x00\x00\x00\x01\x00\x00\x00\x0c\x00m\x00a\x00t\x00r\x00i\x00x)
|
||||
|
||||
[Project]
|
||||
VersionControlSupport=kdevgit
|
||||
|
||||
160
src/main.c
160
src/main.c
@ -17,32 +17,30 @@
|
||||
#endif
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
WINDOW term = *initscr();
|
||||
start_color();
|
||||
init_pair(1,COLOR_GREEN,COLOR_BLACK);
|
||||
attron(COLOR_PAIR(1));
|
||||
noecho();
|
||||
if(nodelay(&term,TRUE)==ERR) {
|
||||
puts("Error could not enter no-delay mode");
|
||||
return ERR;
|
||||
}
|
||||
int time;
|
||||
if(argc >= 3) {
|
||||
time=atoi(argv[2]);
|
||||
} else {
|
||||
time=20;
|
||||
}
|
||||
timeout(time);
|
||||
WINDOW term = *initscr();
|
||||
start_color();
|
||||
init_pair(1,COLOR_GREEN,COLOR_BLACK);
|
||||
attron(COLOR_PAIR(1));
|
||||
noecho();
|
||||
if(nodelay(&term,TRUE)==ERR) {
|
||||
puts("Error could not enter no-delay mode");
|
||||
return ERR;
|
||||
}
|
||||
int time;
|
||||
if(argc >= 3) {
|
||||
time=atoi(argv[2]);
|
||||
} else {
|
||||
time=20;
|
||||
}
|
||||
timeout(time);
|
||||
int maxX = COLS;
|
||||
int maxY = LINES;
|
||||
|
||||
int initTailLen;
|
||||
if(argc >= 2) {
|
||||
int maxY = LINES;
|
||||
int initTailLen;
|
||||
if(argc >= 2) {
|
||||
initTailLen=atoi(argv[1]);
|
||||
} else {
|
||||
initTailLen=10;
|
||||
}
|
||||
|
||||
} else {
|
||||
initTailLen=10;
|
||||
}
|
||||
int tailLen[maxX];
|
||||
|
||||
for(int i=0; i<maxX; i++) {
|
||||
@ -55,83 +53,65 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int cascade[maxX];
|
||||
int tail[maxX];
|
||||
int cascade[maxX];
|
||||
int tail[maxX];
|
||||
int jmpTail[maxX];
|
||||
|
||||
for(int i=0; i<maxX; i++)
|
||||
cascade[i]=ERR;
|
||||
for(int i=0; i<maxX; i++)
|
||||
cascade[i]=ERR;
|
||||
|
||||
int pause = 0;
|
||||
int dir = DOWN;
|
||||
int limit = maxY;
|
||||
int startPos = 0;
|
||||
int get = getch();
|
||||
while(get!='q') {
|
||||
while(get!='q') {
|
||||
if(get=='s') {
|
||||
pause=TRUE;
|
||||
}
|
||||
int xPos = rand()%maxX;//get random x position for the stream
|
||||
if(cascade[xPos]==ERR) {//make sure the stream is set to active
|
||||
cascade[xPos]=startPos;
|
||||
int xPos = rand()%maxX;//get random x position for the stream
|
||||
if(cascade[xPos]==ERR) {//make sure the stream is set to active
|
||||
cascade[xPos]=startPos;
|
||||
}
|
||||
//---------swich to weird format-----------
|
||||
for(int i=0; i<maxX; i++)
|
||||
{//move the streams up/down
|
||||
if(!pause)
|
||||
{
|
||||
if(cascade[i]!=ERR)
|
||||
{
|
||||
for(int i=0; i<maxX; i++) {//move the streams up/down
|
||||
if(!pause) {
|
||||
if(cascade[i]!=ERR) {
|
||||
if(dir==DOWN) {
|
||||
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
|
||||
cascade[i]=ERR;//set the position to ERR if it is at the bottom
|
||||
}
|
||||
else
|
||||
{
|
||||
if(rand()%10==1)
|
||||
{//check if the stream will jump
|
||||
if(!(jmpTail[i]<=maxY))
|
||||
{
|
||||
if(dir==DOWN)
|
||||
{
|
||||
if(cascade[i]==limit) {//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
|
||||
} else {
|
||||
if(rand()%10==1) {//check if the stream will jump
|
||||
if(!(jmpTail[i]<=maxY)) {
|
||||
if(dir==DOWN) {
|
||||
cascade[i]=cascade[i]+rand()%8;
|
||||
jmpTail[i]=cascade[i]-tailLen[i];
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
cascade[i]=cascade[i]-rand()%8;
|
||||
jmpTail[i]=cascade[i]+tailLen[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(dir==DOWN)
|
||||
{
|
||||
} else {
|
||||
if(dir==DOWN) {
|
||||
cascade[i]++;//increase the position
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
cascade[i]--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//-------Back to normal format-------
|
||||
if(tail[i]!=limit) {//keep iterating the tail intill it is at the limit
|
||||
if(tail[i]!=limit) {//keep iterating the tail intill it is at the limit
|
||||
if(dir==DOWN) {
|
||||
tail[i]++;
|
||||
} else {
|
||||
tail[i]--;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(jmpTail[i]==maxY || jmpTail==0) {
|
||||
jmpTail[i]=OK;
|
||||
} else {
|
||||
@ -142,41 +122,41 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
}
|
||||
mvaddch(jmpTail[i],i,' ');
|
||||
mvaddch(tail[i],i,' ');
|
||||
mvaddch(cascade[i],i,(rand()%60)+65);
|
||||
}
|
||||
refresh();
|
||||
mvaddch(tail[i],i,' ');
|
||||
mvaddch(cascade[i],i,(rand()%60)+65);
|
||||
}
|
||||
refresh();
|
||||
if(!pause) {
|
||||
timeout(time);
|
||||
} else {
|
||||
timeout(-1);
|
||||
get=getch();
|
||||
switch (get) {
|
||||
case 's':
|
||||
pause=!pause;
|
||||
case 's':
|
||||
pause=!pause;
|
||||
break;
|
||||
case 'r':
|
||||
pause=FALSE;
|
||||
if(dir==DOWN) {
|
||||
dir=UP;
|
||||
limit=0;
|
||||
startPos=maxY;
|
||||
} else {
|
||||
dir=DOWN;
|
||||
limit=maxY;
|
||||
startPos=0;
|
||||
}
|
||||
case 'r':
|
||||
pause=FALSE;
|
||||
if(dir==DOWN) {
|
||||
dir=UP;
|
||||
limit=0;
|
||||
startPos=maxY;
|
||||
} else {
|
||||
dir=DOWN;
|
||||
limit=maxY;
|
||||
startPos=0;
|
||||
}
|
||||
break;
|
||||
case 'q':
|
||||
get='q';
|
||||
break;
|
||||
case 'q':
|
||||
get='q';
|
||||
break;
|
||||
}
|
||||
timeout(time);
|
||||
}
|
||||
if(get!='q') {
|
||||
get=getch();
|
||||
}
|
||||
}
|
||||
endwin();
|
||||
return 0;
|
||||
}
|
||||
endwin();
|
||||
return 0;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user