Convert this class into appstate format?

How would I fit this code?

package mygame;

import com.jme3.animation.AnimChannel;
import com.jme3.animation.AnimControl;
import com.jme3.animation.AnimEventListener;
import com.jme3.app.SimpleApplication;
import com.jme3.bullet.BulletAppState;
import com.jme3.bullet.collision.shapes.CapsuleCollisionShape;
import com.jme3.bullet.control.CharacterControl;
import com.jme3.bullet.control.RigidBodyControl;
import com.jme3.input.ChaseCamera;
import com.jme3.input.KeyInput;
import com.jme3.input.controls.ActionListener;
import com.jme3.input.controls.KeyTrigger;
import com.jme3.light.DirectionalLight;
import com.jme3.light.PointLight;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.scene.Node;

    



/**
 * test
 * @author 
 */

public class Test1 extends SimpleApplication 
  implements ActionListener, AnimEventListener {
  public AnimChannel animationChannel;
  public AnimControl animationControl;
  public ChaseCamera chaseCam;
  public Node player;
  public Node Scene;
 
    
    /**,
     *  
     * @param args
     */
    public static void main(String[] args) {
        Test1 app = new Test1();
        app.start();
    }
 
   private CharacterControl character;
   public BulletAppState bulletAppState;

  // track directional input
public boolean left = false, right = false, up = false, down = false;
    
 {

   
    }


public void onAction(String binding,boolean value, float tpf) {
 if (binding.equals("CharLeft")) {
      if (value) left= true;
      else left = false;
 } else if (binding.equals("CharRight")) {
   if (value) right = true;
   else right = false;
} else if (binding.equals("CharForward")) {
  if (value) up = true;
  else up = false;
} else if (binding.equals("CharBackward")) {
   if (value) down = true;
else down = false;

}


    /**
     *
     */
}
    public void simpleInitApp() {
    bulletAppState = new BulletAppState();
     //bulletAppState.setThreadingType(BulletAppState.ThreadingType.PARALLEL);
     stateManager.attach(bulletAppState);
     
     
     PhysicsTestHelper.createPhysicsTestWorld(rootNode,
         assetManager, bulletAppState.getPhysicsSpace());
  Scene = (Node) assetManager.loadModel ("Models/Hotelroom/Hotelroom.j3o");
  Scene.addControl(new RigidBodyControl(0));
  rootNode.attachChild(Scene);
  bulletAppState.getPhysicsSpace().addAll(Scene);
  
      

    PointLight lamp = new PointLight();
    lamp.setPosition(Vector3f.ZERO);
    lamp.setColor(ColorRGBA.White);
    rootNode.addLight(lamp); 
    rootNode.attachChild(Scene); 
   
        /** A white, directional light source */ 
    DirectionalLight sun = new DirectionalLight();
    sun.setDirection((new Vector3f(1f, 1f, 1f)).normalizeLocal());
    sun.setColor(ColorRGBA.White);
    rootNode.addLight(sun);     
    rootNode.attachChild(Scene);
    
    
    player =  (Node) assetManager.loadModel("Models/Main Chr/Cube.mesh.j3o");
    player.setLocalTranslation(1f, 1f, 1f);
    //CapsuleCollisionShape capsule = new CapsuleCollisionShape(3f, 4f); - Original
    CapsuleCollisionShape capsule = new CapsuleCollisionShape(2f, 10f);
    character = new CharacterControl(capsule, 0.05f);
    player.scale(3f);
    player.addControl(character);
    character.setJumpSpeed(20f);
    
  animationControl = player.getControl(AnimControl.class);
  animationControl.addListener(this);
  animationChannel = animationControl.createChannel();
  
    bulletAppState.getPhysicsSpace().add(character);
    rootNode.attachChild(player);
    
    
     //Maps the Keys to Action/Animation
    inputManager.addMapping("CharLeft",new KeyTrigger(KeyInput.KEY_LEFT));  
    inputManager.addMapping("CharRight",new KeyTrigger(KeyInput.KEY_RIGHT));
    inputManager.addMapping("CharForward",new KeyTrigger(KeyInput.KEY_UP));
    inputManager.addMapping("CharBackward",new KeyTrigger(KeyInput.KEY_DOWN));
    inputManager.addMapping("CharJump",new KeyTrigger(KeyInput.KEY_J));
    inputManager.addListener(this, "CharLeft", "CharRight");
    inputManager.addListener(this, "CharForward", "CharBackward");
    inputManager.addListener(this, "CharJump");

    flyCam.setEnabled(false);
    chaseCam = new ChaseCamera(cam, player, inputManager);
    chaseCam.setSmoothMotion(true);
    chaseCam.setTrailingEnabled(true);
    
     
}

 public void onAnimCycleDone(AnimControl control, 
         AnimChannel channel, String animName) {

    }

public void onAnimChange(AnimControl control, 
        AnimChannel channel, String animName) {

    }


private Vector3f walkDirection = new Vector3f(0,0,0); //stop
private float airTime = 0;
 public void simpleUpdate(float tpf) { 
   Vector3f camDir = cam.getDirection().clone();
   Vector3f camLeft = cam.getLeft().clone();
   camDir.y = 0;
   camLeft.y = 0;
   camDir.normalizeLocal();
   camLeft.normalizeLocal();
   walkDirection.set(0,0,0);
   
   if (left) walkDirection.addLocal(camLeft);
   if (right) walkDirection.addLocal(camLeft.negate());
   if (up) walkDirection.addLocal(camDir);
   if (down) walkDirection.addLocal(camDir.negate());
   
   if (!character.onGround()) { // Remember to use !character.isOnGround() if the character is a BetterCharacterControl type.
       airTime += tpf;
   } else{ 
       airTime =0;
   } 
   if (walkDirection.lengthSquared() ==0) { 
       if (!"Stand".equals(animationChannel.getAnimationName()))  {
            animationChannel.setAnim("Stand", 1f);
       }
   } else {
       character.setViewDirection(walkDirection);
       if (airTime > .3f) {
           if (!"Stand".equals(animationChannel.getAnimationName())) { 
               animationChannel.setAnim("Stand");
           }
       } else if (!" Walk".equals(animationChannel.getAnimationName())) {
          animationChannel.setAnim(" Walk", 0.1f);
        }
       }
     walkDirection.multLocal(5f).multLocal(tpf); //The use of the first multLocal here is to control the rate of movement multiplier for character walk speed. The second one is to make sure the character walks the same speed no matter what the frame rate is
     character.setWalkDirection(walkDirection); // WALKING!!

     

 }
}   

Into the normal app state format this :smile:



import com.jme3.app.Application;
import com.jme3.app.state.AbstractAppState;
import com.jme3.app.state.AppStateManager;

/**
 *
 * @author yemibob
 */
public class NewAppState extends AbstractAppState {
    
    @Override
    public void initialize(AppStateManager stateManager, Application app) {
        super.initialize(stateManager, app);
        //TODO: initialize your AppState, e.g. attach spatials to rootNode
        //this is called on the OpenGL thread after the AppState has been attached
    }
    
    @Override
    public void update(float tpf) {
        //TODO: implement behavior during runtime
    }
    
    @Override
    public void cleanup() {
        super.cleanup();
        //TODO: clean up what you initialized in the initialize method,
        //e.g. remove all spatials from rootNode
        //this is called on the OpenGL thread after the AppState has been detached
    }
}

Thank you

hint :
simpleInit … initialize
simpleUpdate … update