aboutsummaryrefslogtreecommitdiff
path: root/game/background/ForestParallaxScript.cpp
diff options
context:
space:
mode:
authorJAROWMR <jarorutjes07@gmail.com>2025-01-03 19:39:23 +0100
committerJAROWMR <jarorutjes07@gmail.com>2025-01-03 19:39:23 +0100
commit4f687de3530fac052f30dac7b8c59dae103bcf81 (patch)
treeaf02b332b6a6efced3357834cc2f30fbfe7b223b /game/background/ForestParallaxScript.cpp
parentd65e0ff31a75230fd1c18eaeab9cb25ab2b9c82a (diff)
parent61148c757a1f742ff09e40e5347e74e638c7371c (diff)
merge
Diffstat (limited to 'game/background/ForestParallaxScript.cpp')
-rw-r--r--game/background/ForestParallaxScript.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/game/background/ForestParallaxScript.cpp b/game/background/ForestParallaxScript.cpp
new file mode 100644
index 0000000..c72f85d
--- /dev/null
+++ b/game/background/ForestParallaxScript.cpp
@@ -0,0 +1,29 @@
+#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;
+ }
+ }
+}