5555// #include <unistd.h>
5656// #include <fcntl.h>
5757#include " getkeyboard.cpp"
58+ #include " defines.hpp"
5859using namespace std ;
5960
6061int display_log = 0 ;
@@ -155,13 +156,17 @@ string name;
155156
156157int win ()
157158{
159+ // SHOW_CURSOR();
158160 putlevel (level+1 );
159161 system (" clear" );
160162 int rcc = rand () % 6 ;
161163 printf (" %s! Your new level is: %d\n Play again? [Again : Enter / quit : q ]\n " ,winok[rcc],level+1 );
162164 while (1 ){
163165 int r=check (keyboard ());
164- if (r==9 )return 0 ;
166+ if (r==9 ){
167+ SHOW_CURSOR ();
168+ return 0 ;
169+ }
165170 else if (r==1 ||r==2 ||r==3 ||r==4 ||r==27 ||r==-1 )continue ;
166171 else if (r==13 )return 1 ;
167172 else {
@@ -297,7 +302,10 @@ int game(){
297302 if (fx==hx&&fy==hy){
298303 return win ();
299304 }
300- system (" clear" );
305+ // system("clear");
306+ MOVETO (1 ,1 );
307+ // printf (" User %s, level %d", name, level);
308+ cout << " Login as " << name << " , level is " << level << " . Good luck!\n " ;
301309 printf (" %s\n " , rce);
302310 strcpy (rce," " );
303311 for (int i=1 ;i<=n;i++){
@@ -314,6 +322,7 @@ int game(){
314322 cout<<endl;
315323 }
316324 printf (" \n Use 'UP''DOWN''LEFT''RIGHT' to contral 'H' to catch 'F'\n Press 'R' to restart game\n Press 'Q' to quit game\n " );
325+ MOVETO (1 ,1 );
317326 int r=check (keyboard ());
318327 // printf("%d\n",r);
319328 // sleep(1);
@@ -327,7 +336,7 @@ int game(){
327336 return 0 ;
328337 }
329338 if (r!=1 && r!=2 && r!=3 && r!=4 && r!=0 && r!=27 ){
330- system (" clear" );
339+ // system("clear");
331340 // printf("%s",ebox[4]);
332341 strcpy (rce,ebox[4 ]);
333342 // printf("%d",r);
@@ -337,7 +346,7 @@ int game(){
337346 }
338347 if (r>0 &&r<5 ){
339348 // move
340- system (" clear" );
349+ // system("clear");
341350 if (hx+nx[r]<=1 ||hx+nx[r]>n-1 ||hy+ny[r]<=1 ||hy+ny[r]>n-1 ){
342351 // printf("%s", ebox[1]);
343352 strcpy (rce,ebox[1 ]);
@@ -447,7 +456,10 @@ void start_game(){
447456 level=getlevel ();
448457 fx=n-1 ,fy=n-1 ,hx=2 ,hy=2 ;
449458 field[2 ][2 ]=5 ,field[n-1 ][n-1 ]=6 ;
459+ HIDE_CURSOR ();
450460 if (game ()==1 )start_game ();
461+ RESET_CURSOR ();
462+ SHOW_CURSOR ();
451463}
452464/*
453465
@@ -475,6 +487,7 @@ void findpalse(){
475487
476488void goodbye (){
477489 system (" clear" );
490+ SHOW_CURSOR ();
478491 // system ("rm -rf ~/.local/share/ohzff-zff && mv zffcc ~/.local/share/ohzff-zff");
479492 printlogo ();
480493 printf (" \n Exit Zff game.\n " );
0 commit comments