Platform and PlatformSystem added to the game. WiP.
This commit is contained in:
parent
4d9190b0db
commit
6fe884cd5a
6 changed files with 183 additions and 0 deletions
|
@ -51,6 +51,8 @@ add_executable(${PROJECT_NAME}
|
||||||
src/drawable.cpp
|
src/drawable.cpp
|
||||||
src/sizeratio.cpp
|
src/sizeratio.cpp
|
||||||
src/sizenotifiable.cpp
|
src/sizenotifiable.cpp
|
||||||
|
src/platform.cpp
|
||||||
|
src/platformsystem.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(${PROJECT_NAME}
|
target_link_libraries(${PROJECT_NAME}
|
||||||
|
|
BIN
resources/graphics/platform.png
Normal file
BIN
resources/graphics/platform.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.7 KiB |
41
src/platform.cpp
Normal file
41
src/platform.cpp
Normal 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "platform.hpp"
|
||||||
|
#include "texture.hpp"
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
|
namespace cloonel {
|
||||||
|
///--------------------------------------------------------------------------
|
||||||
|
///--------------------------------------------------------------------------
|
||||||
|
Platform::Platform (SDLMain* parSdlMain, const float2& parPos, Texture* parTexture, const float2& parSize) :
|
||||||
|
m_screenRatio(parSdlMain),
|
||||||
|
m_position(parPos),
|
||||||
|
m_size(parSize),
|
||||||
|
m_surface(parTexture)
|
||||||
|
{
|
||||||
|
assert(m_surface);
|
||||||
|
}
|
||||||
|
|
||||||
|
///--------------------------------------------------------------------------
|
||||||
|
///--------------------------------------------------------------------------
|
||||||
|
void Platform::Draw() const {
|
||||||
|
m_surface->Render(m_position, m_size, m_screenRatio.Ratio(), false);
|
||||||
|
}
|
||||||
|
} //namespace cloonel
|
46
src/platform.hpp
Normal file
46
src/platform.hpp
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
/*
|
||||||
|
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 idDBDFC83B5EBA417D96A342111BFA463E
|
||||||
|
#define idDBDFC83B5EBA417D96A342111BFA463E
|
||||||
|
|
||||||
|
#include "sizenotifiable.hpp"
|
||||||
|
#include "drawable.hpp"
|
||||||
|
|
||||||
|
namespace cloonel {
|
||||||
|
class Texture;
|
||||||
|
class SDLMain;
|
||||||
|
|
||||||
|
class Platform : public Drawable {
|
||||||
|
public:
|
||||||
|
Platform ( SDLMain* parSdlMain, const float2& parPos, Texture* parTexture, const float2& parSize );
|
||||||
|
virtual ~Platform ( void ) noexcept = default;
|
||||||
|
Platform& operator= ( Platform&& parOther );
|
||||||
|
|
||||||
|
virtual void Draw ( void ) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
SizeNotifiable<regbehaviuors::AutoRegister> m_screenRatio;
|
||||||
|
float2 m_position;
|
||||||
|
const float2 m_size;
|
||||||
|
Texture* const m_surface;
|
||||||
|
};
|
||||||
|
} //namespace cloonel
|
||||||
|
|
||||||
|
#endif
|
51
src/platformsystem.cpp
Normal file
51
src/platformsystem.cpp
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
/*
|
||||||
|
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 "platformsystem.hpp"
|
||||||
|
#include "platform.hpp"
|
||||||
|
|
||||||
|
namespace cloonel {
|
||||||
|
///--------------------------------------------------------------------------
|
||||||
|
///--------------------------------------------------------------------------
|
||||||
|
PlatformSystem::PlatformSystem() :
|
||||||
|
m_platforms()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
///--------------------------------------------------------------------------
|
||||||
|
///--------------------------------------------------------------------------
|
||||||
|
PlatformSystem::PlatformSystem (PlatformSystem&& parOther) {
|
||||||
|
m_platforms.swap(parOther.m_platforms);
|
||||||
|
}
|
||||||
|
|
||||||
|
///--------------------------------------------------------------------------
|
||||||
|
///--------------------------------------------------------------------------
|
||||||
|
PlatformSystem::~PlatformSystem() noexcept {
|
||||||
|
}
|
||||||
|
|
||||||
|
///--------------------------------------------------------------------------
|
||||||
|
///--------------------------------------------------------------------------
|
||||||
|
void PlatformSystem::SpawnPlatforms() {
|
||||||
|
}
|
||||||
|
|
||||||
|
///--------------------------------------------------------------------------
|
||||||
|
///--------------------------------------------------------------------------
|
||||||
|
void PlatformSystem::GarbageCollect() {
|
||||||
|
}
|
||||||
|
} //namespace cloonel
|
43
src/platformsystem.hpp
Normal file
43
src/platformsystem.hpp
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
/*
|
||||||
|
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 id17908979556C47F8A978688BBE4A9D22
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
namespace cloonel {
|
||||||
|
class Platform;
|
||||||
|
|
||||||
|
class PlatformSystem {
|
||||||
|
public:
|
||||||
|
PlatformSystem ( void );
|
||||||
|
PlatformSystem ( const PlatformSystem& ) = delete;
|
||||||
|
PlatformSystem ( PlatformSystem&& parOther );
|
||||||
|
~PlatformSystem ( void ) noexcept;
|
||||||
|
PlatformSystem& operator= ( const PlatformSystem& ) = delete;
|
||||||
|
|
||||||
|
void SpawnPlatforms ( void );
|
||||||
|
void GarbageCollect ( void );
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::vector<Platform> m_platforms;
|
||||||
|
};
|
||||||
|
} //namespace cloonel
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in a new issue