MCPcopy Create free account
hub / github.com/SFML/SFML / update

Method update

examples/shader/Shader.cpp:169–195  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

167{
168public:
169 void update(float time, float x, float y) override
170 {
171 m_shader.setUniform("edge_threshold", 1 - (x + y) / 2);
172
173 // Render the updated scene to the off-screen surface
174 m_surface.clear(sf::Color::White);
175
176 sf::Sprite backgroundSprite{m_backgroundTexture};
177 backgroundSprite.setPosition({135.f, 100.f});
178 m_surface.draw(backgroundSprite);
179
180 // Update the position of the moving entities
181 constexpr int numEntities = 6;
182
183 for (int i = 0; i < 6; ++i)
184 {
185 sf::Sprite entity{m_entityTexture, sf::IntRect({96 * i, 0}, {96, 96})};
186
187 entity.setPosition(
188 {std::cos(0.25f * (time * static_cast<float>(i) + static_cast<float>(numEntities - i))) * 300 + 350,
189 std::sin(0.25f * (time * static_cast<float>(numEntities - i) + static_cast<float>(i))) * 200 + 250});
190
191 m_surface.draw(entity);
192 }
193
194 m_surface.display();
195 }
196
197 void draw(sf::RenderTarget& target, sf::RenderStates states) const override
198 {

Callers 2

mainFunction · 0.45
mainFunction · 0.45

Calls 5

setUniformMethod · 0.80
clearMethod · 0.45
setPositionMethod · 0.45
drawMethod · 0.45
displayMethod · 0.45

Tested by

no test coverage detected