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

  1. //-------------------------------------------------------------
  2. //
  3. // Class:    CWingtip
  4. //
  5. // Author:    John M Phillips
  6. //
  7. // Started:    06/05/00
  8. //
  9. // Base:    CUpgrade
  10. //
  11. // Derived:    None
  12. //
  13. //-------------------------------------------------------------
  14.  
  15. #include "game.h"
  16.  
  17. //-------------------------------------------------------------
  18.  
  19. CWingtip::CWingtip()
  20. {
  21. }
  22.  
  23. //-------------------------------------------------------------
  24.  
  25. CWingtip::~CWingtip()
  26. {
  27. //    CActor::~CActor();
  28. }
  29.  
  30. //-------------------------------------------------------------
  31.  
  32. bool CWingtip::activate()
  33. {
  34.     if (!isActive()) {
  35.         m_timer.start();
  36.         }
  37.  
  38.     return CUpgrade::activate();
  39. }
  40.  
  41. //-------------------------------------------------------------
  42.  
  43. bool CWingtip::update(Controls *controls)
  44. {
  45.     CShip *ship = (CShip *) getOwner();
  46.  
  47.     if (!ship) {
  48.         kill();
  49.         return true;
  50.         }
  51.  
  52.     if (getShield() == 0) {
  53.         ship->detachWingtip(this);
  54.         setOwner(0);
  55.         explode();
  56.         kill();
  57.         return true;
  58.         }
  59.  
  60.     int d = ship->getDiveLevel();
  61.  
  62.     if (d == 0) {
  63.         m_position = ship->getPosition() + m_offset;
  64.         if (ship->isCloaked()) {
  65.             if (!ship->isCloakFlashing())
  66.                 m_sprite.setFrame(WINGTIP_CLOAK_FRAME);
  67.             else
  68.                 m_sprite.setFrame(0);
  69.             }
  70.         else
  71.             animate(ANIMATE_LOOP,0,WINGTIP_FRAMES);
  72.         }
  73.     else {
  74.         m_position = ship->getPosition() + m_offset * ship->getDiveScale();
  75.         m_sprite.setFrame(WINGTIP_DIVE_OFFSET + WINGTIP_DIVE_FRAMES * d / SHIP_DIVE_FRAMES);
  76.         }
  77.  
  78.     return true;
  79. }
  80.  
  81. //-------------------------------------------------------------
  82.  
  83.