8 std::string temp_lineParsed =
"";
10 glm::vec3 velocity = glm::vec3(0);
11 glm::vec3 rotation = { 0.0f,0.0f,0.0f };
12 glm::vec3 position = glm::vec3(0);
13 glm::vec3 size = glm::vec3(0);
15 glm::vec3 last_position = glm::vec3(0);
16 glm::vec3 last_size = glm::vec3(0);
17 glm::vec3 last_velocity = glm::vec3(0);
20 glm::vec3 bodyCenter = { 0.0f,0.0f,0.0f };
37 position.x = m_position.x;
38 position.y = m_position.y;
39 bodyCenter = position + (size / 2.0f);
44 position = m_position;
45 bodyCenter = position + (size / 2.0f);
49 position = { m_position.x, m_position.y, getLayerDepth(layer) };
50 size = { m_size.x, m_size.y, 0.0f };
52 bodyCenter = position + (size / 2.0f);
78 void update(
float deltaTime)
override
81 if (entity->getParentEntity() &&
dynamic_cast<NodeEntity*
>(entity->getParentEntity())) {
82 Entity* parent = entity->getParentEntity();
85 parentTR->position == parentTR->last_position
86 && parentTR->size == parentTR->last_size
87 && parentTR->velocity == parentTR->last_velocity
92 bodyCenter = parentTR->getCenterTransform() + position;
96 bodyCenter = position + (size / 2.0f);
99 if (position == last_position && size == last_size && velocity == last_velocity) {
103 entity->cellUpdate();
105 last_position = position;
107 last_velocity = velocity;
109 position.x += velocity.x * speed * deltaTime;
110 position.y += velocity.y * speed * deltaTime;
120 glm::vec3 getCenterTransform()
125 glm::vec3 getSizeCenter() {
126 return glm::vec3(size.x * scale / 2, size.y * scale / 2, size.z * scale / 2);
129 glm::vec3 getPosition() {
133 void setPosition_X(
float newPosition_X) {
134 position.x = newPosition_X;
136 void setPosition_Y(
float newPosition_Y) {
137 position.y = newPosition_Y;
140 glm::vec3 getVelocity() {
144 void setVelocity_X(
float newVelocity_X) {
145 velocity.x = newVelocity_X;
147 void setVelocity_Y(
float newVelocity_Y) {
148 velocity.y = newVelocity_Y;
151 void setRotation(glm::vec3 m_rotation) {
152 rotation = m_rotation;
155 std::string GetComponentName()
override {
156 return "TransformComponent";
159 void showGUI()
override {
162 ImGui::Text(
"Line: %s", temp_lineParsed.c_str());
165 ImGui::Text(
"Position:");
166 ImGui::SliderFloat3(
"##position", &position.x, -1000.0f, 1000.0f);
169 ImGui::Text(
"Size:");
170 ImGui::SliderFloat3(
"##size", &size.x, 1.0f, 100.0f);
173 ImGui::Text(
"Rotation:");
174 ImGui::SliderFloat3(
"##rotation", glm::value_ptr(rotation), -180.0f, 180.0f);
176 ImGui::Text(
"Scale:");
177 ImGui::SliderFloat(
"##scale", &scale, 0.1f, 10.0f);
180 ImGui::Text(
"Speed:");
181 ImGui::InputInt(
"##speed", &speed);