Skip to content

Commit

Permalink
get better at hitting the target framerate
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Dvořák committed Feb 28, 2025
1 parent 9fe3f3f commit a0b4979
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion skladnik.rb
Original file line number Diff line number Diff line change
Expand Up @@ -427,13 +427,16 @@ def render
end

def render_frame
sleep_time = 0.03 - (Time.now - @t_prev_frame) if @t_prev_frame
sleep sleep_time if sleep_time &.> 0
@t_prev_frame = Time.now

if IO.console.winsize != @winsize
@winsize = IO.console.winsize
IO.console.clear_screen
end
IO.console.cursor = [0, 0]
puts render
sleep 0.03
end

# moves a crate along the specified path, with the worker following after it
Expand Down

0 comments on commit a0b4979

Please sign in to comment.