示例#1
0
 @Override
 public void reactToKeyboardSingleKey(String string) {
   char c = string.charAt(0);
   if (c == 'w') {
     globe.print("");
     if (!player_is_jumping) {
       player_is_jumping = true;
       player_velocity_Y = -20;
     }
     // System.out.println("UP");
   }
   if (c == 'a') {
     globe.print("");
     if (!player_is_moving_left && !player_is_moving_right) {
       player_is_moving_left = true;
     }
     // System.out.println("LEFT");
   }
   if (c == 'd') {
     globe.print("");
     if (!player_is_moving_left && !player_is_moving_right) {
       player_is_moving_right = true;
     }
     // System.out.println("RIGHT");
   }
 }
示例#2
0
        @Override
        public void reactToKeyboardSingleKey(String string) {
          // WSAD
          char c = string.charAt(0);
          if (c == 'w') {
            globe.print("");
            globe.print("UP");
            if (!playerIsJumping) {
              playerIsJumping = true;
              speedY = jumpStrength;
            }
          }
          /*
          if(c == 's'){
          globe.print("");
          globe.print("DOWN");
          }*/

          if (c == 'a') {
            globe.print("");
            globe.print("LEFT");
            moveLeft = true;
          } else if (c == 'd') {
            globe.print("");
            globe.print("RIGHT");
            moveRight = true;
          }
        }