Changed: Optimization from code review PR #42

This commit is contained in:
Foxar
2020-12-08 13:36:13 +01:00
parent 83dce5cb92
commit 582b42c29e
5 changed files with 11 additions and 26 deletions
+1 -11
View File
@@ -29,22 +29,12 @@ Collectible::~Collectible()
{
}
void Collectible::setActive(u8 b)
{
bActive = b;
}
void Collectible::disappear()
{
bDisappearing = true;
lift = 10;
}
u8 Collectible::isActive()
{
return bActive;
}
void Collectible::update()
{
mesh.rotation.y += 0.08F;
@@ -58,4 +48,4 @@ void Collectible::update()
bDisappearing = false;
}
}
}
}
+2 -2
View File
@@ -24,8 +24,8 @@ public:
~Collectible();
void update();
void disappear();
void setActive(u8 b);
u8 isActive();
void setActive(const u8 &b) { bActive = b; }
u8 isActive() { return bActive; }
private:
u8 bActive, bDisappearing;
+5 -10
View File
@@ -23,7 +23,7 @@ Player::Player()
mesh.position.set(0.0F, 0.0F, 10.0f);
mesh.rotation.x = -1.6F;
mesh.setAnimSpeed(0.05F);
isJumping = false;
bIsJumping = false;
}
Player::~Player()
@@ -62,9 +62,9 @@ void Player::update(Pad &t_pad)
}
if (mesh.getCurrentAnimationFrame() > 25 && mesh.getCurrentAnimationFrame() < 47)
isJumping = true;
bIsJumping = true;
else
isJumping = false;
bIsJumping = false;
/*
if (lift < 0)
mesh.rotation.y = 1;
@@ -82,13 +82,8 @@ void Player::update(Pad &t_pad)
}
mesh.position.z +=
Math::cos(mesh.rotation.z) * velocity * (isJumping + 1);
Math::cos(mesh.rotation.z) * velocity * (bIsJumping + 1);
mesh.position.x +=
Math::sin(mesh.rotation.z) * velocity * (isJumping + 1);
Math::sin(mesh.rotation.z) * velocity * (bIsJumping + 1);
mesh.position.y += lift;
}
u8 Player::getIsJumping()
{
return isJumping;
}
+2 -2
View File
@@ -26,10 +26,10 @@ public:
Player();
~Player();
void update(Pad &t_pad);
u8 getIsJumping();
const u8 &isJumping() { return bIsJumping; }
private:
u8 isJumping;
u8 bIsJumping;
Vector3 playerNextPosition;
};