Skip to content

Instantly share code, notes, and snippets.

@kyrylo
Created November 26, 2011 20:49
Show Gist options
  • Save kyrylo/1396273 to your computer and use it in GitHub Desktop.
Save kyrylo/1396273 to your computer and use it in GitHub Desktop.
require 'ray'
class BackgroundScene < Ray::Scene
def setup
@bg_color = Ray::Color.yellow
end
def render(win)
win.clear @bg_color
end
end
class ForegroundScene < Ray::Scene
def setup(previous_scene)
@previous_scene = previous_scene
@figure = Ray::Polygon.rectangle([125, 125, 50, 50], Ray::Color.blue)
end
def render(win)
@previous_scene.render(win)
win.draw @figure
end
end
class FoliationExample < Ray::Game
def initialize
super("Foliation example", :size => [300, 300])
BackgroundScene.bind self
ForegroundScene.bind self
scene = registered_scene(:background_scene)
scene.setup
push_scene :foreground_scene, scene
end
end
FoliationExample.new.run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment