mirror of
https://github.com/abakh/nbsdgames.git
synced 2025-02-02 15:07:27 -05:00
wasd support
This commit is contained in:
parent
c5eee81fb3
commit
aaf092d106
16
battleship.c
16
battleship.c
@ -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;
|
||||
@ -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);
|
||||
|
@ -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;
|
||||
|
4
darrt.c
4
darrt.c
@ -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();
|
||||
}
|
||||
@ -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();
|
||||
|
@ -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);
|
||||
|
8
fisher.c
8
fisher.c
@ -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();
|
||||
}
|
||||
@ -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){
|
||||
@ -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){
|
||||
@ -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();
|
||||
|
6
jewels.c
6
jewels.c
@ -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 ");
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
8
mines.c
8
mines.c
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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'){
|
||||
|
8
pipes.c
8
pipes.c
@ -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])
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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')
|
||||
|
8
sos.c
8
sos.c
@ -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);
|
||||
|
6
sudoku.c
6
sudoku.c
@ -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 == ' ' )
|
||||
|
4
tugow.c
4
tugow.c
@ -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();
|
||||
}
|
||||
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user