aboutsummaryrefslogtreecommitdiff
path: root/game/background/AquariumScript.cpp
diff options
context:
space:
mode:
authorMax-001 <maxsmits21@kpnmail.nl>2025-01-08 11:22:53 +0100
committerMax-001 <maxsmits21@kpnmail.nl>2025-01-08 11:22:53 +0100
commit8fc12804f7f0203564cd6352cf47da13a4f46641 (patch)
tree069c7ffe36fee345cb6532a15435f3fab03371e3 /game/background/AquariumScript.cpp
parentb2fb4028f13f47d89487d48a1cc1e3e062d81e35 (diff)
Made background aquarium move
Diffstat (limited to 'game/background/AquariumScript.cpp')
-rw-r--r--game/background/AquariumScript.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/game/background/AquariumScript.cpp b/game/background/AquariumScript.cpp
new file mode 100644
index 0000000..e698e3a
--- /dev/null
+++ b/game/background/AquariumScript.cpp
@@ -0,0 +1,26 @@
+#include "AquariumScript.h"
+
+#include "../Config.h"
+
+#include <crepe/api/Animator.h>
+#include <crepe/api/Sprite.h>
+#include <crepe/api/Transform.h>
+#include <crepe/types.h>
+
+using namespace crepe;
+using namespace std;
+
+void AquariumScript::fixed_update(crepe::duration_t dt) {
+ 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_aqua");
+ for (Transform & tran : trans) {
+ tran.position.x += 12000;
+ }
+ this->start_x += 12000;
+ }
+}