TazGraph Project v0.1.0
Loading...
Searching...
No Matches
MainMenuBackground.h
1#pragma once
2
3#include "GECS/Animators/AnimatorComponent.h"
4
5
7{
8private:
9 TransformComponent* transform = nullptr;
10 SpriteComponent* sprite = nullptr;
11
12 float elapsedTime = 0.0f;
13public: // it is like it has init that creates Animator Component since it inherits it
14
15
17 {
18
19 }
20
22
23 }
24
25 void init() override {
26 std::shared_ptr<PerspectiveCamera> main_camera2D = std::dynamic_pointer_cast<PerspectiveCamera>(CameraManager::getInstance().getCamera("mainMenu_main"));
27
28 if (!entity->hasComponent<TransformComponent>()) {
30 glm::vec2(
31 -TextureManager::getInstance().Get_GLTexture("graphnetwork")->width / 2,
32 -TextureManager::getInstance().Get_GLTexture("graphnetwork")->height / 2
33 ), Layer::action,
34 glm::ivec2(
35 TextureManager::getInstance().Get_GLTexture("graphnetwork")->width,
36 TextureManager::getInstance().Get_GLTexture("graphnetwork")->height
37 ),
38 1.0f);
39 }
40 if (!entity->hasComponent<SpriteComponent>()) {
41 entity->addComponent<SpriteComponent>("graphnetwork", true);
42 }
43 transform = &entity->GetComponent<TransformComponent>();
44 sprite = &entity->GetComponent<SpriteComponent>();
45
46 }
47
48 void update(float deltaTime) override {
49
50 elapsedTime += deltaTime; // Update the accumulated elapsed time
51 float amplitude = 100.0f; // Maximum displacement along the Y axis
52 float frequency = 0.002f; // How fast the object moves up and down
53
54 // Calculate the new Y position
55 float newY = amplitude * sin(frequency * elapsedTime);
56
57 transform->position.z = newY;
58 }
59
60 std::string GetComponentName() override {
61 return "MainMenuBackground";
62 }
63};
Definition GECS.h:123
T & addComponent(TArgs &&... mArgs)
have addScript function
Definition GECS.h:239
Definition MainMenuBackground.h:7
Definition SpriteComponent.h:17
Definition TransformComponent.h:6