Explosion death gradient overlay.
This commit is contained in:
parent
cf4ed30867
commit
2016053c6e
@ -134,6 +134,7 @@ void FaceBall::LoadLevel(int level)
|
||||
this->level = level;
|
||||
restingTriangleYDepth = 0.f;
|
||||
exitWallsCleared = false;
|
||||
hudShakeTime = 0;
|
||||
std::vector<std::vector<Tile>>mapData = editor.LoadLevel(level);
|
||||
MAP_SIZE = { (int)mapData[0].size(),(int)mapData.size() };
|
||||
map.clear();
|
||||
@ -227,7 +228,7 @@ void FaceBall::LoadLevel(int level)
|
||||
MapWallsObjectIndex = objects.size()-1;
|
||||
objects.push_back({ mapFloor,{0,0,0},0,0 });
|
||||
//objects.push_back({ game->mapExit,{(float)exitCoords.x+0.5f,0,(float)exitCoords.y+0.5f},0,0.4f });
|
||||
exit = { game->mapExit,{(float)exitCoords.x + 0.5f,0,(float)exitCoords.y + 0.5f},0,0.4f };
|
||||
exit = { game->mapExit,{(float)exitCoords.x + 0.5f,0.02f,(float)exitCoords.y + 0.5f},0,0.4f };
|
||||
}
|
||||
|
||||
bool FaceBall::CheckCollision(vec3d movementVector,vf2d pos,float radius){
|
||||
@ -1089,6 +1090,7 @@ void FaceBall::HandleKeys(float fElapsedTime) {
|
||||
e.Hurt(999);
|
||||
e.setExploded(true);
|
||||
HurtPlayer(e.GetID(), 1, e.isBlinking());
|
||||
hudShakeTime = 0.6f;
|
||||
}
|
||||
player.UpdatePos(Vector_Add(player.GetPos(), xMovement));
|
||||
}
|
||||
@ -1100,6 +1102,7 @@ void FaceBall::HandleKeys(float fElapsedTime) {
|
||||
e.Hurt(999);
|
||||
e.setExploded(true);
|
||||
HurtPlayer(e.GetID(), 1, e.isBlinking());
|
||||
hudShakeTime = 0.6f;
|
||||
}
|
||||
player.UpdatePos(Vector_Add(player.GetPos(), zMovement));
|
||||
}
|
||||
@ -1121,6 +1124,7 @@ void FaceBall::HandleKeys(float fElapsedTime) {
|
||||
e.Hurt(999);
|
||||
e.setExploded(true);
|
||||
HurtPlayer(e.GetID(), 1, e.isBlinking());
|
||||
hudShakeTime = 0.6f;
|
||||
}
|
||||
player.UpdatePos(Vector_Add(player.GetPos(), xMovement));
|
||||
}
|
||||
@ -1132,6 +1136,7 @@ void FaceBall::HandleKeys(float fElapsedTime) {
|
||||
e.Hurt(999);
|
||||
e.setExploded(true);
|
||||
HurtPlayer(e.GetID(), 1, e.isBlinking());
|
||||
hudShakeTime = 0.6f;
|
||||
}
|
||||
player.UpdatePos(Vector_Add(player.GetPos(), zMovement));
|
||||
}
|
||||
@ -1150,6 +1155,7 @@ void FaceBall::HandleKeys(float fElapsedTime) {
|
||||
e.Hurt(999);
|
||||
e.setExploded(true);
|
||||
HurtPlayer(e.GetID(), 1, e.isBlinking());
|
||||
hudShakeTime = 0.6f;
|
||||
}
|
||||
player.UpdatePos(Vector_Add(player.GetPos(), xMovement));
|
||||
}
|
||||
@ -1161,6 +1167,7 @@ void FaceBall::HandleKeys(float fElapsedTime) {
|
||||
e.Hurt(999);
|
||||
e.setExploded(true);
|
||||
HurtPlayer(e.GetID(), 1, e.isBlinking());
|
||||
hudShakeTime = 0.6f;
|
||||
}
|
||||
player.UpdatePos(Vector_Add(player.GetPos(), zMovement));
|
||||
}
|
||||
@ -1184,6 +1191,7 @@ void FaceBall::HandleKeys(float fElapsedTime) {
|
||||
e.Hurt(999);
|
||||
e.setExploded(true);
|
||||
HurtPlayer(e.GetID(), 1, e.isBlinking());
|
||||
hudShakeTime = 0.6f;
|
||||
}
|
||||
player.UpdatePos(Vector_Add(player.GetPos(), xMovement));
|
||||
}
|
||||
@ -1195,6 +1203,7 @@ void FaceBall::HandleKeys(float fElapsedTime) {
|
||||
e.Hurt(999);
|
||||
e.setExploded(true);
|
||||
HurtPlayer(e.GetID(), 1, e.isBlinking());
|
||||
hudShakeTime = 0.6f;
|
||||
}
|
||||
player.UpdatePos(Vector_Add(player.GetPos(), zMovement));
|
||||
}
|
||||
@ -1353,6 +1362,7 @@ bool Bullet::Update(float fElapsedTime) {
|
||||
else {
|
||||
if (FaceBall::CheckPlayerCollision(adjustedSpd,{pos.x,pos.z},0.1)) {
|
||||
game->HurtPlayer(shooterID,1,shooterBlinking);
|
||||
game->hudShakeTime = 0.2f;
|
||||
return false;
|
||||
} else
|
||||
{
|
||||
@ -1381,9 +1391,13 @@ void FaceBall::HurtPlayer(EnemyID id,int damage,bool blinking) {
|
||||
}
|
||||
lastHitBy = id;
|
||||
lastHitByBlinking = blinking;
|
||||
screenCol = enemyData[lastHitBy].col;
|
||||
}
|
||||
|
||||
void FaceBall::RenderHud(float fElapsedTime) {
|
||||
if (hudShakeTime > 0) {
|
||||
hudShakeTime -= fElapsedTime;
|
||||
}
|
||||
if (!GetKey(olc::D).bHeld && !GetKey(olc::A).bHeld) {
|
||||
hudOffsetAcc += 20 * fElapsedTime;
|
||||
while (hudOffsetAcc >= 1) {
|
||||
@ -1490,17 +1504,26 @@ void FaceBall::RenderHud(float fElapsedTime) {
|
||||
DrawStringDecal({ float(ScreenWidth() / 2 - GetTextSize(bottomText).x / 2 * 3),float(ScreenHeight() - 140.f) }, bottomText, { 96,96,255 }, { 3,6 });
|
||||
}
|
||||
vf2d hudAdjustment = { -32,-18 };
|
||||
if (hudShakeTime > 0) {
|
||||
hudShakeAmt = std::sinf(40 * hudShakeTime);
|
||||
hudAdjustment.x += hudShakeAmt * 2;
|
||||
hudAdjustment.y += hudShakeAmt * 4;
|
||||
}
|
||||
vf2d hudLoc = { hudAdjustment.x + (hp>0?hudOffset:0),hudAdjustment.y};
|
||||
DrawDecal(hudLoc, hud, { 1.05,1.05 });
|
||||
DrawDecal(hudLoc + vf2d{ 704,56 } - hudAdjustment, life4, { 1,1 }, float(hp) / maxHP > 0.75f ? WHITE : VERY_DARK_GREEN);
|
||||
DrawDecal(hudLoc + vf2d{ 704 - 64,56 } - hudAdjustment, life3, { 1,1 }, float(hp) / maxHP > 0.34f && float(hp) / maxHP <= 0.75f ? WHITE : VERY_DARK_GREEN);
|
||||
DrawDecal(hudLoc + vf2d{ 704 - 128,56 } - hudAdjustment, life2, { 1,1 }, hp > 0 && float(hp) / maxHP <= 0.34f ? WHITE : VERY_DARK_GREEN);
|
||||
DrawDecal(hudLoc + vf2d{ 704 - 192,56 } - hudAdjustment, life1, { 1,1 }, hp <= 0 ? WHITE : VERY_DARK_GREEN);
|
||||
DrawDecal(hudLoc + vf2d{ 704+32,56+18 }, life4, { 1,1 }, float(hp) / maxHP > 0.75f ? WHITE : VERY_DARK_GREEN);
|
||||
DrawDecal(hudLoc + vf2d{ 704 - 64+32,56+18 }, life3, { 1,1 }, float(hp) / maxHP > 0.34f && float(hp) / maxHP <= 0.75f ? WHITE : VERY_DARK_GREEN);
|
||||
DrawDecal(hudLoc + vf2d{ 704 - 128+32,56+18 }, life2, { 1,1 }, hp > 0 && float(hp) / maxHP <= 0.34f ? WHITE : VERY_DARK_GREEN);
|
||||
DrawDecal(hudLoc + vf2d{ 704 - 192+32,56+18 }, life1, { 1,1 }, hp <= 0 ? WHITE : VERY_DARK_GREEN);
|
||||
if (hp > 0) {
|
||||
DrawStringDecal({ 112 + hudOffset,4 }, "Triangles: " + std::to_string(triRenderCount), BLACK, { 2,4 });
|
||||
DrawStringDecal(vf2d{ 112 + hudOffset+32,4+18 }+hudAdjustment, "Triangles: " + std::to_string(triRenderCount), BLACK, { 2,4 });
|
||||
std::string hudText = "Tags Left: " + std::to_string(tagsRemaining) + " Lives: " + std::to_string(lives);
|
||||
DrawStringPropDecal(vf2d{ hudOffset + (float)(ScreenWidth() / 2 - GetTextSizeProp(hudText).x * 3 / 2),(float)(ScreenHeight() - 64 - GetTextSizeProp(hudText).y * 6) }, hudText, WHITE, { 3,6 });
|
||||
DrawStringPropDecal(vf2d{ hudOffset + (float)(ScreenWidth() / 2 - GetTextSizeProp(hudText).x * 3 / 2)+32,(float)(ScreenHeight() - 64 - GetTextSizeProp(hudText).y * 6)+18 } + hudAdjustment, hudText, WHITE, { 3,6 });
|
||||
}
|
||||
GradientFillRectDecal({ 0,0 }, vf2d{ (float)ScreenWidth()/2,(float)ScreenHeight()/2 }, { (uint8_t)screenCol.r,(uint8_t)screenCol.g,(uint8_t)screenCol.b,(uint8_t)(hudShakeTime>0.2f?120:hudShakeTime>0?64:0) }, { (uint8_t)screenCol.r,(uint8_t)screenCol.g,(uint8_t)screenCol.b,(uint8_t)(hudShakeTime>0.2f?120:hudShakeTime>0?64:0) }, { (uint8_t)screenCol.r,(uint8_t)screenCol.g,(uint8_t)screenCol.b,(uint8_t)(hudShakeTime > 0.2f ? 64 : 0) }, { (uint8_t)screenCol.r,(uint8_t)screenCol.g,(uint8_t)screenCol.b,(uint8_t)(hudShakeTime>0.2f?120:hudShakeTime>0?64:0) });
|
||||
GradientFillRectDecal({ float(ScreenWidth()/2),0}, vf2d{(float)ScreenWidth() / 2,(float)ScreenHeight() / 2}, {(uint8_t)screenCol.r,(uint8_t)screenCol.g,(uint8_t)screenCol.b,(uint8_t)(hudShakeTime>0.2f?120:hudShakeTime>0?64:0)}, { (uint8_t)screenCol.r,(uint8_t)screenCol.g,(uint8_t)screenCol.b,(uint8_t)(hudShakeTime > 0.2f ? 64 : 0) }, {(uint8_t)screenCol.r,(uint8_t)screenCol.g,(uint8_t)screenCol.b,(uint8_t)(hudShakeTime>0.2f?120:hudShakeTime>0?64:0)}, {(uint8_t)screenCol.r,(uint8_t)screenCol.g,(uint8_t)screenCol.b,(uint8_t)(hudShakeTime>0.2f?120:hudShakeTime>0?64:0)});
|
||||
GradientFillRectDecal({ 0,float(ScreenHeight()/2)}, vf2d{(float)ScreenWidth() / 2,(float)ScreenHeight() / 2}, {(uint8_t)screenCol.r,(uint8_t)screenCol.g,(uint8_t)screenCol.b,(uint8_t)(hudShakeTime>0.2f?120:hudShakeTime>0?64:0)}, {(uint8_t)screenCol.r,(uint8_t)screenCol.g,(uint8_t)screenCol.b,(uint8_t)(hudShakeTime>0.2f?120:hudShakeTime>0?64:0)}, {(uint8_t)screenCol.r,(uint8_t)screenCol.g,(uint8_t)screenCol.b,(uint8_t)(hudShakeTime>0.2f?120:hudShakeTime>0?64:0)}, { (uint8_t)screenCol.r,(uint8_t)screenCol.g,(uint8_t)screenCol.b,(uint8_t)(hudShakeTime > 0.2f ? 64 : 0) });
|
||||
GradientFillRectDecal({ float(ScreenWidth()/2),float(ScreenHeight() / 2)}, vf2d{(float)ScreenWidth() / 2,(float)ScreenHeight() / 2}, { (uint8_t)screenCol.r,(uint8_t)screenCol.g,(uint8_t)screenCol.b,(uint8_t)(hudShakeTime > 0.2f ? 64 : 0) }, {(uint8_t)screenCol.r,(uint8_t)screenCol.g,(uint8_t)screenCol.b,(uint8_t)(hudShakeTime>0.2f?120:hudShakeTime>0?64:0)}, {(uint8_t)screenCol.r,(uint8_t)screenCol.g,(uint8_t)screenCol.b,(uint8_t)(hudShakeTime>0.2f?120:hudShakeTime>0?64:0)}, {(uint8_t)screenCol.r,(uint8_t)screenCol.g,(uint8_t)screenCol.b,(uint8_t)(hudShakeTime>0.2f?120:hudShakeTime>0?64:0)});
|
||||
FillRectDecal({ 0,0 }, vf2d{ (float)ScreenWidth(),(float)ScreenHeight() }, { (uint8_t)0,(uint8_t)0,(uint8_t)0,(uint8_t)screenAlpha });
|
||||
}
|
||||
|
||||
@ -1668,7 +1691,7 @@ void FaceBall::RunEnemyAI(Enemy& e,float fElapsedTime,int myIndex) {
|
||||
t.p[1].y = 0.04f + restingTriangleYDepth;
|
||||
t.p[2].y = 0.04f + restingTriangleYDepth;
|
||||
restingTriangleYDepth += 0.000001f;
|
||||
if (restingTriangleYDepth > 0.01f) {
|
||||
if (restingTriangleYDepth > 0.001f) {
|
||||
restingTriangleYDepth = 0.f;
|
||||
}
|
||||
}
|
||||
@ -1688,6 +1711,12 @@ void FaceBall::RunEnemyAI(Enemy& e,float fElapsedTime,int myIndex) {
|
||||
vf2d movementVec = { std::cosf(e.rot) * dat.movSpd * fElapsedTime,std::sinf(e.rot) * dat.movSpd * fElapsedTime };
|
||||
if (-1 == CheckEnemyCollision({ movementVec.x,0,movementVec.y }, { e.pos.x,e.pos.z }, e.radius, myIndex) &&
|
||||
!CheckCollision({ movementVec.x,0,movementVec.y }, { e.pos.x,e.pos.z }, e.radius)) {
|
||||
if (CheckPlayerCollision({ movementVec.x,0,movementVec.y }, { e.pos.x,e.pos.z }, e.radius)) {
|
||||
e.Hurt(999);
|
||||
e.setExploded(true);
|
||||
HurtPlayer(e.GetID(), 1, e.isBlinking());
|
||||
hudShakeTime = 0.6f;
|
||||
}
|
||||
e.pos.x += movementVec.x;
|
||||
e.pos.z += movementVec.y;
|
||||
}
|
||||
@ -1714,6 +1743,12 @@ void FaceBall::RunEnemyAI(Enemy& e,float fElapsedTime,int myIndex) {
|
||||
vf2d movementVec = { std::cosf(e.rot) * dat.movSpd * fElapsedTime,std::sinf(e.rot) * dat.movSpd * fElapsedTime };
|
||||
if (-1 == CheckEnemyCollision({ movementVec.x,0,movementVec.y }, { e.pos.x,e.pos.z }, e.radius, myIndex) &&
|
||||
!CheckCollision({ movementVec.x,0,movementVec.y }, { e.pos.x,e.pos.z }, e.radius)) {
|
||||
if (CheckPlayerCollision({ movementVec.x,0,movementVec.y }, { e.pos.x,e.pos.z }, e.radius)) {
|
||||
e.Hurt(999);
|
||||
e.setExploded(true);
|
||||
HurtPlayer(e.GetID(), 1, e.isBlinking());
|
||||
hudShakeTime = 0.6f;
|
||||
}
|
||||
e.pos.x += movementVec.x;
|
||||
e.pos.z += movementVec.y;
|
||||
if (e.CanShoot()) {
|
||||
@ -1762,8 +1797,10 @@ bool FaceBall::OnUserUpdate(float fElapsedTime)
|
||||
}
|
||||
switch (mode) {
|
||||
case GAME: {
|
||||
HandleKeys(fElapsedTime);
|
||||
if (hp > 0) { RenderWorld(); }
|
||||
if (hp > 0) {
|
||||
HandleKeys(fElapsedTime);
|
||||
RenderWorld();
|
||||
}
|
||||
else {
|
||||
respawnTimer -= fElapsedTime;
|
||||
if (respawnTimer <= 0.0f) {
|
||||
|
@ -273,6 +273,8 @@ class FaceBall : public PixelGameEngine
|
||||
float moveSpd = 2.0f;
|
||||
float hudOffset = 0;
|
||||
float hudOffsetAcc = 0;
|
||||
float hudShakeAmt = 0;
|
||||
Pixel screenCol = WHITE;
|
||||
float screenAlpha = 0;
|
||||
float respawnTimer = 0;
|
||||
vec3d spawnLoc = { 0,0.3,0 };
|
||||
@ -321,6 +323,7 @@ class FaceBall : public PixelGameEngine
|
||||
public:
|
||||
float restingTriangleYDepth = 0.f;
|
||||
std::vector<Bullet>bullets;
|
||||
float hudShakeTime = 0;
|
||||
Mesh bullet;
|
||||
float shotSpd = 4.0f;
|
||||
static bool CheckCollision(vec3d movementVector,vf2d pos,float radius);
|
||||
|
Loading…
x
Reference in New Issue
Block a user