From 999e1b928aa632e80521651f14013c267af604dc Mon Sep 17 00:00:00 2001 From: Max-001 Date: Sat, 21 Dec 2024 11:19:52 +0100 Subject: Moved file to sub directory --- game/background/ForestParallaxScript.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 game/background/ForestParallaxScript.cpp (limited to 'game/background/ForestParallaxScript.cpp') 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 vec_2 + = this->get_components_by_name("forest_bg_2_" + name); + RefVector vec_3 + = this->get_components_by_name("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; + } + } +} -- cgit v1.2.3