|
|
@ -218,6 +218,11 @@ bool Enemy::Update(float fElapsedTime) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
if (fElapsedTime > 3/120.f) { |
|
|
|
|
|
|
|
mesh.tris.clear(); |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
@ -260,7 +265,7 @@ void FaceBall::InitializeEnemyData() { |
|
|
|
enemyData[SHOOTME2] = { "SHOOTME2",enemy_ShootMe2,YELLOW,1,1,PI / 6,2,1,0.35f,true }; |
|
|
|
enemyData[SHOOTME2] = { "SHOOTME2",enemy_ShootMe2,YELLOW,1,1,PI / 6,2,1,0.35f,true }; |
|
|
|
enemyData[ISHOOT] = { "ISHOOT",enemy_IShoot,YELLOW,1,1,0.5,2,3,0.4f,true }; |
|
|
|
enemyData[ISHOOT] = { "ISHOOT",enemy_IShoot,YELLOW,1,1,0.5,2,3,0.4f,true }; |
|
|
|
enemyData[SHOOTME_ARMOR] = { "SHOOTME",enemy_ShootMe,YELLOW,6,1,0.5,2,1,0.3f,true,PowerupType::ARMOR,true }; |
|
|
|
enemyData[SHOOTME_ARMOR] = { "SHOOTME",enemy_ShootMe,YELLOW,6,1,0.5,2,1,0.3f,true,PowerupType::ARMOR,true }; |
|
|
|
enemyData[ISHOOT_MAP] = { "ISHOOT",enemy_IShoot,YELLOW,7,1,0.5,2,2,0.3f,true,PowerupType::STOP,true }; |
|
|
|
enemyData[ISHOOT_MAP] = { "ISHOOT",enemy_IShoot,YELLOW,7,1,0.5,2,2,0.3f,true,PowerupType::MAP,true }; |
|
|
|
enemyData[SONAR] = { "Sonar",enemy_Sonar,RED,5,1,PI / 8,2,1 }; |
|
|
|
enemyData[SONAR] = { "Sonar",enemy_Sonar,RED,5,1,PI / 8,2,1 }; |
|
|
|
enemyData[COIN] = { "Coin",undefined,BLUE }; |
|
|
|
enemyData[COIN] = { "Coin",undefined,BLUE }; |
|
|
|
enemyData[POWERUP_ARMOR] = { "Armor",undefined,{96,0,96} }; |
|
|
|
enemyData[POWERUP_ARMOR] = { "Armor",undefined,{96,0,96} }; |
|
|
@ -2017,7 +2022,12 @@ void FaceBall::RenderHud(float fElapsedTime) { |
|
|
|
for (int x = -1; x <= 1; x++) { |
|
|
|
for (int x = -1; x <= 1; x++) { |
|
|
|
for (int y = -1; y <= 1; y++) { |
|
|
|
for (int y = -1; y <= 1; y++) { |
|
|
|
if (x != 0 && y != 0) { |
|
|
|
if (x != 0 && y != 0) { |
|
|
|
DrawStringDecal(vf2d{ hudOffset + float(ScreenWidth() / 2 - GetTextSize(hudDisplayText).x / 2 * 4) + 32,float(ScreenHeight() - 128 - GetTextSize(hudDisplayText).y * 4) + 18 } + vf2d{ float(x),float(y) }, hudDisplayText, DARK_BLUE, { 4,4 }); |
|
|
|
if (lookingAtText != "") { |
|
|
|
|
|
|
|
DrawStringDecal(vf2d{ hudOffset + float(ScreenWidth() / 2 - GetTextSize(lookingAtText).x / 2 * 4) + 32,float(ScreenHeight() - 128 - GetTextSize(lookingAtText).y * 4) + 18 } + vf2d{ float(x),float(y) }, lookingAtText, DARK_BLUE, { 4,4 }); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
DrawStringDecal(vf2d{ hudOffset + float(ScreenWidth() / 2 - GetTextSize(hudDisplayText).x / 2 * 4) + 32,float(ScreenHeight() - 128 - GetTextSize(hudDisplayText).y * 4) + 18 } + vf2d{ float(x),float(y) }, hudDisplayText, DARK_BLUE, { 4,4 }); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -2029,7 +2039,12 @@ void FaceBall::RenderHud(float fElapsedTime) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
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 }); |
|
|
|
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 }); |
|
|
|
if (lookingAtText != "") { |
|
|
|
|
|
|
|
DrawStringDecal(vf2d{ hudOffset + float(ScreenWidth() / 2 - GetTextSize(lookingAtText).x / 2 * 4) + 32,float(ScreenHeight() - 128 - GetTextSize(lookingAtText).y * 4) + 18 }, lookingAtText, { 192,192,255 }, { 4,4 }); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
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({float(ScreenWidth()-128),24},std::to_string(wave2Enemies.size())); |
|
|
|
DrawStringDecal({float(ScreenWidth()-128),24},std::to_string(wave2Enemies.size())); |
|
|
|
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}); |
|
|
@ -2229,7 +2244,7 @@ bool FaceBall::PlayerHasMapUpgrade(){ |
|
|
|
|
|
|
|
|
|
|
|
bool FaceBall::OnUserUpdate(float fElapsedTime) |
|
|
|
bool FaceBall::OnUserUpdate(float fElapsedTime) |
|
|
|
{ |
|
|
|
{ |
|
|
|
fElapsedTime = std::min(0.01667f, fElapsedTime); |
|
|
|
fElapsedTime = std::min(2/60.f, fElapsedTime); |
|
|
|
gameTimer += fElapsedTime; |
|
|
|
gameTimer += fElapsedTime; |
|
|
|
switch (mode) { |
|
|
|
switch (mode) { |
|
|
|
case GAME: { |
|
|
|
case GAME: { |
|
|
@ -2296,14 +2311,21 @@ bool FaceBall::OnUserUpdate(float fElapsedTime) |
|
|
|
it++; |
|
|
|
it++; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
for (int i = 0; i < enemies.size(); i++) { |
|
|
|
int counter = 0; |
|
|
|
Enemy& e = enemies[i]; |
|
|
|
for (std::vector<Enemy>::iterator it = enemies.begin(); it != enemies.end();) { |
|
|
|
e.Update(fElapsedTime); |
|
|
|
Enemy& e = *it; |
|
|
|
if (e.isLastHitTimerActive()) { |
|
|
|
if (!e.Update(fElapsedTime)) { |
|
|
|
e.reduceLastHitTimer(fElapsedTime); |
|
|
|
it = enemies.erase(it); |
|
|
|
} |
|
|
|
} |
|
|
|
if (stopDuration < 0) { |
|
|
|
else { |
|
|
|
RunEnemyAI(e, fElapsedTime, i); |
|
|
|
if (e.isLastHitTimerActive()) { |
|
|
|
|
|
|
|
e.reduceLastHitTimer(fElapsedTime); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (stopDuration < 0) { |
|
|
|
|
|
|
|
RunEnemyAI(e, fElapsedTime, counter); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
it++; |
|
|
|
|
|
|
|
counter++; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
for (std::vector<Powerup>::iterator it = powerups.begin(); it != powerups.end();) { |
|
|
|
for (std::vector<Powerup>::iterator it = powerups.begin(); it != powerups.end();) { |
|
|
@ -2360,6 +2382,25 @@ bool FaceBall::OnUserUpdate(float fElapsedTime) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (hp > 0) { |
|
|
|
if (hp > 0) { |
|
|
|
|
|
|
|
vf2d checkPos = {player.GetPos().x, player.GetPos().z}; |
|
|
|
|
|
|
|
lookingAtText = ""; |
|
|
|
|
|
|
|
while (true) { |
|
|
|
|
|
|
|
if (checkPos.x<0 || checkPos.y<0 || checkPos.x>MAP_SIZE.x || checkPos.y>MAP_SIZE.y) break; |
|
|
|
|
|
|
|
vf2d checkVec = { std::cosf(fYaw) * 0.1f,std::sinf(fYaw) * 0.1f }; |
|
|
|
|
|
|
|
if (CheckCollision({ checkVec.x,0,checkVec.y }, checkPos, 0.1f)) break; |
|
|
|
|
|
|
|
checkPos.x += checkVec.x; |
|
|
|
|
|
|
|
checkPos.y += checkVec.y; |
|
|
|
|
|
|
|
for (Enemy&e : enemies) { |
|
|
|
|
|
|
|
if (!e.isDead()) { |
|
|
|
|
|
|
|
float dist = std::sqrtf(std::powf(checkPos.x - e.pos.x, 2) + std::powf(checkPos.y - e.pos.z, 2)); |
|
|
|
|
|
|
|
if (dist <= e.radius) { |
|
|
|
|
|
|
|
lookingAtText = enemyData[e.GetID()].name; |
|
|
|
|
|
|
|
goto afterPositionCheck; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
afterPositionCheck: |
|
|
|
HandleKeys(fElapsedTime); |
|
|
|
HandleKeys(fElapsedTime); |
|
|
|
RenderWorld(); |
|
|
|
RenderWorld(); |
|
|
|
} |
|
|
|
} |
|
|
|