Skip to content

Commit

Permalink
wasd support
Browse files Browse the repository at this point in the history
  • Loading branch information
abakh committed Feb 2, 2022
1 parent c5eee81 commit aaf092d
Show file tree
Hide file tree
Showing 19 changed files with 72 additions and 72 deletions.
16 changes: 8 additions & 8 deletions battleship.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,13 +257,13 @@ void set_the_board(bool side){
input = getch();
if( input == KEY_MOUSE )
mouseinput(0);
if( (input=='k' || input==KEY_UP) && py>0)
if( (input=='k' || (input==KEY_UP||input=='w')) && py>0)
--py;
if( (input=='j' || input==KEY_DOWN) && py<9)
if( (input=='j' || (input==KEY_DOWN||input=='s')) && py<9)
++py;
if( (input=='h' || input==KEY_LEFT) && px>0)
if( (input=='h' || (input==KEY_LEFT||input=='a')) && px>0)
--px;
if( (input=='l' || input==KEY_RIGHT) && px<9)
if( (input=='l' || (input==KEY_RIGHT||input=='d')) && px<9)
++px;
if( input=='\n'||input==KEY_ENTER )
break;
Expand Down Expand Up @@ -607,13 +607,13 @@ int main(int argc,char** argv){
gameplay(turn);
if(input == KEY_MOUSE)
mouseinput(1);
if( (input=='k' || input==KEY_UP) && py>0)
if( (input=='k' || (input==KEY_UP||input=='w')) && py>0)
--py;
if( (input=='j' || input==KEY_DOWN) && py<9)
if( (input=='j' || (input==KEY_DOWN||input=='s')) && py<9)
++py;
if( (input=='h' || input==KEY_LEFT) && px>10)
if( (input=='h' || (input==KEY_LEFT||input=='a')) && px>10)
--px;
if( (input=='l' || input==KEY_RIGHT) && px<19)
if( (input=='l' || (input==KEY_RIGHT||input=='d')) && px<19)
++px;
if( input=='q')
sigint_handler(EXIT_SUCCESS);
Expand Down
8 changes: 4 additions & 4 deletions checkers.c
Original file line number Diff line number Diff line change
Expand Up @@ -665,13 +665,13 @@ int main(int argc,char** argv){
gameplay();
if( input == KEY_MOUSE )
mouseinput();
if( (input=='k' || input==KEY_UP) && py>0)
if( (input=='k' || (input==KEY_UP||input=='w')) && py>0)
--py;
if( (input=='j' || input==KEY_DOWN) && py<7)
if( (input=='j' || (input==KEY_DOWN||input=='s')) && py<7)
++py;
if( (input=='h' || input==KEY_LEFT) && px>0)
if( (input=='h' || (input==KEY_LEFT||input=='a')) && px>0)
--px;
if( (input=='l' || input==KEY_RIGHT) && px<7)
if( (input=='l' || (input==KEY_RIGHT||input=='d')) && px<7)
++px;
if( input=='q'){
result=2;
Expand Down
4 changes: 2 additions & 2 deletions darrt.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ void show_scores(byte playerrank){
refresh();
do{
input=getch();
}while(input==KEY_UP || input==KEY_DOWN);
}while((input==KEY_UP||input=='w') || (input==KEY_DOWN||input=='s'));
filled_rect(0,0,LEN,WID);
red_border();
}
Expand Down Expand Up @@ -432,7 +432,7 @@ int main(int argc,char** argv){
attroff(colors[0]|A_STANDOUT);
do{
input=getch();
}while(input==KEY_UP || input==KEY_DOWN);
}while((input==KEY_UP||input=='w') || (input==KEY_DOWN||input=='s'));
if(input!='q' && input!='n' && input!='N')
goto Start;
endwin();
Expand Down
8 changes: 4 additions & 4 deletions fifteen.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,13 +250,13 @@ int main(int argc, char** argv){
gameplay();
if( input==KEY_MOUSE )
mouseinput();
if( (input=='k' || input==KEY_UP) && py>0)
if( (input=='k' || (input==KEY_UP||input=='w')) && py>0)
--py;
if( (input=='j' || input==KEY_DOWN) && py<size-1)
if( (input=='j' || (input==KEY_DOWN||input=='s')) && py<size-1)
++py;
if( (input=='h' || input==KEY_LEFT) && px>0)
if( (input=='h' || (input==KEY_LEFT||input=='a')) && px>0)
--px;
if( (input=='l' || input==KEY_RIGHT) && px<size-1)
if( (input=='l' || (input==KEY_RIGHT||input=='d')) && px<size-1)
++px;
if( input=='q')
sigint_handler(0);
Expand Down
8 changes: 4 additions & 4 deletions fisher.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ void show_scores(byte playerrank){
refresh();
do{
input=getch();
}while(input==KEY_UP || input==KEY_DOWN);
}while((input==KEY_UP||input=='w') || (input==KEY_DOWN||input=='s'));
filled_rect(0,0,LEN,WID);
green_border();
}
Expand Down Expand Up @@ -329,7 +329,7 @@ int main(int argc,char** argv){
if(rand()%(14-n)==0)//this is to make it stop
stop[n]=1;
}
if(input==KEY_UP){
if((input==KEY_UP||input=='w')){
if(hook>0)
--hook;
if(hook==0 && caught!=-1){
Expand All @@ -340,7 +340,7 @@ int main(int argc,char** argv){
caught=-1;
}
}
if(input==KEY_DOWN){
if((input==KEY_DOWN||input=='s')){
if(hook<11)
++hook;
if(fish[hook-1]==40 && caught==-1){
Expand Down Expand Up @@ -372,7 +372,7 @@ int main(int argc,char** argv){
attroff(colors[2]);
do{
input=getch();
}while(input==KEY_UP || input==KEY_DOWN);
}while((input==KEY_UP||input=='w') || (input==KEY_DOWN||input=='s'));
if(input!='q' && input!='n' && input!='N')
goto Start;
endwin();
Expand Down
6 changes: 3 additions & 3 deletions jewels.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,11 +305,11 @@ int main(int argc,char** argv){
falls=fall();
stop=0;
}
else if(input=='l' || input==KEY_RIGHT)
else if(input=='l' || (input==KEY_RIGHT||input=='d'))
jmove(0,+1);
else if(input=='j' || input==KEY_LEFT )
else if(input=='j' || (input==KEY_LEFT||input=='a') )
jmove(0,-1);
else if(input=='k' || input==KEY_UP)
else if(input=='k' || (input==KEY_UP||input=='w'))
rotate();
else if(input=='p'){
mvaddstr(LINES-2,COLS/2-15,"Paused - Press a key to continue ");
Expand Down
8 changes: 4 additions & 4 deletions memoblocks.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,13 +224,13 @@ int main(int argc,char** argv){
gameplay();
if( input==KEY_MOUSE )
mouseinput();
if( (input=='k' || input==KEY_UP) && py>0)
if( (input=='k' || (input==KEY_UP||input=='w')) && py>0)
--py;
if( (input=='j' || input==KEY_DOWN) && py<size-1)
if( (input=='j' || (input==KEY_DOWN||input=='s')) && py<size-1)
++py;
if( (input=='h' || input==KEY_LEFT) && px>0)
if( (input=='h' || (input==KEY_LEFT||input=='a')) && px>0)
--px;
if( (input=='l' || input==KEY_RIGHT) && px<size2-1)
if( (input=='l' || (input==KEY_RIGHT||input=='d')) && px<size2-1)
++px;
if( input=='q')
sigint_handler(0);
Expand Down
8 changes: 4 additions & 4 deletions miketron.c
Original file line number Diff line number Diff line change
Expand Up @@ -442,17 +442,17 @@ int main(int argc,char** argv){
if( input == KEY_F(2) )
gameplay();
halfspeed=!halfspeed;
if( (input=='k' || input==KEY_UP) ){
if( (input=='k' || (input==KEY_UP||input=='w')) ){
direction=UP;
halfspeed=1;
}
else if( (input=='j' || input==KEY_DOWN) ){
else if( (input=='j' || (input==KEY_DOWN||input=='s')) ){
direction=DOWN;
halfspeed=1;
}
else if( (input=='h' || input==KEY_LEFT) )
else if( (input=='h' || (input==KEY_LEFT||input=='a')) )
direction=LEFT;
else if( (input=='l' || input==KEY_RIGHT) )
else if( (input=='l' || (input==KEY_RIGHT||input=='d')) )
direction=RIGHT;
if( input=='q')
sigint_handler(0);
Expand Down
8 changes: 4 additions & 4 deletions mines.c
Original file line number Diff line number Diff line change
Expand Up @@ -364,13 +364,13 @@ int main(int argc, char** argv){
gameplay();
if( input==KEY_MOUSE )
mouseinput(sy,sx);
if( (input=='k' || input==KEY_UP) && py>0)
if( (input=='k' || (input==KEY_UP||input=='w')) && py>0)
--py;
if( (input=='j' || input==KEY_DOWN) && py<len-1)
if( (input=='j' || (input==KEY_DOWN||input=='s')) && py<len-1)
++py;
if( (input=='h' || input==KEY_LEFT) && px>0)
if( (input=='h' || (input==KEY_LEFT||input=='a')) && px>0)
--px;
if( (input=='l' || input==KEY_RIGHT) && px<wid-1)
if( (input=='l' || (input==KEY_RIGHT||input=='d')) && px<wid-1)
++px;
if( input=='q')
sigint_handler(0);
Expand Down
8 changes: 4 additions & 4 deletions muncher.c
Original file line number Diff line number Diff line change
Expand Up @@ -355,17 +355,17 @@ int main(int argc, char** argv){
help();
if( input==KEY_F(2) )
gameplay();
if( (input=='k' || input==KEY_UP) && py>0 ){
if( (input=='k' || (input==KEY_UP||input=='w')) && py>0 ){
direction=UP;
halfspeed=1;
}
if( (input=='j' || input==KEY_DOWN) && py<len-1 ){
if( (input=='j' || (input==KEY_DOWN||input=='s')) && py<len-1 ){
direction=DOWN;
halfspeed=1;
}
if( (input=='h' || input==KEY_LEFT) && px>0 )
if( (input=='h' || (input==KEY_LEFT||input=='a')) && px>0 )
direction=LEFT;
if( (input=='l' || input==KEY_RIGHT) && px<wid-1 )
if( (input=='l' || (input==KEY_RIGHT||input=='d')) && px<wid-1 )
direction=RIGHT;
if( input=='e')
epilepsy=1;
Expand Down
4 changes: 2 additions & 2 deletions nbsdgames.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,10 +273,10 @@ int menu(char* entries,char* title){
refresh();
int input=0;
input=getch();
if(input==KEY_UP){
if((input==KEY_UP||input=='w')){
--chosen;
}
if(input==KEY_DOWN){
if((input==KEY_DOWN||input=='s')){
++chosen;
}
if(input=='\n'){
Expand Down
8 changes: 4 additions & 4 deletions pipes.c
Original file line number Diff line number Diff line change
Expand Up @@ -394,13 +394,13 @@ int main(int argc, char** argv){
}
if( input == KEY_MOUSE )
mouseinput();
if( (input=='k' || input==KEY_UP) && py>0 )
if( (input=='k' || (input==KEY_UP||input=='w')) && py>0 )
--py;
if( (input=='j' || input==KEY_DOWN) && py<len-1 )
if( (input=='j' || (input==KEY_DOWN||input=='s')) && py<len-1 )
++py;
if( (input=='h' || input==KEY_LEFT) && px>0 )
if( (input=='h' || (input==KEY_LEFT||input=='a')) && px>0 )
--px;
if( (input=='l' || input==KEY_RIGHT) && px<wid-1 )
if( (input=='l' || (input==KEY_RIGHT||input=='d')) && px<wid-1 )
++px;
if( (input == '\n'||input==KEY_ENTER) && !(board[py][px] & FILLED) ){
if(board[py][px])
Expand Down
8 changes: 4 additions & 4 deletions rabbithole.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,13 +276,13 @@ int main(int argc,char** argv){
gameplay();
if( input == KEY_F(1) || input=='?' )
help();
if( (input=='k' || input==KEY_UP) && py>0 && (board[py][px]&UP) )
if( (input=='k' || (input==KEY_UP||input=='w')) && py>0 && (board[py][px]&UP) )
--py;
if( (input=='j' || input==KEY_DOWN) && py<len-1 && (board[py][px]&DOWN) )
if( (input=='j' || (input==KEY_DOWN||input=='s')) && py<len-1 && (board[py][px]&DOWN) )
++py;
if( (input=='h' || input==KEY_LEFT) && px>0 && (board[py][px]&LEFT) )
if( (input=='h' || (input==KEY_LEFT||input=='a')) && px>0 && (board[py][px]&LEFT) )
--px;
if( (input=='l' || input==KEY_RIGHT) && px<wid-1 && (board[py][px]&RIGHT) )
if( (input=='l' || (input==KEY_RIGHT||input=='d')) && px<wid-1 && (board[py][px]&RIGHT) )
++px;
if( input=='q')
sigint_handler(0);
Expand Down
8 changes: 4 additions & 4 deletions redsquare.c
Original file line number Diff line number Diff line change
Expand Up @@ -583,22 +583,22 @@ int main(int argc,char** argv){
gameplay();
prey=py;
prex=px;
if(input=='k' || input==KEY_UP){
if(input=='k' || (input==KEY_UP||input=='w')){
--py;
if(py==-1)
py=LEN-1;
}
else if(input=='j' || input==KEY_DOWN){
else if(input=='j' || (input==KEY_DOWN||input=='s')){
++py;
if(py==LEN)
py=0;
}
else if(input=='h' || input==KEY_LEFT){
else if(input=='h' || (input==KEY_LEFT||input=='a')){
--px;
if(px==-1)
px=WID-1;
}
else if(input=='l' || input==KEY_RIGHT){
else if(input=='l' || (input==KEY_RIGHT||input=='d')){
++px;
if(px==WID)
px=0;
Expand Down
8 changes: 4 additions & 4 deletions reversi.c
Original file line number Diff line number Diff line change
Expand Up @@ -399,13 +399,13 @@ int main(int argc , char** argv){
gameplay();
if( input==KEY_MOUSE )
mouseinput();
if( (input=='k' || input==KEY_UP) && py>0)
if( (input=='k' || (input==KEY_UP||input=='w')) && py>0)
--py;
if( (input=='j' || input==KEY_DOWN) && py<7)
if( (input=='j' || (input==KEY_DOWN||input=='s')) && py<7)
++py;
if( (input=='h' || input==KEY_LEFT) && px>0)
if( (input=='h' || (input==KEY_LEFT||input=='a')) && px>0)
--px;
if( (input=='l' || input==KEY_RIGHT) && px<7)
if( (input=='l' || (input==KEY_RIGHT||input=='d')) && px<7)
++px;
if( input=='q'){
resign=1;
Expand Down
8 changes: 4 additions & 4 deletions snakeduel.c
Original file line number Diff line number Diff line change
Expand Up @@ -708,16 +708,16 @@ int main(int argc, char** argv){
help();
if( input==KEY_F(2) )
gameplay();
if( (input=='k' || input==KEY_UP) && p.y>0 && p.direction != DOWN ){
if( (input=='k' || (input==KEY_UP||input=='w')) && p.y>0 && p.direction != DOWN ){
p.direction=UP;
}
if( (input=='j' || input==KEY_DOWN) && p.y<len-1 && p.direction != UP ){
if( (input=='j' || (input==KEY_DOWN||input=='s')) && p.y<len-1 && p.direction != UP ){
p.direction=DOWN;
}
if( (input=='h' || input==KEY_LEFT) && p.x>0 && p.direction != RIGHT){
if( (input=='h' || (input==KEY_LEFT||input=='a')) && p.x>0 && p.direction != RIGHT){
p.direction=LEFT;
}
if( (input=='l' || input==KEY_RIGHT) && p.x<wid-1 && p.direction != LEFT){
if( (input=='l' || (input==KEY_RIGHT||input=='d')) && p.x<wid-1 && p.direction != LEFT){
p.direction=RIGHT;
}
if( input=='q')
Expand Down
8 changes: 4 additions & 4 deletions sos.c
Original file line number Diff line number Diff line change
Expand Up @@ -403,13 +403,13 @@ int main(int argc, char** argv){
gameplay();
if( input==KEY_MOUSE )
mouseinput(sy,sx);
if( (input=='k' || input==KEY_UP) && py>0)
if( (input=='k' || (input==KEY_UP||input=='w')) && py>0)
--py;
if( (input=='j' || input==KEY_DOWN) && py<len-1)
if( (input=='j' || (input==KEY_DOWN||input=='s')) && py<len-1)
++py;
if( (input=='h' || input==KEY_LEFT) && px>0)
if( (input=='h' || (input==KEY_LEFT||input=='a')) && px>0)
--px;
if( (input=='l' || input==KEY_RIGHT) && px<wid-1)
if( (input=='l' || (input==KEY_RIGHT||input=='d')) && px<wid-1)
++px;
if( input=='q')
sigint_handler(0);
Expand Down
6 changes: 3 additions & 3 deletions sudoku.c
Original file line number Diff line number Diff line change
Expand Up @@ -496,11 +496,11 @@ int main(int argc,char** argv){
mouseinput(sy,sx);
if(input == KEY_UP && py)
--py;
if(input == KEY_DOWN && py<s-1)
if((input==KEY_DOWN||input=='s') && py<s-1)
++py;
if(input == KEY_LEFT && px)
if((input==KEY_LEFT||input=='a') && px)
--px;
if(input == KEY_RIGHT && px<s-1)
if((input==KEY_RIGHT||input=='d') && px<s-1)
++px;
if(!empty[py][px]){
if(input == ' ' )
Expand Down
4 changes: 2 additions & 2 deletions tugow.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ void show_scores(byte playerrank){
refresh();
do{
input=getch();
}while(input==KEY_UP || input==KEY_DOWN);
}while((input==KEY_UP||input=='w') || (input==KEY_DOWN||input=='s'));
filled_rect(0,0,LEN,WID);
blue_border();
}
Expand Down Expand Up @@ -317,7 +317,7 @@ int main(int argc,char** argv){
attroff(colors[2]);
do{
input=getch();
}while(input==KEY_UP || input==KEY_DOWN);
}while((input==KEY_UP||input=='w') || (input==KEY_DOWN||input=='s'));
if(input!='q' && input!='n' && input!='N'){
score=0;
level=0;
Expand Down

0 comments on commit aaf092d

Please sign in to comment.