Add Building, Add Hard floors

This commit is contained in:
Bram Verhulst
2024-04-18 15:39:18 +02:00
parent db83ae5e13
commit ebda39f690
17 changed files with 149 additions and 216 deletions

View File

@@ -19,6 +19,7 @@ Player::Player(const Vector2f& Position, TextureManager* manager) : m_Position(P
m_walkAnimation = new Animation(
manager->GetTexture("animations/player/player_walk.png"),
8, 0.1f, Rectf { 0, 0, 70, 70 });
m_currentAnimation = m_walkAnimation;
}
Collision::CollisionRect Player::GetCollisionRect() const {
Collision::CollisionRect rect = { m_Position, m_Size, m_Vel };
@@ -34,10 +35,10 @@ void Player::Draw() const {
const int frameWidth = 70; //TODO: fix this
int halfFrameWidth = frameWidth / 2;
float bobOffset = m_BobUp ? 1 : 0;
Vector2f drawPos = Vector2f { center.x - halfFrameWidth, center.y - halfFrameWidth + 9 + bobOffset} ;
Vector2f drawPos = Vector2f { center.x - halfFrameWidth, center.y - halfFrameWidth + 9 };
m_walkAnimation->Draw(drawPos, Rectf { drawPos.x, drawPos.y, frameWidth, frameWidth });
m_walkAnimation->Draw(drawPos, Rectf { drawPos.x, drawPos.y , frameWidth, frameWidth });
}
void Player::ProcessImGui() {
ImGui::Begin("Collision Info", nullptr, ImGuiWindowFlags_AlwaysAutoResize);
@@ -56,6 +57,8 @@ void Player::ProcessImGui() {
break;
}
ImGui::Text("Player State %s", currentState.c_str());
ImGui::Text("Bob counter: %f", m_BobTimer);
ImGui::Text("Bob up: %s", m_BobUp ? "true" : "false");
//ContactMap
@@ -68,7 +71,11 @@ void Player::ProcessImGui() {
}
void Player::Update(float elapsedTime, WorldLevel& level) {
m_BobTimer += elapsedTime;
if(m_BobTimer >= m_BobTime) {
m_BobUp = !m_BobUp;
m_BobTimer = 0.0f;
}
//check for keys
if(m_State != PlayerState::Digging) {