Class: Enemy

Inherits:
Chingu::GameObject
  • Object
show all
Defined in:
lib/prkwars/enemy.rb

Overview

A generic Enemy class inheriting from Chingu::Gameobject. Any enemy unit inherits from this class. The class contains a method which returns all the descendants - useful for checking all possible collisions.

Direct Known Subclasses

Stalker, Turret

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#hpObject

Returns the value of attribute hp.



8
9
10
# File 'lib/prkwars/enemy.rb', line 8

def hp
  @hp
end

Class Method Details

.descendantsObject



13
14
15
# File 'lib/prkwars/enemy.rb', line 13

def self.descendants
  ObjectSpace.each_object(::Class).select { |klass| klass < self }
end