Skip to content

Commit

Permalink
More common controls
Browse files Browse the repository at this point in the history
  • Loading branch information
abakh committed Feb 2, 2022
1 parent aaf092d commit 2199c6e
Show file tree
Hide file tree
Showing 17 changed files with 34 additions and 34 deletions.
6 changes: 3 additions & 3 deletions battleship.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ void set_the_board(bool side){
++px;
if( input=='\n'||input==KEY_ENTER )
break;
if( input=='q' )
if( (input=='q'||input==27) )
sigint_handler(EXIT_SUCCESS);
}

Expand Down Expand Up @@ -603,7 +603,7 @@ int main(int argc,char** argv){
input=getch();
if(input == KEY_F(1) || input=='?' )
help(turn);
if(input == KEY_F(2) )
if((input==KEY_F(2)||input=='!') )
gameplay(turn);
if(input == KEY_MOUSE)
mouseinput(1);
Expand All @@ -615,7 +615,7 @@ int main(int argc,char** argv){
--px;
if( (input=='l' || (input==KEY_RIGHT||input=='d')) && px<19)
++px;
if( input=='q')
if( (input=='q'||input==27))
sigint_handler(EXIT_SUCCESS);
if( input=='\n' || input==KEY_ENTER){
byte r=shoot(turn,py,px-10);
Expand Down
4 changes: 2 additions & 2 deletions checkers.c
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ int main(int argc,char** argv){
input=getch();
if( input == KEY_F(1) || input=='?' )
help();
if( input == KEY_F(2) )
if( (input==KEY_F(2)||input=='!') )
gameplay();
if( input == KEY_MOUSE )
mouseinput();
Expand All @@ -673,7 +673,7 @@ int main(int argc,char** argv){
--px;
if( (input=='l' || (input==KEY_RIGHT||input=='d')) && px<7)
++px;
if( input=='q'){
if( (input=='q'||input==27)){
result=2;
goto End;
}
Expand Down
4 changes: 2 additions & 2 deletions fifteen.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ int main(int argc, char** argv){
input = getch();
if( input==KEY_F(1) || input=='?' )
help();
if( input==KEY_F(2) )
if( (input==KEY_F(2)||input=='!') )
gameplay();
if( input==KEY_MOUSE )
mouseinput();
Expand All @@ -258,7 +258,7 @@ int main(int argc, char** argv){
--px;
if( (input=='l' || (input==KEY_RIGHT||input=='d')) && px<size-1)
++px;
if( input=='q')
if( (input=='q'||input==27))
sigint_handler(0);
if(input=='\n'||input==KEY_ENTER){
slide_multi(board,py,px);
Expand Down
2 changes: 1 addition & 1 deletion fisher.c
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ int main(int argc,char** argv){
}
if(input=='?' || input==KEY_F(1))
help();
if(input=='q')
if((input=='q'||input==27))
break;
if(!hooknum)
break;
Expand Down
2 changes: 1 addition & 1 deletion jewels.c
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ int main(int argc,char** argv){
getch();
halfdelay(DELAY);
}
else if(input=='q')
else if((input=='q'||input==27))
goto Lose;
else if(input==' ')
while( (falls=fall()) )
Expand Down
4 changes: 2 additions & 2 deletions memoblocks.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ int main(int argc,char** argv){
input = getch();
if( input==KEY_F(1) || input=='?' )
help();
if( input==KEY_F(2) )
if( (input==KEY_F(2)||input=='!') )
gameplay();
if( input==KEY_MOUSE )
mouseinput();
Expand All @@ -232,7 +232,7 @@ int main(int argc,char** argv){
--px;
if( (input=='l' || (input==KEY_RIGHT||input=='d')) && px<size2-1)
++px;
if( input=='q')
if( (input=='q'||input==27))
sigint_handler(0);
if(input=='\n' || input==KEY_ENTER){
if(fy!=-1 && board[py][px]==board[fy][fx] && !(fy==py && fx==px) )
Expand Down
4 changes: 2 additions & 2 deletions miketron.c
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ int main(int argc,char** argv){
}
if( input == KEY_F(1) || input=='?' )
help();
if( input == KEY_F(2) )
if( (input==KEY_F(2)||input=='!') )
gameplay();
halfspeed=!halfspeed;
if( (input=='k' || (input==KEY_UP||input=='w')) ){
Expand All @@ -454,7 +454,7 @@ int main(int argc,char** argv){
direction=LEFT;
else if( (input=='l' || (input==KEY_RIGHT||input=='d')) )
direction=RIGHT;
if( input=='q')
if( (input=='q'||input==27))
sigint_handler(0);
if(input=='e'){
for(int b=0;b<6;++b){
Expand Down
4 changes: 2 additions & 2 deletions mines.c
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ int main(int argc, char** argv){
}
if( input==KEY_F(1) || input=='?' )
help();
if( input==KEY_F(2) )
if( (input==KEY_F(2)||input=='!') )
gameplay();
if( input==KEY_MOUSE )
mouseinput(sy,sx);
Expand All @@ -372,7 +372,7 @@ int main(int argc, char** argv){
--px;
if( (input=='l' || (input==KEY_RIGHT||input=='d')) && px<wid-1)
++px;
if( input=='q')
if( (input=='q'||input==27))
sigint_handler(0);
if(input=='x' && getch()=='y' && getch()=='z' && getch()=='z' && getch()=='y' ){
if(first_click){
Expand Down
4 changes: 2 additions & 2 deletions muncher.c
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ int main(int argc, char** argv){
input = getch();
if( input == KEY_F(1) || input=='?' )
help();
if( input==KEY_F(2) )
if( (input==KEY_F(2)||input=='!') )
gameplay();
if( (input=='k' || (input==KEY_UP||input=='w')) && py>0 ){
direction=UP;
Expand All @@ -369,7 +369,7 @@ int main(int argc, char** argv){
direction=RIGHT;
if( input=='e')
epilepsy=1;
if( input=='q')
if( (input=='q'||input==27))
sigint_handler(0);
if( input=='p'){
nocbreak();
Expand Down
2 changes: 1 addition & 1 deletion nbsdgames.c
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ int menu(char* entries,char* title){
if(input=='\n'){
return chosen;
}
if(input=='q'){
if((input=='q'||input==27)){
return -1;
}
goto Refresh;
Expand Down
6 changes: 3 additions & 3 deletions pipes.c
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ int main(int argc, char** argv){
if(!flow)
tstart += time(NULL)-now;
}
if( input == KEY_F(2) ){
if( (input==KEY_F(2)||input=='!') ){
gameplay();
if(!flow)
tstart += time(NULL)-now;
Expand Down Expand Up @@ -436,13 +436,13 @@ int main(int argc, char** argv){
flow=1;
if( score < -1000)
goto End;
if( input=='q'){
if( (input=='q'||input==27)){
nocbreak();
cbreak();
curs_set(1);
mvprintw(len+2,0,"Do you want to see the high scores?(y/n)");
input=getch();
if(input == 'N' || input=='n' || input =='q')
if(input == 'N' || input=='n' || (input=='q'||input==27))
sigint_handler(EXIT_SUCCESS);

show_scores(save_score());
Expand Down
4 changes: 2 additions & 2 deletions rabbithole.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ int main(int argc,char** argv){
if(sx< -(wid*2+1))
sx=-(wid*2+1);
}
if( input == KEY_F(2) )
if( (input==KEY_F(2)||input=='!') )
gameplay();
if( input == KEY_F(1) || input=='?' )
help();
Expand All @@ -284,7 +284,7 @@ int main(int argc,char** argv){
--px;
if( (input=='l' || (input==KEY_RIGHT||input=='d')) && px<wid-1 && (board[py][px]&RIGHT) )
++px;
if( input=='q')
if( (input=='q'||input==27))
sigint_handler(0);
if( board[py][px] & CARROT ){
++carrots_found;
Expand Down
6 changes: 3 additions & 3 deletions redsquare.c
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ int main(int argc,char** argv){

if( input==KEY_F(1) || input=='?' )
help();
if( input==KEY_F(2) )
if( (input==KEY_F(2)||input=='!') )
gameplay();
prey=py;
prex=px;
Expand Down Expand Up @@ -610,7 +610,7 @@ int main(int argc,char** argv){
mk_square(board);
}
DidntMove:
if( input=='q'){
if( (input=='q'||input==27)){
sigint_handler(0);
}
if( input=='p'){
Expand All @@ -630,7 +630,7 @@ int main(int argc,char** argv){
if( input=='?' || input==KEY_F(1)){
help();
}
if( input=='!' || input==KEY_F(2)){
if( input=='!' || (input==KEY_F(2)||input=='!')){
gameplay();
}
}
Expand Down
4 changes: 2 additions & 2 deletions reversi.c
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ int main(int argc , char** argv){
input=getch();
if( input==KEY_F(1) || input=='?' )
help();
if( input==KEY_F(2) )
if( (input==KEY_F(2)||input=='!') )
gameplay();
if( input==KEY_MOUSE )
mouseinput();
Expand All @@ -407,7 +407,7 @@ int main(int argc , char** argv){
--px;
if( (input=='l' || (input==KEY_RIGHT||input=='d')) && px<7)
++px;
if( input=='q'){
if( (input=='q'||input==27)){
resign=1;
goto End;
}
Expand Down
4 changes: 2 additions & 2 deletions snakeduel.c
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ int main(int argc, char** argv){
input = getch();
if( input == KEY_F(1) || input=='?' )
help();
if( input==KEY_F(2) )
if( (input==KEY_F(2)||input=='!') )
gameplay();
if( (input=='k' || (input==KEY_UP||input=='w')) && p.y>0 && p.direction != DOWN ){
p.direction=UP;
Expand All @@ -720,7 +720,7 @@ int main(int argc, char** argv){
if( (input=='l' || (input==KEY_RIGHT||input=='d')) && p.x<wid-1 && p.direction != LEFT){
p.direction=RIGHT;
}
if( input=='q')
if( (input=='q'||input==27))
sigint_handler(0);
if( input=='p'){
nocbreak();
Expand Down
4 changes: 2 additions & 2 deletions sos.c
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ int main(int argc, char** argv){
}
if( input==KEY_F(1) || input=='?')
help();
if( input==KEY_F(2) )
if( (input==KEY_F(2)||input=='!') )
gameplay();
if( input==KEY_MOUSE )
mouseinput(sy,sx);
Expand All @@ -411,7 +411,7 @@ int main(int argc, char** argv){
--px;
if( (input=='l' || (input==KEY_RIGHT||input=='d')) && px<wid-1)
++px;
if( input=='q')
if( (input=='q'||input==27))
sigint_handler(0);
if(!board[py][px] && (input=='s'||input=='S'||input=='o'||input=='O') ){
if(input=='s'||input=='S')
Expand Down
4 changes: 2 additions & 2 deletions sudoku.c
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ int main(int argc,char** argv){
}
if(input == KEY_F(1))
help();
if(input == KEY_F(2))
if((input==KEY_F(2)||input=='!'))
gameplay();
if(input == KEY_MOUSE)
mouseinput(sy,sx);
Expand All @@ -508,7 +508,7 @@ int main(int argc,char** argv){
else if(input<=CHAR_MAX && sgn2int(input) && sgn2int(input)<=s )
game[py][px]=input;
}
if( (input=='q' && size<= 5) || input=='Q')
if( ((input=='q'||input==27) && size<= 5) || input=='Q')
sigint_handler(EXIT_SUCCESS);
if(input=='n'&& size <= 4)
goto Start;
Expand Down

0 comments on commit 2199c6e

Please sign in to comment.