Class: Pongo::CircleParticle
- Inherits:
-
AbstractParticle
- Object
- AbstractItem
- AbstractParticle
- Pongo::CircleParticle
- Defined in:
- lib/pongo/circle_particle.rb
Overview
A circle shaped particle.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#radius ⇒ Object
Returns the value of attribute radius.
Attributes inherited from AbstractParticle
#center, #collidable, #collision, #curr, #first_collision, #fixed, #force_list, #forces, #friction, #interval, #inv_mass, #kfr, #mass, #multisample, #prev, #samp, #temp
Attributes inherited from AbstractItem
#always_repaint, #display_object, #display_object_offset, #display_object_rotation, #fill_alpha, #fill_color, #line_alpha, #line_color, #line_thickness, #renderer, #solid, #user_data, #visible
Instance Method Summary collapse
-
#initialize(x, y, radius, options = {}) ⇒ CircleParticle
constructor
A new instance of CircleParticle.
- #interval_x ⇒ Object (also: #get_interval_x)
- #interval_y ⇒ Object (also: #get_interval_y)
- #projection(axis) ⇒ Object (also: #get_projection)
Methods inherited from AbstractParticle
#accumulate_forces, #add_force, #clear_forces, #collidable!, #collidable?, #components, #elasticity, #elasticity=, #fixed?, #position, #position=, #px, #px=, #py, #py=, #reset_first_collision!, #resolve_collision, #solid?, #test_particle_events, #update, #velocity, #velocity=
Methods inherited from AbstractItem
#add_event_listener, #always_redraw!, #always_redraw=, #always_redraw?, #cleanup, #dispatch_event, #draw, #has_event_listener, #init, #set_fill, #set_line, #set_style, #visible!, #visible?
Constructor Details
#initialize(x, y, radius, options = {}) ⇒ CircleParticle
Returns a new instance of CircleParticle.
8 9 10 11 12 |
# File 'lib/pongo/circle_particle.rb', line 8 def initialize(x, y, radius, ={}) = {:fixed => false, :mass => 1, :elasticity => 0.3, :friction => 0}.update() super(x, y, [:fixed], [:mass], [:elasticity], [:friction]) @radius = radius end |
Instance Attribute Details
#radius ⇒ Object
Returns the value of attribute radius.
6 7 8 |
# File 'lib/pongo/circle_particle.rb', line 6 def radius @radius end |
Instance Method Details
#interval_x ⇒ Object Also known as: get_interval_x
22 23 24 25 26 |
# File 'lib/pongo/circle_particle.rb', line 22 def interval_x @interval.min = @samp.x - @radius @interval.max = @samp.x + @radius @interval end |
#interval_y ⇒ Object Also known as: get_interval_y
29 30 31 32 33 |
# File 'lib/pongo/circle_particle.rb', line 29 def interval_y @interval.min = @samp.y - @radius @interval.max = @samp.y + @radius @interval end |
#projection(axis) ⇒ Object Also known as: get_projection
14 15 16 17 18 19 |
# File 'lib/pongo/circle_particle.rb', line 14 def projection(axis) c = @samp.dot(axis) @interval.min = c - @radius @interval.max = c + @radius @interval end |