Browse Source

change getInput to have return

main
fdai7184 2 years ago
parent
commit
4fc726b4be
  1. 10
      src/input.c

10
src/input.c

@ -19,7 +19,7 @@ void Pausieren();
/** getInput gets the userinput and reacts to input of w,a,s,d, arrow keys, p or q /** getInput gets the userinput and reacts to input of w,a,s,d, arrow keys, p or q
* utilises getch() and kbhit, no parameters, no returns * utilises getch() and kbhit, no parameters, no returns
*/ */
void getInput(){
char getInput(){
if(kbhit()){ if(kbhit()){
char key= getch(); char key= getch();
if(key == '\033'){ if(key == '\033'){
@ -27,16 +27,16 @@ void getInput(){
char key = getch(); char key = getch();
switch(key){ switch(key){
case 'A': case 'A':
printf("up");
return 'u';
break; break;
case 'B': case 'B':
printf("down");
return 'd';
break; break;
case 'C': case 'C':
printf("right");
return 'r';
break; break;
case 'D': case 'D':
printf("left");
return 'l';
break; break;
} }
} }

Loading…
Cancel
Save