Class: Enemy
- Inherits:
-
Chingu::GameObject
- Object
- Chingu::GameObject
- Enemy
- 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.
Instance Attribute Summary collapse
-
#hp ⇒ Object
Each enemy has hitpoints, how many has to be specified by the enemy class!.
Class Method Summary collapse
-
.descendants ⇒ Object
Method returning all the descendants of the Enemy class.
Instance Attribute Details
#hp ⇒ Object
Each enemy has hitpoints, how many has to be specified by the enemy class!
12 13 14 |
# File 'lib/prkwars/enemy.rb', line 12 def hp @hp end |
Class Method Details
.descendants ⇒ Object
Method returning all the descendants of the Enemy class. Used for collision checks in the main game loop.
20 21 22 |
# File 'lib/prkwars/enemy.rb', line 20 def self.descendants ObjectSpace.each_object(::Class).select { |klass| klass < self } end |