@Override
    public void simpleUpdate(float tpf) {
        // Update and position the score
        scoreText.setText("Score: " + score);
        scoreText.setLocalTranslation((cam.getWidth() - scoreText.getLineWidth()) / 2.0f,
                scoreText.getLineHeight(), 0.0f);
        
        // Rotate all the pickups
        float pickUpSpeed = PICKUP_SPEED * tpf;
        for(Spatial pickUp : pickUps.getChildren()) {
            pickUp.rotate(pickUpSpeed, pickUpSpeed, pickUpSpeed);
        }
        
        Vector3f centralForce = new Vector3f();
        
        if(keyForward) centralForce.addLocal(cam.getDirection());
        if(keyBackward) centralForce.addLocal(cam.getDirection().negate());
        if(keyLeft) centralForce.addLocal(cam.getLeft());
        if(keyRight) centralForce.addLocal(cam.getLeft().negate());
        
        if(!Vector3f.ZERO.equals(centralForce)) {
            centralForce.setY(0);                   // stop ball from pushing down or flying up
            centralForce.normalizeLocal();          // normalize force
            centralForce.multLocal(PLAYER_FORCE);   // scale vector to force

            player.applyCentralForce(centralForce); // apply force to player
        }
        
        cam.lookAt(player.getPhysicsLocation(), Vector3f.UNIT_Y);
    }
Physics based marble game.

@author SkidRunner (Mark E. Picknell)
jme3-examples/src/main/java/jme3test/games/RollingTheMonkey.java