generated from Laguna1989/JamTemplateCpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ae6d233
commit 10e7b5e
Showing
6 changed files
with
115 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
|
||
#include "wind_particles.hpp" | ||
#include <game_properties.hpp> | ||
#include <random/random.hpp> | ||
#include <screeneffects/screen_wrap.hpp> | ||
|
||
void WindParticles::doCreate() | ||
{ | ||
for (auto i = 0U; i != 100U; ++i) { | ||
auto s = std::make_shared<jt::Shape>(); | ||
s->makeRect({ 8, 2 }, textureManager()); | ||
s->setPosition( | ||
jt::Random::getRandomPointIn({ 0, 0, GP::GetScreenSize().x, GP::GetScreenSize().y })); | ||
s->setScreenSizeHint(GP::GetScreenSize()); | ||
if (jt::Random::getChance()) { | ||
s->setColor(GP::getPalette().getColor(1)); | ||
} else { | ||
s->setColor(GP::getPalette().getColor(6)); | ||
} | ||
|
||
m_shapes.push_back(s); | ||
} | ||
} | ||
void WindParticles::doUpdate(float const elapsed) | ||
{ | ||
jt::Vector2f const windSpeed { -150.0f, 0.0f }; | ||
for (auto& s : m_shapes) { | ||
auto p = s->getPosition(); | ||
// float const f = | ||
p += windSpeed * elapsed * m_windSpeed; | ||
s->setPosition(p); | ||
jt::wrapOnScreen(*s.get()); | ||
s->update(elapsed); | ||
} | ||
} | ||
void WindParticles::doDraw() const | ||
{ | ||
for (auto const& s : m_shapes) { | ||
s->draw(renderTarget()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#ifndef INC_1HGJ384_WIND_PARTICLES_HPP | ||
#define INC_1HGJ384_WIND_PARTICLES_HPP | ||
|
||
#include "game_object.hpp" | ||
#include "shape.hpp" | ||
class WindParticles : public jt::GameObject { | ||
|
||
void doCreate() override; | ||
void doUpdate(float const elapsed) override; | ||
void doDraw() const override; | ||
|
||
std::vector<std::shared_ptr<jt::Shape>> m_shapes; | ||
|
||
public: | ||
float m_windSpeed { 1.0f }; | ||
}; | ||
|
||
#endif // INC_1HGJ384_WIND_PARTICLES_HPP |