Sha256: 9d5f6ce30fcfc594d8e512179f59b55b5dc36dc2e0a98c59385e96824a674b41

Contents?: true

Size: 850 Bytes

Versions: 2

Compression:

Stored size: 850 Bytes

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'

Ray.game "Some effects" do
  register { add_hook :quit, method(:exit!) }

  scene :shader do
    @obj = sprite path_of("sprite.png")

    effect_generator do |gen|
      gen << color_inversion << grayscale
      gen.build window.shader
    end

    @states = Hash.new(true)

    {
      :color_inversion => :i,
      :grayscale       => :g
    }.each do |state, key_name|
      on :key_press, key(key_name) do
        @states[state] = !@states[state]
        window.shader["#{state}.enabled"] = @states[state]
      end
    end

    render do |win|
      win.draw @obj
    end
  end

  scenes << :shader
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ray-0.2.1 samples/effects/effect.rb
ray-0.2.0 samples/effects/effect.rb