Warning: include(../analyticstracking.php): Failed to open stream: No such file or directory in /usr/www/users/beneditd/wurfelengine.net/includes/header_source.php on line 25

Warning: include(): Failed opening '../analyticstracking.php' for inclusion (include_path='.:/usr/local/lib/php/') in /usr/www/users/beneditd/wurfelengine.net/includes/header_source.php on line 25
lettering of Wurfelengine some logos of used technologys

Example: Zombie

Creating a simple bot is very easy. For example a zombie.


How to spawn it at selection

What is done here?
-create new entity with id 42 and at the same coordinates as the selection and save it in the variable "zombie".
-the zombie should follow the player
-spawn it

if (keycode == Input.Keys.K) {
    Zombie zombie = (Zombie) AbstractEntity.getInstance(
        43,
        0,
        controller.getFocusentity().getPosition()
    );
    zombie.setTarget(controller.getPlayer());
    zombie.spawn();   
}

render-Method

What is done here?
-override the usual rendering
-render using green color

    @Override
	public void render(View view, Camera camera, AbstractPosition pos){
		 render(
            view,
            camera,
            pos,
            Color.GREEN.cpy().mul(WE.getCurrentConfig().shouldAutoShade()
                ? Color.GRAY.cpy()
                :
                    Controller.getLightEngine() != null
                        ? Controller.getLightEngine().getColor()
                        : Color.GRAY.cpy())
        );
	}

update-Method

What is done here?
-walk in direction of the target (for example the player)
-update the entity as usual
-jump if standing in front of a block

 @Override
    public void update(float delta) {
        if (getPosition().getCoord().onLoadedMap()) {
            //follow the target
            if (target != null) {
				Vector3 d = new Vector3();
                d.x = target.getPosition().getAbsX()-getPosition().getAbsX();
                d.y = target.getPosition().getAbsY()-getPosition().getAbsY();
				d.nor();
				d.z = getMovement().z;
				// update the movement vector
				setMovement(d);
                setSpeed(0.4f);
            }
            //update as usual
            super.update(delta);

            //if standing on same position as in last update
            if (Arrays.equals(getPosition().getRel(), lastPos))
                runningagainstwallCounter += delta;
            else {
                runningagainstwallCounter=0;
                lastPos = getPosition().getRel();
            }

            //jump after some time
            if (runningagainstwallCounter > 500) {
                jump();
                setMana(0);
                runningagainstwallCounter=0;
            }
        }
    }