Explosion.
This commit is contained in:
parent
2abd640dcb
commit
cf4ed30867
@ -100,6 +100,10 @@ bool Enemy::isBlinking() {
|
|||||||
return blinking;
|
return blinking;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Enemy::isExploded() {
|
||||||
|
return exploded;
|
||||||
|
}
|
||||||
|
|
||||||
void FaceBall::InitializeEnemyData() {
|
void FaceBall::InitializeEnemyData() {
|
||||||
enemyData[EnemyID::NONE] = { "VOID",undefined,BLACK };
|
enemyData[EnemyID::NONE] = { "VOID",undefined,BLACK };
|
||||||
enemyData[EXIT] = { "EXIT",undefined,GREEN };
|
enemyData[EXIT] = { "EXIT",undefined,GREEN };
|
||||||
@ -128,6 +132,7 @@ void FaceBall::ConvertBulletColor(Mesh& bullet, Pixel col) {
|
|||||||
void FaceBall::LoadLevel(int level)
|
void FaceBall::LoadLevel(int level)
|
||||||
{
|
{
|
||||||
this->level = level;
|
this->level = level;
|
||||||
|
restingTriangleYDepth = 0.f;
|
||||||
exitWallsCleared = false;
|
exitWallsCleared = false;
|
||||||
std::vector<std::vector<Tile>>mapData = editor.LoadLevel(level);
|
std::vector<std::vector<Tile>>mapData = editor.LoadLevel(level);
|
||||||
MAP_SIZE = { (int)mapData[0].size(),(int)mapData.size() };
|
MAP_SIZE = { (int)mapData[0].size(),(int)mapData.size() };
|
||||||
@ -1577,6 +1582,42 @@ void FaceBall::RunEnemyAI(Enemy& e,float fElapsedTime,int myIndex) {
|
|||||||
darkenAmt++;
|
darkenAmt++;
|
||||||
e.decreaseColorFactor();
|
e.decreaseColorFactor();
|
||||||
}
|
}
|
||||||
|
if (e.isExploded()) {
|
||||||
|
if (!e.flippedTriangles) {
|
||||||
|
e.flippedTriangles = true;
|
||||||
|
for (Triangle& t : tris) {
|
||||||
|
vec3d temp=t.p[1];
|
||||||
|
t.p[1] = t.p[2];
|
||||||
|
t.p[2] = t.p[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (Triangle& t : tris) {
|
||||||
|
float dir = std::atan2f(t.p[0].z, t.p[0].x);
|
||||||
|
t.p[0].x += std::cosf(dir+ (rand() % 200 / 200.f)- 1) * (rand() % 100/100.f) * fElapsedTime*3;
|
||||||
|
t.p[0].z += std::sinf(dir + (rand() % 200 / 200.f) - 1) * (rand() % 100 / 100.f) * fElapsedTime * 3;
|
||||||
|
if (t.p[0].y > 0.041f) {
|
||||||
|
t.p[0].y = std::max(0.04f, t.p[0].y - 0.8f * fElapsedTime * 3);
|
||||||
|
}
|
||||||
|
dir = std::atan2f(t.p[1].z, t.p[1].x);
|
||||||
|
t.p[1].x += std::cosf(dir + (rand() % 200 / 200.f) - 1) * (rand() % 100 / 100.f) * fElapsedTime * 3;
|
||||||
|
t.p[1].z += std::sinf(dir + (rand() % 200 / 200.f) - 1) * (rand() % 100 / 100.f) * fElapsedTime * 3;
|
||||||
|
if (t.p[1].y > 0.041f) {
|
||||||
|
t.p[1].y = std::max(0.04f, t.p[1].y - 0.8f * fElapsedTime * 3);
|
||||||
|
}
|
||||||
|
dir = std::atan2f(t.p[2].z, t.p[2].x);
|
||||||
|
t.p[2].x += std::cosf(dir + (rand() % 200 / 200.f) - 1) * (rand() % 70 / 100.f) * fElapsedTime * 3;
|
||||||
|
t.p[2].z += std::sinf(dir + (rand() % 200 / 200.f) - 1) * (rand() % 70 / 100.f) * fElapsedTime * 3;
|
||||||
|
if (t.p[2].y > 0.041f) {
|
||||||
|
t.p[2].y = std::max(0.04f, t.p[2].y - 0.8f * fElapsedTime * 3);
|
||||||
|
}
|
||||||
|
if (darkenAmt > 0) {
|
||||||
|
t.col[0] -= {darkenAmt, darkenAmt, darkenAmt};
|
||||||
|
t.col[1] -= {darkenAmt, darkenAmt, darkenAmt};
|
||||||
|
t.col[2] -= {darkenAmt, darkenAmt, darkenAmt};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
for (Triangle& t : tris) {
|
for (Triangle& t : tris) {
|
||||||
if (t.p[0].y > 0.1) {
|
if (t.p[0].y > 0.1) {
|
||||||
t.p[0].y = std::max(0.1f, t.p[0].y - 0.3f * fElapsedTime);
|
t.p[0].y = std::max(0.1f, t.p[0].y - 0.3f * fElapsedTime);
|
||||||
@ -1608,10 +1649,32 @@ void FaceBall::RunEnemyAI(Enemy& e,float fElapsedTime,int myIndex) {
|
|||||||
t.col[2] -= {darkenAmt, darkenAmt, darkenAmt};
|
t.col[2] -= {darkenAmt, darkenAmt, darkenAmt};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (e.isExploded()) {
|
||||||
|
e.increaseDeathTimer(fElapsedTime*3);
|
||||||
|
e.increaseColorFactor(fElapsedTime*3);
|
||||||
|
}
|
||||||
|
else {
|
||||||
e.increaseDeathTimer(fElapsedTime);
|
e.increaseDeathTimer(fElapsedTime);
|
||||||
e.increaseColorFactor(fElapsedTime);
|
e.increaseColorFactor(fElapsedTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
if (!e.finishedAnimation){
|
||||||
|
e.finishedAnimation = true;
|
||||||
|
if (e.isExploded()) {
|
||||||
|
for (Triangle& t : e.mesh.tris) {
|
||||||
|
t.p[0].y = 0.04f+ restingTriangleYDepth;
|
||||||
|
t.p[1].y = 0.04f + restingTriangleYDepth;
|
||||||
|
t.p[2].y = 0.04f + restingTriangleYDepth;
|
||||||
|
restingTriangleYDepth += 0.000001f;
|
||||||
|
if (restingTriangleYDepth > 0.01f) {
|
||||||
|
restingTriangleYDepth = 0.f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
EnemyData dat = enemyData[e.GetID()];
|
EnemyData dat = enemyData[e.GetID()];
|
||||||
e.ReloadBullet(fElapsedTime);
|
e.ReloadBullet(fElapsedTime);
|
||||||
|
@ -193,6 +193,8 @@ struct Enemy : public Object {
|
|||||||
float lastHitTime = 0;
|
float lastHitTime = 0;
|
||||||
public:
|
public:
|
||||||
float turnAmt = 0;
|
float turnAmt = 0;
|
||||||
|
bool flippedTriangles = false;
|
||||||
|
bool finishedAnimation = false;
|
||||||
Enemy(EnemyID id, vec3d pos, float rot, float radius);
|
Enemy(EnemyID id, vec3d pos, float rot, float radius);
|
||||||
EnemyID GetID();
|
EnemyID GetID();
|
||||||
//Can set the damage to 0 to cause just a visual hit.
|
//Can set the damage to 0 to cause just a visual hit.
|
||||||
@ -213,6 +215,7 @@ struct Enemy : public Object {
|
|||||||
bool isExplosive();
|
bool isExplosive();
|
||||||
void setExploded(bool exploded);
|
void setExploded(bool exploded);
|
||||||
bool isBlinking();
|
bool isBlinking();
|
||||||
|
bool isExploded();
|
||||||
};
|
};
|
||||||
|
|
||||||
class FaceBall : public PixelGameEngine
|
class FaceBall : public PixelGameEngine
|
||||||
@ -316,6 +319,7 @@ class FaceBall : public PixelGameEngine
|
|||||||
void RenderHud(float fElapsedTime);
|
void RenderHud(float fElapsedTime);
|
||||||
void ConvertBulletColor(Mesh& bullet, Pixel col);
|
void ConvertBulletColor(Mesh& bullet, Pixel col);
|
||||||
public:
|
public:
|
||||||
|
float restingTriangleYDepth = 0.f;
|
||||||
std::vector<Bullet>bullets;
|
std::vector<Bullet>bullets;
|
||||||
Mesh bullet;
|
Mesh bullet;
|
||||||
float shotSpd = 4.0f;
|
float shotSpd = 4.0f;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user