public class Enemy {
	
	public int current_hp;
	public int max_hp;
	private int speed = 1;
	public int x_pos;
	public int y_pos;
	public int x_middle;
	public int y_middle;
	public String img;
	private String name;
	
	// Creates a new "Enemy" with a name and max hp as parameters
	public Enemy(String e_name, int hp){
			this.name = e_name;
			this.max_hp = hp;
			this.current_hp = hp;
			this.x_pos = 37;
			this.y_pos = -19;
		}
	
	// Moves the Enemy through the path
	public void move(){
		if (this.x_pos < 142 && this.y_pos < 203){ // Section 1
			if(this.y_pos < 82 && this.x_pos == 37){
				this.moveDown();
			}
			else if (this.x_pos < 82 && this.y_pos == 82){
				this.moveRight();
			}
			else if (this.y_pos < 142 && this.x_pos == 82){
				this.moveDown();
			}
			else if (this.x_pos > 37 && this.y_pos == 142){
				this.moveLeft();
			}
			else if (this.y_pos < 202 && this.x_pos == 37){
				this.moveDown();
			}
			else if (this.x_pos < 142 && this.y_pos == 202){
				this.moveRight();
			}
		}
		else if (this.x_pos >= 142 && this.y_pos < 203 || (this.x_pos == 217 && this.y_pos < 277 )){ // Section 2
			if (this.y_pos > 37 && this.x_pos == 142){
					this.moveUp();
				}	
			else if (this.x_pos < 442 && this.y_pos == 37){
				this.moveRight();
			}
			else if (this.y_pos < 112 && this.x_pos == 442){
				this.moveDown();
			}
			else if (this.x_pos > 367 && this.y_pos == 112){
				this.moveLeft();
			}
			else if (this.y_pos < 202 && this.x_pos == 367){
				this.moveDown();
			}
			else if (this.x_pos > 307 && this.y_pos == 202){
				this.moveLeft();
			}
			else if (this.y_pos > 112 && this.x_pos == 307){
				this.moveUp();
			}
			else if (this.x_pos > 217 && this.y_pos == 112){
				this.moveLeft();
			}
			else if (this.y_pos < 277 && this.x_pos == 217){
				this.moveDown();
			}
		}
		else if (this.y_pos >= 277 && this.x_pos < 277){ // Section 3
			if (this.x_pos > 67 && this.y_pos == 277){
				this.moveLeft();
			}
			else if (this.y_pos < 352 && this.x_pos == 67){
				this.moveDown();
			}
			else if (this.x_pos > 37 && this.y_pos == 352){
				this.moveLeft();
			}
			else if (this.y_pos < 397 && this.x_pos == 37){
				this.moveDown();
			}
			else if (this.x_pos < 277 && this.y_pos == 397){
				this.moveRight();
			}
			else if (this.x_pos < 277 && this.y_pos == 397){
				this.moveRight();
			}
		}
		else if (this.y_pos > 322 && this.x_pos == 277){ // Section 4 (the rest)
			this.moveUp();
		}
		else if (this.x_pos < 337 && this.y_pos == 322){
			this.moveRight();
		}
		else if (this.y_pos > 262 && this.x_pos == 337){
			this.moveUp();
		}
		else if (this.x_pos < 427 && this.y_pos == 262){
			this.moveRight();
		}
		else if (this.y_pos < 400 && this.x_pos == 427){
			this.moveDown();
		}
		
	}
	
	// Moves the Enemy Down and changes sprite image
	private void moveDown(){
		this.y_pos += this.speed;
		this.img = "ship1_d.png";
		this.x_middle = this.x_pos + 7;
		this.y_middle = this.y_pos + 15;
	}
	// Moves the Enemy Left and changes sprite image
	private void moveLeft(){
		this.x_pos -= this.speed;
		this.img = "ship1_l.png";
		this.x_middle = this.x_pos + 15;
		this.y_middle = this.y_pos + 7;
	}
	// Moves the Enemy Right and changes sprite image
	private void moveRight(){
		this.x_pos += this.speed;
		this.img = "ship1_r.png";
		this.x_middle = this.x_pos + 15;
		this.y_middle = this.y_pos + 7;
	}
	// Moves the Enemy Up and changes sprite image
	private void moveUp(){
		this.y_pos -= this.speed;
		this.img = "ship1_u.png";
		this.x_middle = this.x_pos + 7;
		this.y_middle = this.y_pos + 15;
	}
}
