summaryrefslogtreecommitdiffhomepage
path: root/lib
diff options
context:
space:
mode:
authorTom Black <[email protected]>2017-02-17 00:50:09 -0500
committerTom Black <[email protected]>2017-02-17 00:50:09 -0500
commite11976895af419e7411ae1d326779ff04909b6ca (patch)
tree912d41835e5600f2899942568ccb25656073591d /lib
parentb017a89612b3e264467eeb481f2c4bfeee81e825 (diff)
downloadruby2d-e11976895af419e7411ae1d326779ff04909b6ca.tar.gz
ruby2d-e11976895af419e7411ae1d326779ff04909b6ca.zip
Add sound and music classes
Diffstat (limited to 'lib')
-rw-r--r--lib/ruby2d.rb2
-rw-r--r--lib/ruby2d/music.rb16
-rw-r--r--lib/ruby2d/sound.rb14
3 files changed, 23 insertions, 9 deletions
diff --git a/lib/ruby2d.rb b/lib/ruby2d.rb
index 125ad82..4be4f39 100644
--- a/lib/ruby2d.rb
+++ b/lib/ruby2d.rb
@@ -12,6 +12,8 @@ require 'ruby2d/triangle'
require 'ruby2d/image'
require 'ruby2d/sprite'
require 'ruby2d/text'
+require 'ruby2d/sound'
+require 'ruby2d/music'
require 'ruby2d/ruby2d' # load native extension
include Ruby2D::DSL
diff --git a/lib/ruby2d/music.rb b/lib/ruby2d/music.rb
new file mode 100644
index 0000000..6d9475e
--- /dev/null
+++ b/lib/ruby2d/music.rb
@@ -0,0 +1,16 @@
+# music.rb
+
+module Ruby2D
+ class Music
+
+ attr_accessor :data, :loop
+ attr_reader :path
+
+ def initialize(path)
+ # TODO: Check if file exists
+ @path = path
+ @loop = false
+ end
+
+ end
+end
diff --git a/lib/ruby2d/sound.rb b/lib/ruby2d/sound.rb
index edbbef9..4691f6d 100644
--- a/lib/ruby2d/sound.rb
+++ b/lib/ruby2d/sound.rb
@@ -3,16 +3,12 @@
module Ruby2D
class Sound
- def initialize(window, path)
- unless File.exists? path
- raise Error, "Cannot find sound file!"
- end
- window.create_audio(self, path)
- @window, @path = window, path
- end
+ attr_accessor :data
+ attr_reader :path
- def play
- @window.play_audio(self)
+ def initialize(path)
+ # TODO: Check if file exists
+ @path = path
end
end