Im trying to fix the up and down erratic movements the pathing makes so it will be more smooth.
dzt67uGx50w
package net.gasquake.sentinel.entity;
import net.gasquake.framework.entity.Entity;
import net.gasquake.framework.resources.Screen;
import net.gasquake.framework.util.Tilemap;
import net.gasquake.sentinel.res.Textures;
import net.gasquake.sentinel.states.Play;
public class Enemy extends Entity {
Tilemap tm;
Player player;
Textures tex;
private boolean triggered = false;
public Enemy(int x, int y, int w, int h, Tilemap tm, Textures tex, Player player) {
super(x, y, w, h);
this.tm = tm;
this.player = player;
this.tex = tex;
}
public void update() {
triggered = false;
if (player.getX() <= x) {
dx = -2;
}
if (player.getX() >= x) {
dx = 2;
}
if (tm.tilemapCollision(this, Play.worldArray, w, h, 48, 0, 0)) {
dy = -3;
triggered = true;
}
if (triggered == false) {
dy = 4;
}
tm.tilemapCollision(this, Play.worldArray, w, h, 48, 1);
move(dx, dy);
}
public void render() {
Screen.render(tex.playerRight, this);
}
}
This doesnt have anything to do with the collision its just the pathing I think. Ideas?