From 8fc12804f7f0203564cd6352cf47da13a4f46641 Mon Sep 17 00:00:00 2001 From: Max-001 Date: Wed, 8 Jan 2025 11:22:53 +0100 Subject: Made background aquarium move --- game/background/AquariumScript.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 game/background/AquariumScript.cpp (limited to 'game/background/AquariumScript.cpp') 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 +#include +#include +#include + +using namespace crepe; +using namespace std; + +void AquariumScript::fixed_update(crepe::duration_t dt) { + Transform & trans_cam = this->get_components_by_name("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 trans = this->get_components_by_tag("background_aqua"); + for (Transform & tran : trans) { + tran.position.x += 12000; + } + this->start_x += 12000; + } +} -- cgit v1.2.3