Class: CP::BB
- Inherits:
-
Object
- Object
- CP::BB
- Defined in:
- lib/chipmunk-ffi/bb.rb
Instance Attribute Summary collapse
-
#struct ⇒ Object
readonly
Returns the value of attribute struct.
Instance Method Summary collapse
- #b ⇒ Object
- #b=(new_b) ⇒ Object
- #clamp_vect(v) ⇒ Object
- #contains_bb?(other_bb) ⇒ Boolean
- #contains_vect?(other_bb) ⇒ Boolean
-
#initialize(*args) ⇒ BB
constructor
A new instance of BB.
- #intersect?(other_bb) ⇒ Boolean
- #l ⇒ Object
- #l=(new_l) ⇒ Object
- #r ⇒ Object
- #r=(new_r) ⇒ Object
- #t ⇒ Object
- #t=(new_t) ⇒ Object
- #to_s ⇒ Object
- #wrap_vect(v) ⇒ Object
Constructor Details
#initialize(*args) ⇒ BB
Returns a new instance of BB.
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/chipmunk-ffi/bb.rb', line 20 def initialize(*args) case args.size when 1 @struct = args.first when 4 @struct = CP.cpBBNew(*args) else raise "wrong number of args for BB, got #{args.size}, but expected 4" end end |
Instance Attribute Details
#struct ⇒ Object (readonly)
Returns the value of attribute struct.
19 20 21 |
# File 'lib/chipmunk-ffi/bb.rb', line 19 def struct @struct end |
Instance Method Details
#b ⇒ Object
31 |
# File 'lib/chipmunk-ffi/bb.rb', line 31 def b;@struct.b;end |
#b=(new_b) ⇒ Object
36 |
# File 'lib/chipmunk-ffi/bb.rb', line 36 def b=(new_b);@struct.b=new_b;end |
#clamp_vect(v) ⇒ Object
55 56 57 58 |
# File 'lib/chipmunk-ffi/bb.rb', line 55 def clamp_vect(v) v_struct = CP.cpBBClampVect(@struct,v.struct) Vec2.new v_struct end |
#contains_bb?(other_bb) ⇒ Boolean
45 46 47 48 |
# File 'lib/chipmunk-ffi/bb.rb', line 45 def contains_bb?(other_bb) b = CP.cpBBcontainsBB(@struct,other_bb.struct) b == 0 ? false : true end |
#contains_vect?(other_bb) ⇒ Boolean
50 51 52 53 |
# File 'lib/chipmunk-ffi/bb.rb', line 50 def contains_vect?(other_bb) b = CP.cpBBcontainsVect(@struct,other_bb.struct) b == 0 ? false : true end |
#intersect?(other_bb) ⇒ Boolean
40 41 42 43 |
# File 'lib/chipmunk-ffi/bb.rb', line 40 def intersect?(other_bb) b = CP.cpBBintersects(@struct,other_bb.struct) b == 0 ? false : true end |
#l ⇒ Object
30 |
# File 'lib/chipmunk-ffi/bb.rb', line 30 def l;@struct.l;end |
#l=(new_l) ⇒ Object
35 |
# File 'lib/chipmunk-ffi/bb.rb', line 35 def l=(new_l);@struct.l=new_l;end |
#r ⇒ Object
32 |
# File 'lib/chipmunk-ffi/bb.rb', line 32 def r;@struct.r;end |
#r=(new_r) ⇒ Object
37 |
# File 'lib/chipmunk-ffi/bb.rb', line 37 def r=(new_r);@struct.r=new_r;end |
#t ⇒ Object
33 |
# File 'lib/chipmunk-ffi/bb.rb', line 33 def t;@struct.t;end |
#t=(new_t) ⇒ Object
38 |
# File 'lib/chipmunk-ffi/bb.rb', line 38 def t=(new_t);@struct.t=new_t;end |
#to_s ⇒ Object
65 66 67 |
# File 'lib/chipmunk-ffi/bb.rb', line 65 def to_s "#<CP::BB:(% .3f, % .3f) -> (% .3f, % .3f)>" % [l,b,r,t] end |