
#include "Object.h"


ShipBase::ShipBase() {
	Position = glm::vec2(0.0f, 0.0f);
	Velocity = glm::vec2(0.0f, 0.0f);
	pImage = nullptr;
	HP = 0;
}

ShipBase::~ShipBase() { }

//現在位置の更新
void ShipBase::Update() {
	Position += Velocity;
}

//描画
void ShipBase::Draw() { }



Player::Player(GLFWwindow *pWindow) {
	this->pWindow = pWindow;
	pImage = new Image("img/player.png");
}

Player::~Player() {
	delete pImage;
}

//現在位置を更新
void Player::Update() {
	
	Velocity = glm::vec2(0.0f, 0.0f);
	if( glfwGetKey(pWindow, GLFW_KEY_LEFT) == GLFW_PRESS ) {
		Velocity += glm::vec2(-1.0f, 0.0f);
	}
	if( glfwGetKey(pWindow, GLFW_KEY_RIGHT) == GLFW_PRESS ) {
		Velocity += glm::vec2(1.0f, 0.0f);
	}
	if( glfwGetKey(pWindow, GLFW_KEY_UP) == GLFW_PRESS ) {
		Velocity += glm::vec2(0.0f, 1.0f);
	}
	if( glfwGetKey(pWindow, GLFW_KEY_DOWN) == GLFW_PRESS ) {
		Velocity += glm::vec2(0.0f, -1.0f);
	}
	
	ShipBase::Update();
	
}

//プレイヤーを描画
void Player::Draw() {
	pImage->Draw(
		Position,
		glm::vec2(pImage->GetWidth() * 0.5f, pImage->GetHeight()),
		false,
		glm::vec2(0.0f, 0.0f),
		glm::vec2(0.5f, 1.0f)
	);
	
	ShipBase::Draw();
	
}




Enemy::Enemy() {
	pImage = new Image("img/enemy1.png");
}
Enemy::~Enemy() {
	delete pImage;
}

//現在位置を更新
void Enemy::Update() {
	ShipBase::Update();
}

//プレイヤーを描画
void Enemy::Draw() {
	pImage->Draw(
		Position,
		glm::vec2(pImage->GetWidth() * 0.5f, pImage->GetHeight()),
		true,
		glm::vec2(0.0f, 0.0f),
		glm::vec2(0.5f, 1.0f)
	);
	
	ShipBase::Draw();
	
}



PlayerBullet::PlayerBullet() {
	pImage = new Image("img/player_bullet.png");
}
PlayerBullet::~PlayerBullet() {
	delete pImage;
}

//現在位置を更新
void PlayerBullet::Update() {
	ShipBase::Update();
}

//弾を描画
void PlayerBullet::Draw() {
	pImage->Draw(
		Position,
		glm::vec2(pImage->GetWidth(), pImage->GetHeight())
	);
	
	ShipBase::Draw();
	
}
