Class: Pugnacious::Molecule
- Inherits:
-
Object
- Object
- Pugnacious::Molecule
- Includes:
- Movable
- Defined in:
- lib/pugnacious/molecule.rb
Constant Summary collapse
- MAX_LIFE =
30
Constants included from Movable
Pugnacious::Movable::DIRECTIONS
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#game_map ⇒ Object
Returns the value of attribute game_map.
-
#life ⇒ Object
Returns the value of attribute life.
-
#molecules ⇒ Object
Returns the value of attribute molecules.
-
#player ⇒ Object
Returns the value of attribute player.
-
#pointer ⇒ Object
Returns the value of attribute pointer.
-
#position ⇒ Object
Returns the value of attribute position.
-
#rival ⇒ Object
Returns the value of attribute rival.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Molecule
constructor
A new instance of Molecule.
- #receive_damage ⇒ Object
Methods included from Movable
#check_tile, #fight, #here, #move, #move!, #pointer_at_east, #pointer_at_north, #pointer_at_north_east, #pointer_at_north_west, #pointer_at_south, #pointer_at_south_east, #pointer_at_south_west, #pointer_at_west, #pointer_direction, #posible_directions
Constructor Details
#initialize(options = {}) ⇒ Molecule
Returns a new instance of Molecule.
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/pugnacious/molecule.rb', line 9 def initialize( = {}) @player = [:player] @game_map = [:map] @position = [:pos] @game_map[@position[0]][@position[1]] = self @body = Ray::Polygon.rectangle([0, 0, MOLECULE_SIZE, MOLECULE_SIZE], Ray::Color.new(100, 100, 0) + @player.color) @body.pos = [@position[0] * MOLECULE_SIZE, @position[1] * MOLECULE_SIZE] || [0, 0] @molecules = [:molecules] @pointer = @player.pointer @life = MAX_LIFE @rival = [:rival] end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
5 6 7 |
# File 'lib/pugnacious/molecule.rb', line 5 def body @body end |
#game_map ⇒ Object
Returns the value of attribute game_map.
5 6 7 |
# File 'lib/pugnacious/molecule.rb', line 5 def game_map @game_map end |
#life ⇒ Object
Returns the value of attribute life.
5 6 7 |
# File 'lib/pugnacious/molecule.rb', line 5 def life @life end |
#molecules ⇒ Object
Returns the value of attribute molecules.
5 6 7 |
# File 'lib/pugnacious/molecule.rb', line 5 def molecules @molecules end |
#player ⇒ Object
Returns the value of attribute player.
5 6 7 |
# File 'lib/pugnacious/molecule.rb', line 5 def player @player end |
#pointer ⇒ Object
Returns the value of attribute pointer.
5 6 7 |
# File 'lib/pugnacious/molecule.rb', line 5 def pointer @pointer end |
#position ⇒ Object
Returns the value of attribute position.
5 6 7 |
# File 'lib/pugnacious/molecule.rb', line 5 def position @position end |
#rival ⇒ Object
Returns the value of attribute rival.
5 6 7 |
# File 'lib/pugnacious/molecule.rb', line 5 def rival @rival end |
Instance Method Details
#receive_damage ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/pugnacious/molecule.rb', line 23 def receive_damage() @life -=3 if @life <= 0 @rival, @player = @player, @rival @body.color = Ray::Color.new(100, 100, 0) + @player.color @life = MAX_LIFE @pointer = @player.pointer end end |