Sha256: 750d0f4c3b00920980a2a5243d0301b26f160d05a5ac5ecd82ac5c5a08248cd9
Contents?: true
Size: 683 Bytes
Versions: 10
Compression:
Stored size: 683 Bytes
Contents
class Ground attr_accessor :x, :y, :len, :rot attr_reader :x1, :y1, :x2, :y2 def initialize(x1, y1, x2, y2) @x1, @y1, @x2, @y2 = x1, y1, x2, y2 @x = (x1 + x2) / 2.0 @y = (y1 + y2) / 2.0 @len = dist(x1, y1, x2, y2) @rot = Math.atan2((y2 - y1), (x2 - x1)) end def dist(x1, y1, x2, y2) Math.sqrt( (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2) ) end end class Orb attr_accessor :x, :y, :r def initialize (x, y, r) @x, @y, @r = x, y, r end def move v @x += v.x @y += v.y end end class Vect attr_accessor :x, :y def initialize(x, y) @x, @y = x, y end def add v @x += v.x @y += v.y end end
Version data entries
10 entries across 10 versions & 1 rubygems