|
|
@ -219,7 +219,7 @@ bool Enemy::Update(float fElapsedTime) { |
|
|
|
//Has Camo powerup code so camo masks the player position.
|
|
|
|
//Has Camo powerup code so camo masks the player position.
|
|
|
|
vf2d Enemy::GetPlayerPosition() { |
|
|
|
vf2d Enemy::GetPlayerPosition() { |
|
|
|
if (game->PlayerHasCamo()) { |
|
|
|
if (game->PlayerHasCamo()) { |
|
|
|
return { int(id) % game->MAP_SIZE.x,int(id) % game->MAP_SIZE.y }; |
|
|
|
return { float(int(id) % game->MAP_SIZE.x) + 0.5f,float(int(id) % game->MAP_SIZE.y)+0.5f }; |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
return game->GetPlayerPos(); |
|
|
|
return game->GetPlayerPos(); |
|
|
@ -227,6 +227,8 @@ vf2d Enemy::GetPlayerPosition() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Enemy::OnDeathEvent() { |
|
|
|
void Enemy::OnDeathEvent() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
game->AddScore(game->enemyData[id].health*10); |
|
|
|
game->SubtractTag(); |
|
|
|
game->SubtractTag(); |
|
|
|
if (game->enemyData[id].powerupDrop != PowerupType::NONE) { |
|
|
|
if (game->enemyData[id].powerupDrop != PowerupType::NONE) { |
|
|
|
game->SpawnPowerup(game->enemyData[id].powerupDrop, pos); |
|
|
|
game->SpawnPowerup(game->enemyData[id].powerupDrop, pos); |
|
|
@ -1927,6 +1929,14 @@ void FaceBall::RenderHud(float fElapsedTime) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
for (int x = -1; x <= 1; x++) { |
|
|
|
|
|
|
|
for (int y = -1; y <= 1; y++) { |
|
|
|
|
|
|
|
if (x != 0 && y != 0) { |
|
|
|
|
|
|
|
DrawStringPropDecal(vf2d{ hudOffset + (float)(ScreenWidth() / 2 - GetTextSizeProp(std::to_string(score)).x * 4 / 2) + 32,(float)(36 - GetTextSizeProp(std::to_string(score)).y * 4) + 18 } + hudAdjustment + vf2d{float(x),float(y)}, std::to_string(score), VERY_DARK_RED, {4,4}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
DrawStringPropDecal(vf2d{ hudOffset + (float)(ScreenWidth() / 2 - GetTextSizeProp(std::to_string(score)).x * 4 / 2) + 32,(float)(36 - GetTextSizeProp(std::to_string(score)).y * 4) + 18 } + hudAdjustment, std::to_string(score), { 192,96,96 }, { 4,4 }); |
|
|
|
DrawStringDecal(vf2d{ hudOffset + float(ScreenWidth() / 2 - GetTextSize(hudDisplayText).x / 2 * 4) + 32,float(ScreenHeight() - 128 - GetTextSize(hudDisplayText).y * 4) + 18 }, hudDisplayText, { 192,192,255 }, { 4,4 }); |
|
|
|
DrawStringDecal(vf2d{ hudOffset + float(ScreenWidth() / 2 - GetTextSize(hudDisplayText).x / 2 * 4) + 32,float(ScreenHeight() - 128 - GetTextSize(hudDisplayText).y * 4) + 18 }, hudDisplayText, { 192,192,255 }, { 4,4 }); |
|
|
|
SetDecalMode(DecalMode::ADDITIVE); |
|
|
|
SetDecalMode(DecalMode::ADDITIVE); |
|
|
|
DrawDecal({ float(ScreenWidth() / 2 - crosshair->sprite->width / 2),float(ScreenHeight() / 2 - crosshair->sprite->height / 2) }, crosshair, { 1,1 }, {255,255,255,128}); |
|
|
|
DrawDecal({ float(ScreenWidth() / 2 - crosshair->sprite->width / 2),float(ScreenHeight() / 2 - crosshair->sprite->height / 2) }, crosshair, { 1,1 }, {255,255,255,128}); |
|
|
@ -2176,7 +2186,7 @@ bool FaceBall::OnUserUpdate(float fElapsedTime) |
|
|
|
hasMapUpgrade = true; |
|
|
|
hasMapUpgrade = true; |
|
|
|
}break; |
|
|
|
}break; |
|
|
|
case PowerupType::COIN: { |
|
|
|
case PowerupType::COIN: { |
|
|
|
score += 1000; |
|
|
|
AddScore(1000); |
|
|
|
}break; |
|
|
|
}break; |
|
|
|
} |
|
|
|
} |
|
|
|
powerups.erase(powerups.begin() + lastPowerupCollidedWith); |
|
|
|
powerups.erase(powerups.begin() + lastPowerupCollidedWith); |
|
|
@ -2238,6 +2248,20 @@ void FaceBall::OnTextEntryComplete(const std::string& sText) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//This function adds to the game score and increments lives appropriately.
|
|
|
|
|
|
|
|
void FaceBall::AddScore(int score) { |
|
|
|
|
|
|
|
this->score += score; |
|
|
|
|
|
|
|
if (lastAwardedScore/10000 != this->score/10000) { |
|
|
|
|
|
|
|
lives++; |
|
|
|
|
|
|
|
lastAwardedScore = this->score; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void FaceBall::ResetScore() { |
|
|
|
|
|
|
|
score = 0; |
|
|
|
|
|
|
|
lastAwardedScore = 0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int main() |
|
|
|
int main() |
|
|
|
{ |
|
|
|
{ |
|
|
|
FaceBall demo; |
|
|
|
FaceBall demo; |
|
|
|