Is it possible to render a particular object on the screen for a certain number of frames without having to delay the rendering? Thanks
1 Answer
\$\begingroup\$
\$\endgroup\$
0
Indeed it is.
Assuming that your object has a method such as Update() that gets called once per fame, you can simply count your frames and toggle a boolean that you use to determine the rendering.
class Object
{
public:
bool visible = true;
void Update()
{
frames++;
visible = frames < 10; // Or however many frames you want to display the object.
}
private:
int frames = 0;
};
// Main loop:
while (True)
{
HandleEvents()()
object.Update()
ClearWindow()
if (object.visible)
{
object.Render()
}
UpdateWindow()
}
That is a very basic example of what you might be looking for.