This file contains hidden or 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
| def command(action) | |
| case action | |
| when "L" | |
| puts "It's a L" | |
| when "R" | |
| puts "It's a R" | |
| when "F" | |
| puts "It's a F" | |
| when "P" | |
| puts "It's a P" |
This file contains hidden or 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' | |
| Ray::Game.new(:video_modes => %w(640x480)) do | |
| scene(:mouse) do | |
| @rect = Ray::Image.new(:w => 50, :h => 50).fill(Ray::Color.red) | |
| @pos = [0, 0] | |
| on :mouse_motion do |pos| | |
| @pos = [pos.x - 25, pos.y - 25] | |
| need_render! |
This file contains hidden or 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
| @ri_driver = RDoc::RI::Driver.new(:use_cache => false, | |
| :use_stdout => false, | |
| :use_system => true, | |
| :use_site => true, | |
| :use_home => true, | |
| :use_gems => true) | |
| def ri_cache_for(full_name) | |
| begin | |
| name = RDoc::RI::NameDescriptor.new(full_name) |
This file contains hidden or 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 'benchmark' | |
| n = 1e7.to_i | |
| Benchmark.bm do |x| | |
| x.report("if") do | |
| n.times { nil if !false } | |
| end | |
| x.report("unless") do |
This file contains hidden or 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
| game "Hello world!" do | |
| scene :hello do | |
| @font = Ray::Font.new("VeraMono.ttf", 12) | |
| on :quit do | |
| exit! | |
| end | |
| render do |win| | |
| @font.draw("Hello world!", :on => win, :at => [0, 0]) |
This file contains hidden or 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' | |
| Ray::Game.new("Formula") do | |
| register do | |
| add_hook :quit, method(:exit!) | |
| end | |
| scene :graphic do | |
| @code, @rect = scene_arguments | |
This file contains hidden or 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 Point < Struct.new(:x, :y) | |
| def self.random | |
| Point.new(rand, rand) | |
| end | |
| def self.random_inside(rect) | |
| Point.new(rand((rect.w - rect.x).abs) + rect.x, | |
| rand((rect.h - rect.y).abs) + rect.y) |
This file contains hidden or 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' | |
| require 'optparse' | |
| module Life | |
| DEFAULT_OPTIONS = { | |
| :file => nil, | |
| :random => true, | |
| :tile_size => [16, 16], | |
| :updates_per_sec => 10.0, | |
| :life_chance => 0.2, |
This file contains hidden or 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
| module Rame | |
| class Map < Struct.new(:title, :identifier, :tileset, :size, :filename, :project) | |
| attr_accessor :layers | |
| def self.load(filename) | |
| obj = YAML.load(File.read(filename)) | |
| obj | |
| end | |
| def initialize(*args) |
This file contains hidden or 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
| class Class | |
| attr_accessor :__defaults | |
| def attr_accessor_defaults(attributes) | |
| attr_accessor(*attributes.keys) | |
| (@__defaults ||= {}).merge!(attributes) | |
| end | |
| def inherited(subclass) | |
| subclass.class_eval do |