Class: CP::BB

Inherits:
Object
  • Object
show all
Defined in:
lib/chipmunk-ffi/bb.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#structObject (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

#bObject



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

Returns:

  • (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

Returns:

  • (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

Returns:

  • (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

#lObject



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

#rObject



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

#tObject



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_sObject



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

#wrap_vect(v) ⇒ Object



60
61
62
63
# File 'lib/chipmunk-ffi/bb.rb', line 60

def wrap_vect(v)
  v_struct = CP.cpBBWrapVect(@struct,v.struct)
  Vec2.new v_struct
end