Fork it on GitHub! 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().getPos()
    );
    zombie.setTarget(controller.getPlayer());
    zombie.exist();   
}

render-Method

What is done here?
-override the usual rendering
-Use the graphics from the player
-render using green color

    @Override
    public void render(View view, WECamera camera, AbstractPosition pos) {
        getSprites()[CATEGORY][43][getValue()] = getSprites()[CATEGORY][40][getValue()];//reference player sprite
        Color color = Color.GRAY.cpy();
        if (Controller.getLightengine() != null){
            color = Controller.getLightengine().getGlobalLight();
        }
        render(view, camera, pos, color.mul(Color.GREEN));
    }

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) {
    //follow the target
    walk(
        (target.getPos().getAbsY()<getPos().getAbsY()),
        (target.getPos().getAbsY()>getPos().getAbsY()),
        (target.getPos().getAbsX()<getPos().getAbsX()),
        (target.getPos().getAbsX()>getPos().getAbsX()),
        .35f
    );
    
    //update as usual
    super.update(delta);
    
    //if standing on same position as in last update
    if (getPos().equals(lastPos))
        runningagainstwallCounter += delta;
    else {
        runningagainstwallCounter=0;
        lastPos = getPos().cpy();
    }
    
    //jump after one second
    if (runningagainstwallCounter > 50) {
        jump();
        runningagainstwallCounter=0;
    }
}