Archived

This topic is now archived and is closed to further replies.

Alien wave pattern - how to?

This topic is 5024 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

How do I create alien wave attack patterns for a vertical scrolling shoot ''em up? How does one go about creating structures for such patterns and associate them with different sprites? "There is no dark side of the moon." - Pink Floyd

Share this post


Link to post
Share on other sites
That's not too difficult, you just have to make all the little steps.

For the wave pattern concentrate on one alien for now, having a movement path. Let the path be several frames, with each frame being a relative movement in a specific direction.

For example:


struct tPathFrame
{
vector2 m_vDistance;
float m_fFrameLength;
};

typedef std::vector tMovementPath;


Now you can store any predefined paths in an array or vector or a list. Give every alien an ID to the path entry. Every alien also needs an Update with the elapes time.

For example:


class CAlien
{
public:

vector2 m_vecPos;

int m_iPathID;
int m_iCurrentPathFrame;
float m_fCurrentFramePos;

CAlien() :
m_iPathID( 0 ),
m_iCurrentPathFrame( 0 ),
m_fCurrentFramePos( 0.0f )
{
}

void Update( float fElapsedTime )
{
tMovementPath& MyPath = .....

while ( fElapsedTime > 0.0f )
{
// retrieve current Path Frame

tPathFrame& Frame = MyPath[m_iCurrentPathFrame];

if ( fElapsedTime >= Frame.m_fFrameLength - fCurrentFramePos )
{
// move to Frame end position

m_vecPos += ( Frame.m_fFrameLength - fCurrentFramePos ) / Frame.m_fFrameLength * Frame.m_vDistance;

// this Frame is done

fCurrentFramePos = 0.0f;
m_iCurrentPathFrame++;
if ( m_iCurrentPathFrame >= MyPath.size() )
{
// reached the end, loop

m_iCurrentPathFrame = 0;
}

// adjust remaining time

fElapsedTime -= Frame.m_fFrameLength - fCurrentFramePos;
}
else
{
// move

m_vecPos += fElapsedTime / Frame.m_fFrameLength * Frame.m_vDistance;

fCurrentFramePos += fElapsedTime;
fElapsedTime = 0.0f;
}
}

}
};



This is pseudo code out of my head, it misses safety checks and maybe got an error or two, but should show the general direction.

[edited by - Endurion on April 15, 2004 3:33:44 AM]

[edited by - Endurion on April 15, 2004 3:34:30 AM]

Share this post


Link to post
Share on other sites
Yep, that''s how I''d do it. I''d also use bool arrays to define the initial formations of the alien ships, and then just assign them paths, as Endurion said.

Share this post


Link to post
Share on other sites
Cool. That''s pretty much what I had figured. Thanks for the help!

"There is no dark side of the moon." - Pink Floyd

Share this post


Link to post
Share on other sites