M
Michael Tomer
I'm trying to write a loop that will only run a certain number of times
per second. For instance, in Ruby-Processing, you would use
"frame_rate(30)" to make the main loop execute no more than 30 evenly
spaced frames per second. How might I go about doing something like
that?
I could try calling sleep with a float that represents the difference
between the next time I want the loop to run and the current time. That
seems clunky, though.
I also thought about using the Observer pattern to have a timer alert
the simulation each time it should update. That also seems wrong.
I feel like I must be overlooking something simple. Any ideas?
per second. For instance, in Ruby-Processing, you would use
"frame_rate(30)" to make the main loop execute no more than 30 evenly
spaced frames per second. How might I go about doing something like
that?
I could try calling sleep with a float that represents the difference
between the next time I want the loop to run and the current time. That
seems clunky, though.
I also thought about using the Observer pattern to have a timer alert
the simulation each time it should update. That also seems wrong.
I feel like I must be overlooking something simple. Any ideas?