Changed: Optimization from code review PR #42
This commit is contained in:
@@ -114,7 +114,7 @@ void Dolphin::onUpdate()
|
||||
oysters[i].update();
|
||||
Vector3 vecDist = oysters[i].mesh.position - player.mesh.position;
|
||||
float dist = Math::sqrt(vecDist.x + vecDist.y + vecDist.z);
|
||||
if (dist < 2.5F && player.getIsJumping() && oysters[i].isActive())
|
||||
if (dist < 2.5F && player.isJumping() && oysters[i].isActive())
|
||||
{
|
||||
printf("Pickup %d Dist %d\n", i, dist);
|
||||
//oysters[i].setActive(false);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user