Class: CP::Shape::Poly
- Inherits:
-
Object
- Object
- CP::Shape::Poly
- Defined in:
- lib/chippunk.rb
Instance Attribute Summary collapse
-
#offset ⇒ Object
readonly
Returns the value of attribute offset.
-
#verts ⇒ Object
readonly
Returns the value of attribute verts.
Instance Method Summary collapse
- #draw(canvas) ⇒ Object
-
#initialize(body, verts, offset) ⇒ Poly
constructor
A new instance of Poly.
- #orig_init ⇒ Object
Constructor Details
#initialize(body, verts, offset) ⇒ Poly
Returns a new instance of Poly.
75 76 77 78 |
# File 'lib/chippunk.rb', line 75 def initialize(body, verts, offset) @verts, @offset = verts, offset orig_init(body, verts, offset) end |
Instance Attribute Details
#offset ⇒ Object (readonly)
Returns the value of attribute offset.
72 73 74 |
# File 'lib/chippunk.rb', line 72 def offset @offset end |
#verts ⇒ Object (readonly)
Returns the value of attribute verts.
72 73 74 |
# File 'lib/chippunk.rb', line 72 def verts @verts end |
Instance Method Details
#draw(canvas) ⇒ Object
80 81 82 83 84 85 86 |
# File 'lib/chippunk.rb', line 80 def draw(canvas) ary = verts.map {|v| body.p + self.offset + v.rotate(body.rot)} segs = ary.enum_cons(2).to_a << [ary[-1],ary[0]] segs.each do |v1,v2| canvas.draw_line(v1.x,v1.y,Gosu::Color.new(0xffff0000),v2.x,v2.y,Gosu::Color.new(0xffff0000)) end end |
#orig_init ⇒ Object
73 |
# File 'lib/chippunk.rb', line 73 alias_method :orig_init, :initialize |