home *** CD-ROM | disk | FTP | other *** search
/ PC Format (South-Africa) 2001 June / PCFJune.iso / Xenon / XenonSource.exe / xenon / source / bosseye.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2000-09-09  |  1.9 KB  |  100 lines

  1. //-------------------------------------------------------------
  2. //
  3. // Class:    CBossEye
  4. //
  5. // Author:    John M Phillips
  6. //
  7. // Started:    06/05/00
  8. //
  9. // Base:    CAlien
  10. //
  11. // Derived:    None
  12. //
  13. //-------------------------------------------------------------
  14.  
  15. #include "game.h"
  16.  
  17. //-------------------------------------------------------------
  18.  
  19. BossEyeState CBossEye::m_state = BOSSEYE_SHUT;
  20.  
  21. //-------------------------------------------------------------
  22.  
  23. CBossEye::CBossEye()
  24. {
  25.     m_eye_number = 0;
  26.     m_state = BOSSEYE_SHUT;
  27. }
  28.  
  29. //-------------------------------------------------------------
  30.  
  31. CBossEye::~CBossEye()
  32. {
  33. }
  34.  
  35. //-------------------------------------------------------------
  36.  
  37. bool CBossEye::activate()
  38. {
  39.     if (!isActive())
  40.         m_timer.start();
  41.  
  42.     return CActor::activate();
  43. }
  44.  
  45. //-------------------------------------------------------------
  46.  
  47. void CBossEye::kill()
  48. {
  49.     CExplosion *x = new CBigExplosion;
  50.     m_scene->addActor(x);
  51.     x->setPosition(getPosition());
  52.     x->activate();
  53.  
  54.     m_active_eyes--;
  55.  
  56.     CActor::kill();
  57. }
  58.  
  59. //-------------------------------------------------------------
  60.  
  61. void CBossEye::registerHit(int energy,CActor *hitter)
  62. {
  63.     if (m_state == BOSSEYE_OPEN)
  64.         CActor::registerHit(energy,hitter);
  65. }
  66.  
  67. //-------------------------------------------------------------
  68.  
  69. bool CBossEye::update(Controls *controls)
  70. {
  71.     if (m_state != BOSSEYE_OPEN)
  72.         m_is_hit = false;
  73.  
  74.     if (m_shield == 0) {
  75.         explode();
  76.         kill();
  77.         return true;
  78.         }
  79.  
  80.     m_sprite.setFrame(m_eye_number + (int) m_state * BOSSEYE_TOTAL);
  81.  
  82.     return true;
  83. }
  84.  
  85. //-------------------------------------------------------------
  86.  
  87. void CBossEye::setEyeNumber(int eye_number)
  88. {
  89.     m_eye_number = eye_number;
  90. }
  91.  
  92. //-------------------------------------------------------------
  93.  
  94. void CBossEye::setState(BossEyeState state)
  95. {
  96.     m_state = state;
  97. }
  98.  
  99. //-------------------------------------------------------------
  100.