Sha256: a6f9cf8749457d3243ff92c0d72f4fec1e39ab6b0a2e440778cb000bb4371616
Contents?: true
Size: 1.24 KB
Versions: 2
Compression:
Stored size: 1.24 KB
Contents
$:.unshift File.expand_path(File.dirname(__FILE__) + "/../../lib") $:.unshift File.expand_path(File.dirname(__FILE__) + "/../../ext") def path_of(res) File.expand_path(File.dirname(__FILE__) + "/../../test/res/#{res}") end require 'ray' SPEED = 5 Ray.game "Spacial sounds" do register do add_hook :quit, method(:exit!) end scene :spacial do center = window.size / 2 @sound = music path_of("pop.wav") @sound.attenuation = 0.5 @sound.min_distance = 10 @sound.pos = [center.x, center.y, 0] @sound.looping = true @sound.pitch = 1 @sound.relative = false @sound.play @rect = Ray::Polygon.rectangle([0, 0, 10, 10], Ray::Color.blue) @source = Ray::Polygon.rectangle([center.x, center.y, 10, 10], Ray::Color.green) on :key_press, key(:+) do @sound.pitch += 0.1 end on :key_press, key(:-) do @sound.pitch -= 0.1 end always do @rect.x += SPEED if holding? :right @rect.x -= SPEED if holding? :left @rect.y += SPEED if holding? :down @rect.y -= SPEED if holding? :up Ray::Audio.pos = [@rect.x, @rect.y, 0] end render do |win| win.draw @rect win.draw @source end end scenes << :spacial end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ray-0.1.1 | samples/audio/spacial.rb |
ray-0.1.0 | samples/audio/spacial.rb |