Sha256: 912d0074eaf6bbec29efe41c12432b20ba72e657cbda258f5507bd90f7496642
Contents?: true
Size: 1.14 KB
Versions: 2
Compression:
Stored size: 1.14 KB
Contents
# -*- coding: utf-8 -*- %w[xot rays reflex] .map {|s| File.expand_path "../../../../#{s}/lib", __FILE__} .each {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)} require 'reflexion/include' $garbages = [] class View def setup (frame: [0, 0, 100, 100], color: :white, type: :static) set frame: frame, fill: color, density: 1, friction: 0, restitution: 1, type => true end end setup do set size: [600, 400] wall.set friction: 0 5.times do |y| 10.times do |x| add RectShape.new { setup frame: [(x + 1) * 50, (y + 1) * 20, 30, 10], color: [:white, :red, :green, :blue, :yellow][y] on(:contact) {$garbages << self} } end end $bar = add RectShape.new { setup frame: [0, 350, 100, 20], color: :blue } end update do $garbages.uniq.each {|o| o.parent.remove o} $garbages.clear end draw do text "#{event.fps.to_i} FPS", 10, 10 end pointer do |e| $bar.x = e.x - $bar.w / 2 if e.down? window.add [EllipseShape, RectShape].sample.new { setup frame: [e.x, $bar.y - 20, 20, 20], type: :dynamic set :linear_velocity, Point.new(rand(-1.0..1.0), -1).normal * 500 } end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
reflexion-0.1.9.1 | samples/reflexion/breakout.rb |
reflexion-0.1.9 | samples/reflexion/breakout.rb |