Created
August 20, 2014 01:14
-
-
Save changemewtf/625699d8b499558f67cf 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' | |
# Prerequisites: | |
# brew install glew libsndfile | |
# Tutorial: | |
# http://mon-ouie.github.io/projects/ray.html | |
quit_game = Proc.new do | |
# This method doesn't exist yet. It is defined inside Ray, but since the | |
# quit_game Proc doesn't run until Ray is setup, it doesn't matter! | |
exit! | |
end | |
game = Ray.game('Hello') do | |
# We have to make this into a block because it must be run | |
# every time the scene changes | |
register() do | |
on(:quit, &quit_game) | |
on(:key_press, key(:q), &quit_game) | |
end | |
scene(:hello) do | |
@text = text("Hello, world!", {:size => 50, :at => [50, 50]}) | |
@obj = Ray::Polygon.rectangle([0, 0, 100, 100], Ray::Color.blue()) | |
@obj.pos = [100, 350] | |
on(:mouse_motion) do |pos| | |
@obj.pos = pos | |
end | |
render() do |win| | |
win.draw(@text) | |
win.draw(@obj) | |
end | |
end | |
scenes.push(:hello) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment