Refactoring in Movers.

The displayed texture now bounces vertically.
This commit is contained in:
King_DuckZ 2014-02-22 13:13:49 +01:00
parent 3269b469e3
commit 85c65b3e68
13 changed files with 62 additions and 22 deletions

View file

@ -1,11 +1,14 @@
#include "moversine.hpp"
#if !defined(_GNU_SOURCE)
# define _GNU_SOURCE
#endif
#include <cmath>
namespace cloonel {
///--------------------------------------------------------------------------
///--------------------------------------------------------------------------
MoverSine::MoverSine() :
MoverOneShot(),
MoverRelative(),
m_alpha(0.0f),
m_power(1.0f)
{
@ -14,12 +17,15 @@ namespace cloonel {
///--------------------------------------------------------------------------
///--------------------------------------------------------------------------
float2 MoverSine::GetOffset() const {
return float2(std::sin(m_alpha) * m_power);
return float2(0.0f, std::abs(std::sin(m_alpha)) * m_power);
}
///--------------------------------------------------------------------------
///--------------------------------------------------------------------------
void MoverSine::Update (float parDelta) {
void MoverSine::ApplyMotion (float parDelta) {
const float pitwo = static_cast<float>(M_PI) * 2.0f;
m_alpha += parDelta;
if (m_alpha >= pitwo)
m_alpha -= pitwo;
}
} //namespace cloonel