Click here to Skip to main content
15,886,110 members
Articles / Programming Languages / C

Another Star Trek Game (The Retro One)

Rate me:
Please Sign up or sign in to vote.
5.00/5 (14 votes)
27 Aug 2008CPOL6 min read 54.5K   2.2K   32  
The Star Trek game reworked, using a 2D retro look
#include "StdAfx.h"
#include "Torpedo.h"
#include "KlingonShip.h"
#include "Explosion.h"
#include "game.h"

Torpedo::Torpedo(IVessel* pVessel)
{ 
  m_pVessel = pVessel;
  m_clrTemplate = SColor(0, 255, 64, 0);
  m_infTemplate.Alpha = 0;
  m_infTemplate.Fade = 100;

  m_uTimeStep = 800;
  m_bStar     = false;
  m_bExploded = false;

  m_strData   = L"T";
}

Torpedo::~Torpedo(void)
{
}

void Torpedo::updateInfo(Info& rInfo)
{
  if(rInfo.Alpha == 0)
  {
    rInfo.Alpha = 255;
  }
  else
  {
    if(rInfo.Alpha >= 0)
    {
      rInfo.Alpha -= rInfo.Fade;
    }
  }
}

void Torpedo::draw(u32 uTime)
{
  Animator::draw(uTime);

  if(m_iIndex == m_infTraject.size() &&
     m_bExploded == false &&
     m_pVessel != NULL)
  {
    m_bExploded = true;

    Explosion* pExplode = new Explosion(m_infTraject[m_iIndex - 1].Coor);

    pExplode->setFont(m_pFont);
    pExplode->setTime(m_uTime);

    //  add to act
    Act* pAct = Game::getInstance()->getDirector()->getCurrentAct();
    if(pAct)
    {
      pAct->addAnimator(pExplode);
    }
  }
}

void Torpedo::setObstacle(bool bStar)
{
  m_bStar = bStar;
}

void Torpedo::endAnimator()
{
  if(m_pVessel)
  {
    m_pVessel->hitTorpedo();
  }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
Belgium Belgium
I'm from Belgium, happily (should my wife ever read this) married and have two boys.

After a first attempt on the Atari during college in
an old foreign dialect of basic, via Pascal I am now
developing mostly in VC++ / VB / C#.

Comments and Discussions