Sha256: e0695a17578a89a697873c6dbbc2c3c7ab7fbcf589fbcdc65e69052a5d8be58d
Contents?: true
Size: 783 Bytes
Versions: 1
Compression:
Stored size: 783 Bytes
Contents
module Shape class << self attr_accessor :points end @points = { :missile => { :points => [[-1,0],[0,-2],[1,0]], :close => false }, :silo => { :points => [], :close => true } } end module Wireframe def build_wireframe opts scale = 5 @wireframe = opts[:points].cycle.each_cons(2).take(opts[:points].length) @wireframe.map!{ |p1, p2| [Vector2d.new( p1[0] * scale, p1[1] * scale ), Vector2d.new( p2[0] * scale, p2[1] * scale )] } @wireframe.pop unless opts[:close] end def draw super return @wireframe.each do |v1, v2| radians = @angle.degrees_to_radians $lotu.draw_line(v1.rotate(radians).x + x, v1.rotate(radians).y + y, @color, v2.rotate(radians).x + x, v2.rotate(radians).y + y, @color) end if @wireframe end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
missile-command-ruby-0.0.8 | lib/experimental.rb |