RSpec Code Examples

 

 

Physical#add_force
moves the object
moves more massive objects less distance with the same force
Physical#add_velocity
adds a velocity to the object
is cumulative
is negatable
Physical#add_excluded_physical
allows the object to occupy the same space as the given target
Physical#angular_damping=
slows rotation continually when angular damping is applied
expected: < -499.0,
     got:   249001.0
test/unit/behaviors/physical_spec.rb:87:
85      old_value = @game_object.angular_velocity
86      do_update
87      @game_object.angular_velocity.should < old_value
88    end
89    it "does not slow if angular damping is zero" do
90# gem install syntax to get syntax highlighting
does not slow if angular damping is zero
Physical#angular_velocity=
sets the object's angular velocity to an absolute value
works even if the object is already rotating
Physical#apply_angular_velocity
adds to the object's angular velocity
is cumulative
is negatable
Physical#come_to_rest
stops moving
stops rotating
Physical#exclude_all_physicals
causes the object not to interact even with new objects
Physical#friction=
slows continually when friction is applied
expected: < 1.0,
     got:   1.0
test/unit/behaviors/physical_spec.rb:171:
169      @game_object.friction = 1.0
170      do_update
171      @game_object.velocity.x.should < 1.0
172      old_x = @game_object.velocity.x
173      do_update
174# gem install syntax to get syntax highlighting
does not slow if friction is zero
Physical#get_collision_events
returns events for objects currently colliding with this one
does not return any events if there was no collision
does not return any events if other object is excluded from physical interaction
Physical#gravity_effected=
turns gravity on for object when true
turns gravity off for object when false
Physical#set_static_body
becomes immobile
stops moving
stops rotating
Physical#speed_limit
restricts the object to the given x/y velocity
Physical#velocity=
sets the object's velocity to an absolute value
works even if the object is already moving