package io.github.lambo993.game;

/**
 * Same as enemy but follow the player movements
 * @author Lamboling Seans
 * @since version 1.7.9_Alpha
 */
public class SmartEnemy extends Enemy {

	private Player player;

	public SmartEnemy(Player player) {
		setX(400);
		setY(50);
		this.player = player;
	}

	@Override
	public void run() {
		while (true) {
			int x = player.getX() + 30;
			int y = player.getY() - 3;
			if (getX() == x && player.isAlive()) {
				setXVelocity(0);
			}
			if (getY() == y && player.isAlive()) {
				setYVelocity(0);
			}
			if (player.isAlive()) {
				move(x, y, x, y);
			} else {
				move(0, 5, 790, 590);
			}
			try {
				Thread.sleep(5);
			} catch (InterruptedException ex) {
				System.err.println("Error: Thread Interrupted.");
			}
		}
	}
}
@@ -27,16 +27,43 @@
 .game;%0A%0A
+import java.awt.Graphics;%0A%0A
 /**%0A * S
@@ -678,22 +678,19 @@
 %09%09%09%09
-Thread
+Main
 .sleep(
-5
 );%0A%09
@@ -793,9 +793,161 @@
 %0A%09%09%7D%0A%09%7D%0A
-%7D
+%0A%09@Override%0A%09public void draw(Graphics g) %7B%0A%09%09g.drawImage(Main.loadImage(%22/io/github/lambo993/game/images/Enemy.png%22), getX(), getY(), new Main());%0A%09%7D%0A%7D%0A

Version Alpha 1.8