0
\$\begingroup\$

Is it possible to render a particular object on the screen for a certain number of frames without having to delay the rendering? Thanks

\$\endgroup\$
0

1 Answer 1

1
\$\begingroup\$

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.

\$\endgroup\$
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .