JohnBoyJohn / Game_Engine

0 stars 0 forks source link

Enemy AI #7

Open DidiCatman opened 7 years ago

DidiCatman commented 7 years ago

battle AI and world AI.

for the second i like some random movement in some sort of range (looks like person is alive). i have some code in my java game for creating this effect, but my AI so far can move everywhere (same as player, so we need some kind of restriction)

DidiCatman commented 7 years ago

code from my mobs update method:

public void update() {
    time++;
    if (time % (random.nextInt(40) + 40) == 0) {
        xa = random.nextInt(3) - 1;
        ya = random.nextInt(3) - 1;
        if (random.nextInt(2) == 0) {
            xa = 0;
            ya = 0;
        }
    }
    if (walking) animSprite.update();
    else animSprite.setFrame(1);
    if (ya < 0) {
        animSprite = up;
        dir = Direction.UP;
    }
    if (ya > 0) {
        animSprite = down;
        dir = Direction.DOWN;
    }
    if (xa < 0) {
        animSprite = left;
        dir = Direction.LEFT;
    }
    if (xa > 0) {
        animSprite = right;
        dir = Direction.RIGHT;
    }
    if (xa != 0 || ya != 0) {
        move(xa, ya);
        walking = true;
    } else {
        walking = false;
    }
}
JohnBoyJohn commented 7 years ago

i will skip this part for now to provide some graphics first and lead the game in the direction i thought to be best at it's own.

Any improvements to the engine are welcome and can be done in a new branch. We can merge it later with upper branches. I made my personal branch to work for some improvements locally and on github (feature_j).

DidiCatman commented 7 years ago

i created branch 'feature_d' to add things... so far i only have code snippets so nothing to commit yet.