Class: Entity::Pellet
- Inherits:
-
OwnedEntity
- Object
- Entity
- OwnedEntity
- Entity::Pellet
- Defined in:
- lib/game_2d/entity/pellet.rb
Constant Summary
Constants included from EntityConstants
EntityConstants::CELL_WIDTH_IN_PIXELS, EntityConstants::MAX_VELOCITY, EntityConstants::PIXEL_WIDTH, EntityConstants::WIDTH
Instance Attribute Summary
Attributes inherited from OwnedEntity
Attributes inherited from Entity
#a, #moving, #space, #x, #x_vel, #y, #y_vel
Instance Method Summary collapse
- #i_hit(others) ⇒ Object
- #image_filename ⇒ Object
- #should_fall? ⇒ Boolean
- #sleep_now? ⇒ Boolean
-
#transparent_to_me?(other) ⇒ Boolean
Pellets don’t hit the originating player, or other pellets fired by the same player.
Methods inherited from OwnedEntity
#all_state, #as_json, #owner, #owner=, #update_from_json
Methods inherited from Entity
#accelerate, #all_state, #angle_to_vector, #as_json, #bottom_cell_y, bottom_cell_y_at, #destroy!, #direction_to, #doomed?, #draw, #draw_zorder, #drop_diagonal, #empty_above?, #empty_on_left?, #empty_on_right?, #empty_underneath?, #entities_obstructing, #going_past_entity, #harmed_by, #initialize, #left_cell_x, left_cell_x_at, #move, #move_x, #move_y, #moving?, #next_to, #occupied_cells, #opaque, #pixel_x, #pixel_y, #right_cell_x, right_cell_x_at, #to_s, #top_cell_y, top_cell_y_at, #update, #update_from_json, #vector_to_angle, #wake!, #warp
Methods included from Registerable
#nullsafe_registry_id, #registry_id, #registry_id=, #registry_id?, #registry_id_safe
Methods included from Serializable
#<=>, #==, #all_state, as_json, #eql?, from_json, #hash, #to_json, #to_s, #update_from_json
Constructor Details
This class inherits a constructor from Entity
Instance Method Details
#i_hit(others) ⇒ Object
18 19 20 21 22 |
# File 'lib/game_2d/entity/pellet.rb', line 18 def i_hit(others) puts "#{self}: hit #{others.inspect}. That's all for me." others.each {|other| other.harmed_by(self)} @space.doom(self) end |
#image_filename ⇒ Object
24 |
# File 'lib/game_2d/entity/pellet.rb', line 24 def image_filename; "pellet.png" end |
#should_fall? ⇒ Boolean
7 |
# File 'lib/game_2d/entity/pellet.rb', line 7 def should_fall?; true end |
#sleep_now? ⇒ Boolean
8 |
# File 'lib/game_2d/entity/pellet.rb', line 8 def sleep_now?; false end |
#transparent_to_me?(other) ⇒ Boolean
Pellets don’t hit the originating player, or other pellets fired by the same player
12 13 14 15 16 |
# File 'lib/game_2d/entity/pellet.rb', line 12 def transparent_to_me?(other) super || other.registry_id == self.owner_id || ((other.is_a?(Pellet) || other.is_a?(Block)) && other.owner_id == self.owner_id) end |