Class: CP::Shape::Segment
- Inherits:
-
Object
- Object
- CP::Shape::Segment
- Defined in:
- lib/chippunk.rb
Instance Attribute Summary collapse
-
#a ⇒ Object
readonly
Returns the value of attribute a.
-
#b ⇒ Object
readonly
Returns the value of attribute b.
-
#radius ⇒ Object
readonly
Returns the value of attribute radius.
Instance Method Summary collapse
- #draw(canvas) ⇒ Object
-
#initialize(body, a, b, radius) ⇒ Segment
constructor
A new instance of Segment.
- #orig_init ⇒ Object
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
#a ⇒ Object (readonly)
Returns the value of attribute a.
30 31 32 |
# File 'lib/chippunk.rb', line 30 def a @a end |
#b ⇒ Object (readonly)
Returns the value of attribute b.
30 31 32 |
# File 'lib/chippunk.rb', line 30 def b @b end |
#radius ⇒ Object (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_init ⇒ Object
31 |
# File 'lib/chippunk.rb', line 31 alias_method :orig_init, :initialize |