Rolling The Monkey - example [merged]

Hello I was hoping to get a simple example game into the jme-examples project. It’s not much but it is one class like the others. and only uses one asset from the core project. technically it is a complete game…LOL even though there isn’t much challenge to it.


Pull request link if anyone cares pull request 592

@nehon I have updated the update method as follows…

    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 pusing 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);
1 Like

@nehon @Empire_Phoenix @jayfella
Thanks for all the help. I am actually really excited that my example is now part of jMonkeyEngine source :smile:

1 Like