diff options
author | WBoerenkamps <wrj.boerenkamps@student.avans.nl> | 2025-01-08 12:17:36 +0100 |
---|---|---|
committer | WBoerenkamps <wrj.boerenkamps@student.avans.nl> | 2025-01-08 12:17:36 +0100 |
commit | dc5d46426b30303843e8746d514db6f55ce1495b (patch) | |
tree | 2b01a358b3daa4f55e54ca2c87f58becf83edeb8 /game/background/ForestParallaxScript.cpp | |
parent | 1a5744a3285a5ba5132fb4f6f031c27df1b64d33 (diff) | |
parent | c9c9702edc58ff8f40b13dc6b86b216421f79e9b (diff) |
Merge branch 'master' of https://github.com/lonkaars/crepe into wouter/enemyAI
Diffstat (limited to 'game/background/ForestParallaxScript.cpp')
-rw-r--r-- | game/background/ForestParallaxScript.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/game/background/ForestParallaxScript.cpp b/game/background/ForestParallaxScript.cpp index c72f85d..7470da2 100644 --- a/game/background/ForestParallaxScript.cpp +++ b/game/background/ForestParallaxScript.cpp @@ -1,5 +1,7 @@ #include "ForestParallaxScript.h" +#include "../Config.h" + using namespace crepe; using namespace std; @@ -26,4 +28,28 @@ void ForestParallaxScript::fixed_update(crepe::duration_t dt) { t.position.x = begin_x - 400; } } + + //Move whole background 12000 to the right + Transform & trans_cam = this->get_components_by_name<Transform>("camera").front(); + + float cam_left_x = trans_cam.position.x - VIEWPORT_X / 2; + + if (cam_left_x > this->start_x + this->lenght) { + //Move whole background 12000 to the right + RefVector<Transform> trans + = this->get_components_by_tag<Transform>("background_forest"); + for (Transform & tran : trans) { + tran.position.x += 12000; + } + this->start_x += 12000; + + RefVector<Transform> trans_back + = this->get_components_by_tag<Transform>("forest_background"); + for (Transform & tran : trans_back) { + tran.position.x += 12000; + } + + begin_x += 12000; + end_x += 12000; + } } |