Created
November 26, 2011 20:49
-
-
Save kyrylo/1396273 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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