Changed: Optimization from code review PR #42
This commit is contained in:
@@ -114,7 +114,7 @@ void Dolphin::onUpdate()
|
|||||||
oysters[i].update();
|
oysters[i].update();
|
||||||
Vector3 vecDist = oysters[i].mesh.position - player.mesh.position;
|
Vector3 vecDist = oysters[i].mesh.position - player.mesh.position;
|
||||||
float dist = Math::sqrt(vecDist.x + vecDist.y + vecDist.z);
|
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);
|
printf("Pickup %d Dist %d\n", i, dist);
|
||||||
//oysters[i].setActive(false);
|
//oysters[i].setActive(false);
|
||||||
|
|||||||
@@ -29,22 +29,12 @@ Collectible::~Collectible()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void Collectible::setActive(u8 b)
|
|
||||||
{
|
|
||||||
bActive = b;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Collectible::disappear()
|
void Collectible::disappear()
|
||||||
{
|
{
|
||||||
bDisappearing = true;
|
bDisappearing = true;
|
||||||
lift = 10;
|
lift = 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
u8 Collectible::isActive()
|
|
||||||
{
|
|
||||||
return bActive;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Collectible::update()
|
void Collectible::update()
|
||||||
{
|
{
|
||||||
mesh.rotation.y += 0.08F;
|
mesh.rotation.y += 0.08F;
|
||||||
|
|||||||
@@ -24,8 +24,8 @@ public:
|
|||||||
~Collectible();
|
~Collectible();
|
||||||
void update();
|
void update();
|
||||||
void disappear();
|
void disappear();
|
||||||
void setActive(u8 b);
|
void setActive(const u8 &b) { bActive = b; }
|
||||||
u8 isActive();
|
u8 isActive() { return bActive; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
u8 bActive, bDisappearing;
|
u8 bActive, bDisappearing;
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ Player::Player()
|
|||||||
mesh.position.set(0.0F, 0.0F, 10.0f);
|
mesh.position.set(0.0F, 0.0F, 10.0f);
|
||||||
mesh.rotation.x = -1.6F;
|
mesh.rotation.x = -1.6F;
|
||||||
mesh.setAnimSpeed(0.05F);
|
mesh.setAnimSpeed(0.05F);
|
||||||
isJumping = false;
|
bIsJumping = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player::~Player()
|
Player::~Player()
|
||||||
@@ -62,9 +62,9 @@ void Player::update(Pad &t_pad)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mesh.getCurrentAnimationFrame() > 25 && mesh.getCurrentAnimationFrame() < 47)
|
if (mesh.getCurrentAnimationFrame() > 25 && mesh.getCurrentAnimationFrame() < 47)
|
||||||
isJumping = true;
|
bIsJumping = true;
|
||||||
else
|
else
|
||||||
isJumping = false;
|
bIsJumping = false;
|
||||||
/*
|
/*
|
||||||
if (lift < 0)
|
if (lift < 0)
|
||||||
mesh.rotation.y = 1;
|
mesh.rotation.y = 1;
|
||||||
@@ -82,13 +82,8 @@ void Player::update(Pad &t_pad)
|
|||||||
}
|
}
|
||||||
|
|
||||||
mesh.position.z +=
|
mesh.position.z +=
|
||||||
Math::cos(mesh.rotation.z) * velocity * (isJumping + 1);
|
Math::cos(mesh.rotation.z) * velocity * (bIsJumping + 1);
|
||||||
mesh.position.x +=
|
mesh.position.x +=
|
||||||
Math::sin(mesh.rotation.z) * velocity * (isJumping + 1);
|
Math::sin(mesh.rotation.z) * velocity * (bIsJumping + 1);
|
||||||
mesh.position.y += lift;
|
mesh.position.y += lift;
|
||||||
}
|
}
|
||||||
|
|
||||||
u8 Player::getIsJumping()
|
|
||||||
{
|
|
||||||
return isJumping;
|
|
||||||
}
|
|
||||||
@@ -26,10 +26,10 @@ public:
|
|||||||
Player();
|
Player();
|
||||||
~Player();
|
~Player();
|
||||||
void update(Pad &t_pad);
|
void update(Pad &t_pad);
|
||||||
u8 getIsJumping();
|
const u8 &isJumping() { return bIsJumping; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
u8 isJumping;
|
u8 bIsJumping;
|
||||||
Vector3 playerNextPosition;
|
Vector3 playerNextPosition;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user