Class: CP::Shape::Segment

Inherits:
Object
  • Object
show all
Defined in:
lib/chippunk.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(body, a, b, radius) ⇒ Segment

Returns a new instance of Segment.



33
34
35
36
# File 'lib/chippunk.rb', line 33

def initialize(body, a, b, radius)
  @a, @b, @radius = a, b, radius
  orig_init(body, a, b, radius)
end

Instance Attribute Details

#aObject (readonly)

Returns the value of attribute a.



30
31
32
# File 'lib/chippunk.rb', line 30

def a
  @a
end

#bObject (readonly)

Returns the value of attribute b.



30
31
32
# File 'lib/chippunk.rb', line 30

def b
  @b
end

#radiusObject (readonly)

Returns the value of attribute radius.



30
31
32
# File 'lib/chippunk.rb', line 30

def radius
  @radius
end

Instance Method Details

#draw(canvas) ⇒ Object



38
39
40
41
42
# File 'lib/chippunk.rb', line 38

def draw(canvas)
  v1 = body.p + self.a.rotate(body.rot)
  v2 = body.p + self.b.rotate(body.rot)
  canvas.draw_line(v1.x, v1.y, Gosu::Color.new(0xffff0000), v2.x, v2.y, Gosu::Color.new(0xffff0000))
end

#orig_initObject



31
# File 'lib/chippunk.rb', line 31

alias_method :orig_init, :initialize