Respawn timer integrated.
This commit is contained in:
parent
926ee37651
commit
b4c42e4fd3
@ -140,8 +140,10 @@ void FaceBall::LoadLevel(int level)
|
|||||||
exitCoords = { x,y };
|
exitCoords = { x,y };
|
||||||
}
|
}
|
||||||
if (id == START) {
|
if (id == START) {
|
||||||
player.UpdatePos({ x+0.5f,0.3,y+0.5f });
|
spawnLoc = { x + 0.5f,0.3,y + 0.5f };
|
||||||
fYaw = (int(mapData[y][x].facingDir) - 1) * PI / 2;
|
player.UpdatePos(spawnLoc);
|
||||||
|
spawnFacingDir = mapData[y][x].facingDir;
|
||||||
|
fYaw = (int(spawnFacingDir) - 1) * PI / 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
map.push_back(row);
|
map.push_back(row);
|
||||||
@ -1181,7 +1183,7 @@ bool Bullet::Update(float fElapsedTime) {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (FaceBall::CheckPlayerCollision(adjustedSpd,{pos.x,pos.z},0.1)) {
|
if (FaceBall::CheckPlayerCollision(adjustedSpd,{pos.x,pos.z},0.1)) {
|
||||||
game->HurtPlayer(shooterID,shooterBlinking);
|
game->HurtPlayer(shooterID,1,shooterBlinking);
|
||||||
return false;
|
return false;
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
@ -1203,8 +1205,11 @@ bool Bullet::Update(float fElapsedTime) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FaceBall::HurtPlayer(EnemyID id,bool blinking) {
|
void FaceBall::HurtPlayer(EnemyID id,int damage,bool blinking) {
|
||||||
hp = std::max(0, hp - 1);
|
hp = std::max(0, hp - damage);
|
||||||
|
if (hp <= 0) {
|
||||||
|
respawnTimer = 3.0f;
|
||||||
|
}
|
||||||
lastHitBy = id;
|
lastHitBy = id;
|
||||||
lastHitByBlinking = blinking;
|
lastHitByBlinking = blinking;
|
||||||
}
|
}
|
||||||
@ -1246,9 +1251,6 @@ void FaceBall::RenderHud(float fElapsedTime) {
|
|||||||
RenderMeshDeathScreen(matView, vecTrianglesToRaster, o);
|
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;});
|
//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;
|
triRenderCount = 0;
|
||||||
for (auto& triToRaster : vecTrianglesToRaster) {
|
for (auto& triToRaster : vecTrianglesToRaster) {
|
||||||
Triangle clipped[2];
|
Triangle clipped[2];
|
||||||
@ -1509,6 +1511,20 @@ bool FaceBall::OnUserUpdate(float fElapsedTime)
|
|||||||
case GAME: {
|
case GAME: {
|
||||||
HandleKeys(fElapsedTime);
|
HandleKeys(fElapsedTime);
|
||||||
if (hp > 0) { RenderWorld(); }
|
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);
|
RenderHud(fElapsedTime);
|
||||||
}break;
|
}break;
|
||||||
case EDITOR: {
|
case EDITOR: {
|
||||||
|
@ -266,6 +266,9 @@ class FaceBall : public PixelGameEngine
|
|||||||
float hudOffset = 0;
|
float hudOffset = 0;
|
||||||
float hudOffsetAcc = 0;
|
float hudOffsetAcc = 0;
|
||||||
float screenAlpha = 0;
|
float screenAlpha = 0;
|
||||||
|
float respawnTimer = 0;
|
||||||
|
vec3d spawnLoc = { 0,0.3,0 };
|
||||||
|
FacingDirection spawnFacingDir = FacingDirection::NORTH;
|
||||||
|
|
||||||
EnemyID lastHitBy=EnemyID::NONE;
|
EnemyID lastHitBy=EnemyID::NONE;
|
||||||
bool lastHitByBlinking = false;
|
bool lastHitByBlinking = false;
|
||||||
@ -315,5 +318,5 @@ class FaceBall : public PixelGameEngine
|
|||||||
static int CheckEnemyCollision(vec3d movementVector, vf2d pos, float radius, int ignoreIndex = -1);
|
static int CheckEnemyCollision(vec3d movementVector, vf2d pos, float radius, int ignoreIndex = -1);
|
||||||
static bool CheckPlayerCollision(vec3d movementVector, vf2d pos, float radius);
|
static bool CheckPlayerCollision(vec3d movementVector, vf2d pos, float radius);
|
||||||
void SubtractTag();
|
void SubtractTag();
|
||||||
void HurtPlayer(EnemyID id, bool blinking = false);
|
void HurtPlayer(EnemyID id, int damage=1,bool blinking = false);
|
||||||
};
|
};
|
Loading…
x
Reference in New Issue
Block a user