Game dev, Suit’em up – Milestone, playable game

The game is playable. It is a very simple version without almost all collision since that is not implemented yet. All code that makes the game playable is located within the engine but it will be broken up into the different states and managers as they start getting added.

I made a temporary collision code, as it was needed for collision between projectiles and enemies. It looks like this:

fDistanceX = fabs(m_xEnemies[k]->GetPos().x – m_xProjectiles[i]->GetPos().x);
fDistanceY = fabs(m_xEnemies[k]->GetPos().y – m_xProjectiles[i]->GetPos().y);
fDistanceTotal = sqrtf(fDistanceX*fDistanceX + fDistanceY*fDistanceY);
if(fDistanceTotal < 50.0f)

It simply checks for enemies closer than 50.0f and then removes both the enemy and projectile upon collision. Like this:

if(!m_xProjectiles.empty() && !m_xEnemies.empty())
{
for(unsigned int i=m_xProjectiles.size()-1; i>=0; i–)
{
if(m_xProjectiles[i]->GetPlayerControlled())
{
if(m_xProjectiles.empty() || m_xEnemies.empty())
{ break; }
//collisions with player projectiles and enemies
for(unsigned int k=m_xEnemies.size()-1; k>=0; k–)
{
if(m_xProjectiles.empty() || m_xEnemies.empty())
{ break; }
fDistanceX = fabs(m_xEnemies[k]->GetPos().x – m_xProjectiles[i]->GetPos().x);
fDistanceY = fabs(m_xEnemies[k]->GetPos().y – m_xProjectiles[i]->GetPos().y);
fDistanceTotal = sqrtf(fDistanceX*fDistanceX + fDistanceY*fDistanceY);
if(fDistanceTotal < 50.0f)
{
m_xEnemies.erase(m_xEnemies.begin()+k);
m_xProjectiles.erase(m_xProjectiles.begin()+i);
//Loop over it backwards instead of forward, might prevent crash
}
if(m_xProjectiles.empty() || m_xEnemies.empty() || k == 0)
{ break; }
}
if(m_xProjectiles.empty() || m_xEnemies.empty() || i == 0)
{ break; }
}
}
}

I have a lot of safeguards for when the vectors are empty which can be removed.

There exists two bosses with placeholder sprites right now. When they are killed the final boss, also with a placeholder, is spawned. When the final boss is killed the game is won. This is currently only conveyed in the console window.

In each update of the game it checks for dead bosses, like so:

if(m_xEnemies[k]->GetEnemyType() == “Boss1”)
{ m_bBoss1Alive = false; }
else if(m_xEnemies[k]->GetEnemyType() == “Boss2”)
{ m_bBoss2Alive = false; }
else if(m_xEnemies[k]->GetEnemyType() == “FinalBoss”)
{ std::cout << “Win!” << std::endl; }

if(m_bBoss1Alive == false
&& m_bBoss2Alive == false
&& m_bSpawnFinalBoss == true)
{
std::cout << “Spawning final boss.” << std::endl;
m_bSpawnFinalBoss = false;

Image

Here are some ingame screenshots of the game.

Image

Image

Image

This entry was posted in 5SD023, 5SD033 and tagged , , . Bookmark the permalink.

1 Response to Game dev, Suit’em up – Milestone, playable game

  1. lyrtzz says:

    Great work. keep it up!

Leave a comment