diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-12-22 11:53:15 +0100 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-12-22 11:53:15 +0100 |
commit | 794facac7a7a1886bc2e0fea4c19c1106d6b458e (patch) | |
tree | 9518ed7903cf1b38af293cfd60146376f1016504 /game/background/ForestParallaxScript.cpp | |
parent | f5d2ef9a5a335509f6ade05470938f0fbbbb74ad (diff) | |
parent | e7599e648ea24d5e8a27bd9f4f162ef1a7c53d21 (diff) |
Merge branch 'max/game' of github.com:lonkaars/crepe
Diffstat (limited to 'game/background/ForestParallaxScript.cpp')
-rw-r--r-- | game/background/ForestParallaxScript.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/game/background/ForestParallaxScript.cpp b/game/background/ForestParallaxScript.cpp new file mode 100644 index 0000000..27e30eb --- /dev/null +++ b/game/background/ForestParallaxScript.cpp @@ -0,0 +1,28 @@ +#include "ForestParallaxScript.h" + +using namespace crepe; +using namespace std; + +ForestParallaxScript::ForestParallaxScript(float begin_x, float end_x, + std::string unique_bg_name) + : begin_x(begin_x), + end_x(end_x), + name(unique_bg_name) {} + +void ForestParallaxScript::fixed_update(crepe::duration_t dt) { + RefVector<Transform> vec_2 + = this->get_components_by_name<Transform>("forest_bg_2_" + name); + RefVector<Transform> vec_3 + = this->get_components_by_name<Transform>("forest_bg_3_" + name); + + for (Transform & t : vec_2) { + if (t.position.x > end_x - 400) { + t.position.x = begin_x - 400; + } + } + for (Transform & t : vec_3) { + if (t.position.x > end_x - 400) { + t.position.x = begin_x - 400; + } + } +} |