|
|
|
@ -140,8 +140,10 @@ void FaceBall::LoadLevel(int level) |
|
|
|
|
exitCoords = { x,y }; |
|
|
|
|
} |
|
|
|
|
if (id == START) { |
|
|
|
|
player.UpdatePos({ x+0.5f,0.3,y+0.5f }); |
|
|
|
|
fYaw = (int(mapData[y][x].facingDir) - 1) * PI / 2; |
|
|
|
|
spawnLoc = { x + 0.5f,0.3,y + 0.5f }; |
|
|
|
|
player.UpdatePos(spawnLoc); |
|
|
|
|
spawnFacingDir = mapData[y][x].facingDir; |
|
|
|
|
fYaw = (int(spawnFacingDir) - 1) * PI / 2; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
map.push_back(row); |
|
|
|
@ -1181,7 +1183,7 @@ bool Bullet::Update(float fElapsedTime) { |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
if (FaceBall::CheckPlayerCollision(adjustedSpd,{pos.x,pos.z},0.1)) { |
|
|
|
|
game->HurtPlayer(shooterID,shooterBlinking); |
|
|
|
|
game->HurtPlayer(shooterID,1,shooterBlinking); |
|
|
|
|
return false; |
|
|
|
|
} else |
|
|
|
|
{ |
|
|
|
@ -1203,8 +1205,11 @@ bool Bullet::Update(float fElapsedTime) { |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void FaceBall::HurtPlayer(EnemyID id,bool blinking) { |
|
|
|
|
hp = std::max(0, hp - 1); |
|
|
|
|
void FaceBall::HurtPlayer(EnemyID id,int damage,bool blinking) { |
|
|
|
|
hp = std::max(0, hp - damage); |
|
|
|
|
if (hp <= 0) { |
|
|
|
|
respawnTimer = 3.0f; |
|
|
|
|
} |
|
|
|
|
lastHitBy = id; |
|
|
|
|
lastHitByBlinking = blinking; |
|
|
|
|
} |
|
|
|
@ -1246,9 +1251,6 @@ void FaceBall::RenderHud(float fElapsedTime) { |
|
|
|
|
RenderMeshDeathScreen(matView, vecTrianglesToRaster, o); |
|
|
|
|
|
|
|
|
|
//std::sort(vecTrianglesToRaster.begin(),vecTrianglesToRaster.end(),[](triangle&t1,triangle&t2){return (t1.p[0].z+t1.p[1].z+t1.p[2].z)/3.0f>(t2.p[0].z+t2.p[1].z+t2.p[2].z)/3.0f;});
|
|
|
|
|
if (vecTrianglesToRaster.size() > 0) { |
|
|
|
|
std::cout << vecTrianglesToRaster[0].p[0] << std::endl; |
|
|
|
|
} |
|
|
|
|
triRenderCount = 0; |
|
|
|
|
for (auto& triToRaster : vecTrianglesToRaster) { |
|
|
|
|
Triangle clipped[2]; |
|
|
|
@ -1509,6 +1511,20 @@ bool FaceBall::OnUserUpdate(float fElapsedTime) |
|
|
|
|
case GAME: { |
|
|
|
|
HandleKeys(fElapsedTime); |
|
|
|
|
if (hp > 0) { RenderWorld(); } |
|
|
|
|
else { |
|
|
|
|
respawnTimer -= fElapsedTime; |
|
|
|
|
if (respawnTimer <= 0.0f) { |
|
|
|
|
lives--; |
|
|
|
|
if (lives > 0) { |
|
|
|
|
hp = maxHP; |
|
|
|
|
player.UpdatePos(spawnLoc); |
|
|
|
|
fYaw = (int(spawnFacingDir) - 1) * PI / 2; |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
//TODO Game over.
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
RenderHud(fElapsedTime); |
|
|
|
|
}break; |
|
|
|
|
case EDITOR: { |
|
|
|
|