Add some (badly) generated platforms that will scroll

down whenever the player's top side depasses the middle
of the screen.
WiP.
This commit is contained in:
King_DuckZ 2014-07-05 20:33:16 +02:00
parent 976d34f17e
commit 4a3a0a4782
13 changed files with 251 additions and 55 deletions

View file

@ -20,7 +20,7 @@
#ifndef id9CDCF10D483641A2845353C0835F93EC
#define id9CDCF10D483641A2845353C0835F93EC
//Move a Placeable by issuind an offset.
//Move a Placeable by issuing an offset.
//The offset is applied to the current position of the Placeable you are
//moving.
//For example issuing 1, then 2 will put your Placeable in position 3,

View file

@ -22,7 +22,7 @@
//Move a Placeable by issuing an offset relative to a base position.
//Use this if for example your Placeable is following a mathematical formula or
//if you're giving a position you want it to be at any specific time.
//if you're giving a position you want it to be at at any specific time.
//For example issuing 1, then 2 will put your Placeable in position 2,
//assuming it started at 0.

View file

@ -44,7 +44,7 @@ namespace cloonel {
void MoverSine::ApplyMotion (float parDelta) {
const float pitwo = static_cast<float>(M_PI) * 2.0f;
m_alpha += parDelta * 2.6f;
if (m_alpha >= pitwo)
while (m_alpha >= pitwo)
m_alpha -= pitwo;
}
} //namespace cloonel

39
src/movers/moverworld.cpp Normal file
View file

@ -0,0 +1,39 @@
/*
Copyright 2014 Michele "King_DuckZ" Santullo
This file is part of CloonelJump.
CloonelJump is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
CloonelJump is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with CloonelJump. If not, see <http://www.gnu.org/licenses/>.
*/
#include "moverworld.hpp"
#include <algorithm>
namespace cloonel {
MoverWorld::MoverWorld (float parMidPoint) :
Placeable(float2(0.0f)),
m_midPoint(parMidPoint),
m_offs(0.0f)
{
}
float2 MoverWorld::GetOffset() const {
return float2(0.0f, -m_offs);
}
void MoverWorld::ApplyMotion (float) {
const auto vertPos = this->GetPos().y();
m_offs = std::max(0.0f, vertPos - m_midPoint);
}
} //namespace cloonel

41
src/movers/moverworld.hpp Normal file
View file

@ -0,0 +1,41 @@
/*
Copyright 2014 Michele "King_DuckZ" Santullo
This file is part of CloonelJump.
CloonelJump is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
CloonelJump is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with CloonelJump. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef id47E717F84F3647A69E14C3B695B38F7B
#define id47E717F84F3647A69E14C3B695B38F7B
#include "moveroneshot.hpp"
#include "placeable.hpp"
namespace cloonel {
class MoverWorld : public MoverOneShot, public Placeable {
public:
explicit MoverWorld ( float parMidPoint );
virtual ~MoverWorld ( void ) noexcept = default;
private:
virtual float2 GetOffset ( void ) const;
virtual void ApplyMotion ( float parDelta );
const float m_midPoint;
float m_offs;
};
} //namespace cloonel
#endif