Skip to content

Instantly share code, notes, and snippets.

@domgetter
Last active January 3, 2016 07:19
Show Gist options
  • Save domgetter/8429058 to your computer and use it in GitHub Desktop.
Save domgetter/8429058 to your computer and use it in GitHub Desktop.
require 'gosu'
class Game < Gosu::Window
def initialize
super 640, 480, false
@song = Gosu::Song.new("file.ogg")
@loop_time = Gosu.milliseconds
end
def update
duration = Gosu.milliseconds - @loop_time
#if 112 seconds have passed
if duration > 112000
#play the song
play_song
#and make sure to reset the timer
@loop_time = Gosu.milliseconds
end
end
def draw
end
private
def play_song
@song.play # play song here
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment