MCPcopy Create free account
hub / github.com/JeanPhilippeKernel/RendererEngine / Update

Method Update

Tetragrama/src/Layers/RenderLayer.cpp:101–166  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

99 }
100
101 void RenderLayer::Update(TimeStep dt) {
102 m_scene->Update(dt);
103
104 auto box_entity = m_scene->GetEntity("box");
105 auto light_entity = m_scene->GetEntity("light");
106
107 auto& box_component = box_entity.GetComponent<TransformComponent>();
108 auto angle = box_component.GetRotationAngle();
109 box_component.SetRotationAngle(angle + std::sin(dt * 0.05f));
110
111 if (IDevice::As<Inputs::Keyboard>()->IsKeyPressed(ZENGINE_KEY_UP, GetAttachedWindow())) {
112 auto& component = light_entity.GetComponent<TransformComponent>();
113 auto position = component.GetPosition();
114 position.y += .5f;
115 component.SetPosition(position);
116 }
117
118 if (IDevice::As<Inputs::Keyboard>()->IsKeyPressed(ZENGINE_KEY_DOWN, GetAttachedWindow())) {
119 auto& component = light_entity.GetComponent<TransformComponent>();
120 auto position = component.GetPosition();
121 position.y -= .5f;
122 component.SetPosition(position);
123 }
124
125 if (IDevice::As<Inputs::Keyboard>()->IsKeyPressed(ZENGINE_KEY_LEFT, GetAttachedWindow())) {
126 auto& component = light_entity.GetComponent<TransformComponent>();
127 auto position = component.GetPosition();
128 position.x -= .5f;
129 component.SetPosition(position);
130 }
131
132 if (IDevice::As<Inputs::Keyboard>()->IsKeyPressed(ZENGINE_KEY_RIGHT, GetAttachedWindow())) {
133 auto& component = light_entity.GetComponent<TransformComponent>();
134 auto position = component.GetPosition();
135 position.x += .5f;
136 component.SetPosition(position);
137 }
138
139 if (IDevice::As<Inputs::Keyboard>()->IsKeyPressed(ZENGINE_KEY_W, GetAttachedWindow())) {
140 auto& component = box_entity.GetComponent<TransformComponent>();
141 auto position = component.GetPosition();
142 position.y += .5f;
143 component.SetPosition(position);
144 }
145
146 if (IDevice::As<Inputs::Keyboard>()->IsKeyPressed(ZENGINE_KEY_S, GetAttachedWindow())) {
147 auto& component = box_entity.GetComponent<TransformComponent>();
148 auto position = component.GetPosition();
149 position.y -= .5f;
150 component.SetPosition(position);
151 }
152
153 if (IDevice::As<Inputs::Keyboard>()->IsKeyPressed(ZENGINE_KEY_A, GetAttachedWindow())) {
154 auto& component = box_entity.GetComponent<TransformComponent>();
155 auto position = component.GetPosition();
156 position.x -= .5f;
157 component.SetPosition(position);
158 }

Callers

nothing calls this directly

Calls 6

GetEntityMethod · 0.80
GetRotationAngleMethod · 0.45
SetRotationAngleMethod · 0.45
IsKeyPressedMethod · 0.45
GetPositionMethod · 0.45
SetPositionMethod · 0.45

Tested by

no test coverage detected