Compare commits

..

No commits in common. 'd4e37b6179efedc77d91c380d679b4a3123cc7e2' and '57ee47105cd1c88471d92e9ba8d66ac35eef0151' have entirely different histories.

  1. 14
      Faceball2030/assets/map/map1.map
  2. 309
      Faceball2030/main.cpp
  3. 26
      Faceball2030/main.h

@ -19,26 +19,26 @@
8192 8192
8194 8194
8192 8192
16272 15632
16276 8196
8193 8193
2 2
25492 25492
8201 8201
16272 16144
8192 8192
16276 15508
8197 8197
8351 8351
8197 8197
8195 8195
8198 8198
273 273
16276 15764
8195 8195
8602 8602
8194 8194
8202 8202
8202 8202
8194 16018
16278 15894

@ -112,137 +112,16 @@ bool Enemy::Update(float fElapsedTime) {
blinkingAmt = std::sinf(30 * aliveTime); blinkingAmt = std::sinf(30 * aliveTime);
} }
} }
else {
if (!deathAnimationOver()) {
std::vector<Triangle>& tris = mesh.tris;
uint8_t darkenAmt = 0;
while (getColorFactor() >= 1) {
darkenAmt++;
decreaseColorFactor();
}
if (isExploded()) {
if (!flippedTriangles) {
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) {
if (t.p[0].y > 0.1) {
t.p[0].y = std::max(0.1f, t.p[0].y - 0.3f * fElapsedTime);
}
else {
float dir = std::atan2f(t.p[0].z, t.p[0].x);
t.p[0].x += std::cosf(dir) * 0.04f * fElapsedTime;
t.p[0].z += std::sinf(dir) * 0.04f * fElapsedTime;
}
if (t.p[1].y > 0.1) {
t.p[1].y = std::max(0.1f, t.p[1].y - 0.3f * fElapsedTime);
}
else {
float dir = std::atan2f(t.p[1].z, t.p[1].x);
t.p[1].x += std::cosf(dir) * 0.06f * fElapsedTime;
t.p[1].z += std::sinf(dir) * 0.06f * fElapsedTime;
}
if (t.p[2].y > 0.1) {
t.p[2].y = std::max(0.1f, t.p[2].y - 0.3f * fElapsedTime);
}
else {
float dir = std::atan2f(t.p[2].z, t.p[2].x);
t.p[2].x += std::cosf(dir) * 0.05f * fElapsedTime;
t.p[2].z += std::sinf(dir) * 0.05f * fElapsedTime;
}
if (darkenAmt > 0) {
t.col[0] -= {darkenAmt, darkenAmt, darkenAmt};
t.col[1] -= {darkenAmt, darkenAmt, darkenAmt};
t.col[2] -= {darkenAmt, darkenAmt, darkenAmt};
}
}
}
if (isExploded()) {
increaseDeathTimer(fElapsedTime * 3);
increaseColorFactor(fElapsedTime * 3);
}
else {
increaseDeathTimer(fElapsedTime);
increaseColorFactor(fElapsedTime);
}
}
else
if (!finishedAnimation) {
finishedAnimation = true;
if (isExploded()) {
for (Triangle& t : mesh.tris) {
t.p[0].y = 0.04f + game->restingTriangleYDepth;
t.p[1].y = 0.04f + game->restingTriangleYDepth;
t.p[2].y = 0.04f + game->restingTriangleYDepth;
game->restingTriangleYDepth += 0.000001f;
if (game->restingTriangleYDepth > 0.001f) {
game->restingTriangleYDepth = 0.f;
}
}
}
}
}
return true; return true;
} }
//Has Camo powerup code so camo masks the player position.
vf2d Enemy::GetPlayerPosition() {
if (game->PlayerHasCamo()) {
return { float(int(id) % game->MAP_SIZE.x) + 0.5f,float(int(id) % game->MAP_SIZE.y)+0.5f };
}
else {
return game->GetPlayerPos();
}
}
void Enemy::OnDeathEvent() { void Enemy::OnDeathEvent() {
game->AddScore(game->enemyData[id].health*10);
game->SubtractTag(); game->SubtractTag();
if (game->enemyData[id].powerupDrop != PowerupType::NONE) { if (game->enemyData[id].powerupDrop != PowerupType::NONE) {
game->SpawnPowerup(game->enemyData[id].powerupDrop, pos); game->SpawnPowerup(game->enemyData[id].powerupDrop, pos);
} }
} }
vf2d FaceBall::GetPlayerPos() {
return { player.GetPos().x,player.GetPos().z };
}
bool FaceBall::PlayerHasCamo() {
return camoDuration >= 0;
}
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 };
@ -1422,9 +1301,6 @@ void FaceBall::HandleKeys(float fElapsedTime) {
else { else {
pitch = 0; pitch = 0;
if (GetMouse(0).bPressed) { if (GetMouse(0).bPressed) {
if (bullets.size() >= shotLimit) {
bullets.erase(bullets.begin());
}
bullets.push_back({ bullet,{player.GetPos().x,player.GetPos().y - 0.15f, player.GetPos().z},fYaw,0.125f,{shotSpd * std::cosf(fYaw),shotSpd * std::sinf(fYaw)},GREEN,true }); bullets.push_back({ bullet,{player.GetPos().x,player.GetPos().y - 0.15f, player.GetPos().z},fYaw,0.125f,{shotSpd * std::cosf(fYaw),shotSpd * std::sinf(fYaw)},GREEN,true });
} }
} }
@ -1445,7 +1321,7 @@ void FaceBall::HandleKeys(float fElapsedTime) {
e.Hurt(999); e.Hurt(999);
e.setExploded(true); e.setExploded(true);
HurtPlayer(e.GetID(), 1, e.isBlinking()); HurtPlayer(e.GetID(), 1, e.isBlinking());
hudShakeTime = shieldDuration >= 0?0.2f:0.6f; hudShakeTime = 0.6f;
} }
player.UpdatePos(Vector_Add(player.GetPos(), xMovement)); player.UpdatePos(Vector_Add(player.GetPos(), xMovement));
} }
@ -1458,7 +1334,7 @@ void FaceBall::HandleKeys(float fElapsedTime) {
e.Hurt(999); e.Hurt(999);
e.setExploded(true); e.setExploded(true);
HurtPlayer(e.GetID(), 1, e.isBlinking()); HurtPlayer(e.GetID(), 1, e.isBlinking());
hudShakeTime = shieldDuration >= 0 ? 0.2f : 0.6f; hudShakeTime = 0.6f;
} }
player.UpdatePos(Vector_Add(player.GetPos(), zMovement)); player.UpdatePos(Vector_Add(player.GetPos(), zMovement));
} }
@ -1481,7 +1357,7 @@ void FaceBall::HandleKeys(float fElapsedTime) {
e.Hurt(999); e.Hurt(999);
e.setExploded(true); e.setExploded(true);
HurtPlayer(e.GetID(), 1, e.isBlinking()); HurtPlayer(e.GetID(), 1, e.isBlinking());
hudShakeTime = shieldDuration >= 0 ? 0.2f : 0.6f; hudShakeTime = 0.6f;
} }
player.UpdatePos(Vector_Add(player.GetPos(), xMovement)); player.UpdatePos(Vector_Add(player.GetPos(), xMovement));
} }
@ -1494,7 +1370,7 @@ void FaceBall::HandleKeys(float fElapsedTime) {
e.Hurt(999); e.Hurt(999);
e.setExploded(true); e.setExploded(true);
HurtPlayer(e.GetID(), 1, e.isBlinking()); HurtPlayer(e.GetID(), 1, e.isBlinking());
hudShakeTime = shieldDuration >= 0 ? 0.2f : 0.6f; hudShakeTime = 0.6f;
} }
player.UpdatePos(Vector_Add(player.GetPos(), zMovement)); player.UpdatePos(Vector_Add(player.GetPos(), zMovement));
} }
@ -1514,7 +1390,7 @@ void FaceBall::HandleKeys(float fElapsedTime) {
e.Hurt(999); e.Hurt(999);
e.setExploded(true); e.setExploded(true);
HurtPlayer(e.GetID(), 1, e.isBlinking()); HurtPlayer(e.GetID(), 1, e.isBlinking());
hudShakeTime = shieldDuration >= 0 ? 0.2f : 0.6f; hudShakeTime = 0.6f;
} }
player.UpdatePos(Vector_Add(player.GetPos(), xMovement)); player.UpdatePos(Vector_Add(player.GetPos(), xMovement));
} }
@ -1527,7 +1403,7 @@ void FaceBall::HandleKeys(float fElapsedTime) {
e.Hurt(999); e.Hurt(999);
e.setExploded(true); e.setExploded(true);
HurtPlayer(e.GetID(), 1, e.isBlinking()); HurtPlayer(e.GetID(), 1, e.isBlinking());
hudShakeTime = shieldDuration >= 0 ? 0.2f : 0.6f; hudShakeTime = 0.6f;
} }
player.UpdatePos(Vector_Add(player.GetPos(), zMovement)); player.UpdatePos(Vector_Add(player.GetPos(), zMovement));
} }
@ -1552,7 +1428,7 @@ void FaceBall::HandleKeys(float fElapsedTime) {
e.Hurt(999); e.Hurt(999);
e.setExploded(true); e.setExploded(true);
HurtPlayer(e.GetID(), 1, e.isBlinking()); HurtPlayer(e.GetID(), 1, e.isBlinking());
hudShakeTime = shieldDuration >= 0 ? 0.2f : 0.6f; hudShakeTime = 0.6f;
} }
player.UpdatePos(Vector_Add(player.GetPos(), xMovement)); player.UpdatePos(Vector_Add(player.GetPos(), xMovement));
} }
@ -1565,7 +1441,7 @@ void FaceBall::HandleKeys(float fElapsedTime) {
e.Hurt(999); e.Hurt(999);
e.setExploded(true); e.setExploded(true);
HurtPlayer(e.GetID(), 1, e.isBlinking()); HurtPlayer(e.GetID(), 1, e.isBlinking());
hudShakeTime = shieldDuration >= 0 ? 0.2f : 0.6f; hudShakeTime = 0.6f;
} }
player.UpdatePos(Vector_Add(player.GetPos(), zMovement)); player.UpdatePos(Vector_Add(player.GetPos(), zMovement));
} }
@ -1573,10 +1449,10 @@ void FaceBall::HandleKeys(float fElapsedTime) {
} }
if (GetKey(olc::A).bHeld) { if (GetKey(olc::A).bHeld) {
if (freeRoam) { if (freeRoam) {
freeRoamCamera_yaw -= turnSpd * fElapsedTime; freeRoamCamera_yaw -= 2 * fElapsedTime;
} }
else { else {
fYaw -= turnSpd * fElapsedTime; fYaw -= 2 * fElapsedTime;
if (hudOffset < 20) { if (hudOffset < 20) {
hudOffset = std::min(20.f, hudOffset + 128 * fElapsedTime); hudOffset = std::min(20.f, hudOffset + 128 * fElapsedTime);
} }
@ -1584,10 +1460,10 @@ void FaceBall::HandleKeys(float fElapsedTime) {
} }
if (GetKey(olc::D).bHeld) { if (GetKey(olc::D).bHeld) {
if (freeRoam) { if (freeRoam) {
freeRoamCamera_yaw += turnSpd * fElapsedTime; freeRoamCamera_yaw += 2 * fElapsedTime;
} }
else { else {
fYaw += turnSpd * fElapsedTime; fYaw += 2 * fElapsedTime;
if (hudOffset > -20) { if (hudOffset > -20) {
hudOffset = std::max(-20.f,hudOffset-128 * fElapsedTime); hudOffset = std::max(-20.f,hudOffset-128 * fElapsedTime);
} }
@ -1768,21 +1644,13 @@ bool Bullet::Update(float fElapsedTime) {
} }
void FaceBall::HurtPlayer(EnemyID id,int damage,bool blinking) { void FaceBall::HurtPlayer(EnemyID id,int damage,bool blinking) {
if (shieldDuration >= 0) {
damage = 0;
}
hp = std::max(0, hp - damage); hp = std::max(0, hp - damage);
if (hp <= 0) { if (hp <= 0) {
respawnTimer = 3.0f; respawnTimer = 3.0f;
} }
lastHitBy = id; lastHitBy = id;
lastHitByBlinking = blinking; lastHitByBlinking = blinking;
if (shieldDuration < 0) { screenCol = enemyData[lastHitBy].col;
screenCol = enemyData[lastHitBy].col;
}
else {
screenCol = WHITE;
}
} }
void FaceBall::Display3DKillerModel() { void FaceBall::Display3DKillerModel() {
@ -1929,14 +1797,6 @@ void FaceBall::RenderHud(float fElapsedTime) {
} }
} }
} }
for (int x = -1; x <= 1; x++) {
for (int y = -1; y <= 1; y++) {
if (x != 0 && y != 0) {
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 + vf2d{float(x),float(y)}, std::to_string(score), VERY_DARK_RED, {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 }); 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 });
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});
@ -2028,12 +1888,112 @@ void FaceBall::SubtractTag() {
} }
void FaceBall::RunEnemyAI(Enemy& e,float fElapsedTime,int myIndex) { void FaceBall::RunEnemyAI(Enemy& e,float fElapsedTime,int myIndex) {
if (!e.isDead()) { if (e.isDead()) {
if (!e.deathAnimationOver()) {
std::vector<Triangle>& tris = e.mesh.tris;
uint8_t darkenAmt = 0;
while (e.getColorFactor() >= 1) {
darkenAmt++;
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) {
if (t.p[0].y > 0.1) {
t.p[0].y = std::max(0.1f, t.p[0].y - 0.3f * fElapsedTime);
}
else {
float dir = std::atan2f(t.p[0].z, t.p[0].x);
t.p[0].x += std::cosf(dir) * 0.04f * fElapsedTime;
t.p[0].z += std::sinf(dir) * 0.04f * fElapsedTime;
}
if (t.p[1].y > 0.1) {
t.p[1].y = std::max(0.1f, t.p[1].y - 0.3f * fElapsedTime);
}
else {
float dir = std::atan2f(t.p[1].z, t.p[1].x);
t.p[1].x += std::cosf(dir) * 0.06f * fElapsedTime;
t.p[1].z += std::sinf(dir) * 0.06f * fElapsedTime;
}
if (t.p[2].y > 0.1) {
t.p[2].y = std::max(0.1f, t.p[2].y - 0.3f * fElapsedTime);
}
else {
float dir = std::atan2f(t.p[2].z, t.p[2].x);
t.p[2].x += std::cosf(dir) * 0.05f * fElapsedTime;
t.p[2].z += std::sinf(dir) * 0.05f * fElapsedTime;
}
if (darkenAmt > 0) {
t.col[0] -= {darkenAmt, darkenAmt, darkenAmt};
t.col[1] -= {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.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.001f) {
restingTriangleYDepth = 0.f;
}
}
}
}
}
else {
EnemyData dat = enemyData[e.GetID()]; EnemyData dat = enemyData[e.GetID()];
e.ReloadBullet(fElapsedTime); e.ReloadBullet(fElapsedTime);
switch (e.GetID()) { switch (e.GetID()) {
case SHOOTME: case SHOOTME: {
case SHOOTME_ARMOR: {
e.rot += 0.5 * fElapsedTime; e.rot += 0.5 * fElapsedTime;
}break; }break;
case SHOOTME2: { case SHOOTME2: {
@ -2114,13 +2074,13 @@ bool FaceBall::OnUserUpdate(float fElapsedTime)
switch (mode) { switch (mode) {
case GAME: { case GAME: {
hudDisplayText = ""; hudDisplayText = "";
if (stopDuration >= 0) { if (stopDuration > 0) {
stopDuration -= fElapsedTime; stopDuration -= fElapsedTime;
} }
if (shieldDuration >= 0) { if (shieldDuration > 0) {
shieldDuration -= fElapsedTime; shieldDuration -= fElapsedTime;
} }
if (camoDuration >= 0) { if (camoDuration > 0) {
camoDuration -= fElapsedTime; camoDuration -= fElapsedTime;
} }
for (std::vector<Bullet>::iterator it = bullets.begin(); it != bullets.end();) { for (std::vector<Bullet>::iterator it = bullets.begin(); it != bullets.end();) {
@ -2138,9 +2098,7 @@ bool FaceBall::OnUserUpdate(float fElapsedTime)
if (e.isLastHitTimerActive()) { if (e.isLastHitTimerActive()) {
e.reduceLastHitTimer(fElapsedTime); e.reduceLastHitTimer(fElapsedTime);
} }
if (stopDuration < 0) { RunEnemyAI(e, fElapsedTime, i);
RunEnemyAI(e, fElapsedTime, i);
}
} }
for (std::vector<Powerup>::iterator it = powerups.begin(); it != powerups.end();) { for (std::vector<Powerup>::iterator it = powerups.begin(); it != powerups.end();) {
Powerup& p = *it; Powerup& p = *it;
@ -2160,18 +2118,13 @@ bool FaceBall::OnUserUpdate(float fElapsedTime)
Powerup& power = powerups[lastPowerupCollidedWith]; Powerup& power = powerups[lastPowerupCollidedWith];
switch (power.type) { switch (power.type) {
case PowerupType::ARMOR: { case PowerupType::ARMOR: {
armorUpgrades=std::min(maxArmorUpgrades,armorUpgrades+1); armorUpgrades++;
maxHP = hp = armorUpgrades + baseHP;
}break; }break;
case PowerupType::SPEED: { case PowerupType::SPEED: {
speedUpgrades = std::min(maxSpeedUpgrades, speedUpgrades + 1); speedUpgrades++;
moveSpd = baseMoveSpd + speedUpgrades * 0.5;
turnSpd = baseTurnSpd + speedUpgrades * 0.25;
shotSpd = baseShotSpd + speedUpgrades * 0.5;
}break; }break;
case PowerupType::SHOTS: { case PowerupType::SHOTS: {
shotsUpgrades = std::min(maxShotsUpgrades, shotsUpgrades + 1); shotsUpgrades++;
shotLimit = baseShotLimit + shotsUpgrades * 1;
}break; }break;
case PowerupType::STOP: { case PowerupType::STOP: {
stopDuration = 20; stopDuration = 20;
@ -2186,7 +2139,7 @@ bool FaceBall::OnUserUpdate(float fElapsedTime)
hasMapUpgrade = true; hasMapUpgrade = true;
}break; }break;
case PowerupType::COIN: { case PowerupType::COIN: {
AddScore(1000); score += 1000;
}break; }break;
} }
powerups.erase(powerups.begin() + lastPowerupCollidedWith); powerups.erase(powerups.begin() + lastPowerupCollidedWith);
@ -2248,20 +2201,6 @@ void FaceBall::OnTextEntryComplete(const std::string& sText) {
} }
} }
//This function adds to the game score and increments lives appropriately.
void FaceBall::AddScore(int score) {
this->score += score;
if (lastAwardedScore/10000 != this->score/10000) {
lives++;
lastAwardedScore = this->score;
}
}
void FaceBall::ResetScore() {
score = 0;
lastAwardedScore = 0;
}
int main() int main()
{ {
FaceBall demo; FaceBall demo;

@ -249,7 +249,6 @@ struct Enemy : public Object {
bool isExploded(); bool isExploded();
bool Update(float fElapsedTime); bool Update(float fElapsedTime);
void OnDeathEvent(); void OnDeathEvent();
vf2d GetPlayerPosition();
}; };
class FaceBall : public PixelGameEngine class FaceBall : public PixelGameEngine
@ -321,29 +320,20 @@ class FaceBall : public PixelGameEngine
}; };
Player player = { {3.7,0.3,0.7}, {{0.5,0.5},0.2} }; Player player = { {3.7,0.3,0.7}, {{0.5,0.5},0.2} };
const int baseHP = 3; int hp = 3;
int hp = baseHP;
int maxHP=hp; int maxHP=hp;
int score = 0; int score = 0;
int lastAwardedScore = 0;
Object walls; Object walls;
Object exit; Object exit;
vec3d freeRoamCamera = { 1,0.5,1 }; vec3d freeRoamCamera = { 1,0.5,1 };
float freeRoamCamera_pitch = pitch; float freeRoamCamera_pitch = pitch;
float freeRoamCamera_yaw = fYaw; float freeRoamCamera_yaw = fYaw;
int armorUpgrades = 0, maxArmorUpgrades=20; int armorUpgrades = 2, maxArmorUpgrades=20;
int speedUpgrades = 0, maxSpeedUpgrades=5; int speedUpgrades = 2, maxSpeedUpgrades=5;
int shotsUpgrades = 0, maxShotsUpgrades=3; int shotsUpgrades = 2, maxShotsUpgrades=3;
const float baseMoveSpd = 2.0f; float moveSpd = 2.0f;
const float baseTurnSpd = 2.0f;
const float baseShotSpd = 4.0f;
int baseShotLimit = 2;
int shotLimit = baseShotLimit;
float moveSpd = baseMoveSpd;
float turnSpd = baseTurnSpd;
float hudOffset = 0; float hudOffset = 0;
float hudOffsetAcc = 0; float hudOffsetAcc = 0;
float hudShakeAmt = 0; float hudShakeAmt = 0;
@ -396,14 +386,13 @@ class FaceBall : public PixelGameEngine
void ConvertBulletColor(Mesh& bullet, Pixel col); void ConvertBulletColor(Mesh& bullet, Pixel col);
void Display3DKillerModel(); void Display3DKillerModel();
int CheckPowerupCollision(vec3d movementVector, vf2d pos, float radius); int CheckPowerupCollision(vec3d movementVector, vf2d pos, float radius);
void ResetScore();
public: public:
vi2d MAP_SIZE; vi2d MAP_SIZE;
float restingTriangleYDepth = 0.f; float restingTriangleYDepth = 0.f;
std::vector<Bullet>bullets; std::vector<Bullet>bullets;
float hudShakeTime = 0; float hudShakeTime = 0;
Mesh bullet; Mesh bullet;
float shotSpd = baseShotSpd; float shotSpd = 4.0f;
static bool CheckCollision(vec3d movementVector,vf2d pos,float radius); static bool CheckCollision(vec3d movementVector,vf2d pos,float radius);
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 int CheckExplosiveEnemyCollision(vec3d movementVector, vf2d pos, float radius, int ignoreIndex = -1); static int CheckExplosiveEnemyCollision(vec3d movementVector, vf2d pos, float radius, int ignoreIndex = -1);
@ -411,7 +400,4 @@ class FaceBall : public PixelGameEngine
void SubtractTag(); void SubtractTag();
void HurtPlayer(EnemyID id, int damage=1,bool blinking = false); void HurtPlayer(EnemyID id, int damage=1,bool blinking = false);
void SpawnPowerup(PowerupType type, vec3d pos); void SpawnPowerup(PowerupType type, vec3d pos);
bool PlayerHasCamo();
vf2d GetPlayerPos();
void AddScore(int score);
}; };
Loading…
Cancel
Save