Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mx=randi([1,8]);
- my=randi([1,8]);
- score=0;
- x=5;
- y=5;
- w=10;
- h=10;
- while 1
- for n = 1:100; clc; printf ("\n"); end
- % S 115 W 119 A 97 D 100
- for yy=1:h
- for xx=1:w
- if xx==x && yy==y
- fprintf(stdout, "X.");
- elseif xx==mx && yy==my
- fprintf(stdout, "@.");
- else
- fprintf(stdout, " .");
- end
- end
- fprintf(stdout, "\n");
- end
- fprintf(stdout, "\nPunkciory: %i\n",score);
- key=kbhit();
- if key==115
- y++;
- end
- if key==119
- y--;
- end
- if key==97
- x--;
- end
- if key==100
- x++;
- end
- if key==107
- exit
- end
- if x<1
- x=1;
- end
- if y<1
- y=1;
- end
- if x>w
- x=w;
- end
- if y>h
- y=h;
- end
- if x==mx && y==my
- score++;
- mx=randi([1,8]);
- my=randi([1,8]);
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement