Skip to content

Commit

Permalink
Make Crystal example a bit more Crystal-ish (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sija authored Oct 26, 2024
1 parent 4284408 commit 80f6529
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions crystal/src/main.cr
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ require "sdl/image"

begin
SDL.init(SDL::Init::VIDEO)

at_exit { SDL.quit }

window = SDL::Window.new("Hello, World!", 620, 387)
Expand All @@ -14,17 +13,16 @@ begin
png = SDL::IMG.load(File.join("..", "img", "grumpy-cat.png"))
png = png.convert(window.surface)

start_time = Time.utc
start_time = Time.monotonic
loop do
png.blit(window.surface)
window.update

if (Time.utc - start_time).seconds > 2
if (Time.monotonic - start_time).total_seconds > 2
break
end
end

rescue ex
puts "Error: " + ex.message.to_s
exit 1
abort "Error: #{ex.message}"
end

0 comments on commit 80f6529

Please sign in to comment.