Advertisement
j0h

navKey

j0h
May 28th, 2023
1,161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.58 KB | None | 0 0
  1. #!/bin/bash
  2. #set is used to set variables, and assist in debugging
  3. #set -vx
  4.  
  5.  
  6. #keys are wasd
  7. w(){
  8.     clear
  9. echo -e "Moving Forward\n"
  10.     }
  11.  
  12. a(){
  13.     clear
  14. echo -e "Turning Left\n"
  15.     }  
  16.    
  17. s(){
  18.     clear
  19. echo -e "Going Back\n"
  20.     }
  21.    
  22. d(){
  23.     clear
  24. echo -e "Turning right\n"
  25.     }
  26.  
  27. while true; do
  28.  
  29. echo "w=go forward a=go left s=back d=go right"
  30. read -rsn1 input
  31.     if [ "$input" = "w" ]; then
  32.         w
  33.         elif [ "$input" = "a" ]; then
  34.         a
  35.         elif [ "$input" = "s" ]; then
  36.         s
  37.         elif [ "$input" = "d" ]; then
  38.         d
  39.         else
  40.         echo -e"something went wrong:\n" $input
  41.         exit
  42.     fi
  43. done
  44.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement