|
|
|
@ -95,6 +95,7 @@ bool Enemy::isExplosive() { |
|
|
|
|
|
|
|
|
|
void Enemy::setExploded(bool exploded) { |
|
|
|
|
this->exploded = exploded; |
|
|
|
|
game->RegenerateMinimap(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Enemy Enemy::freshCopy(bool randomizeLoc){ |
|
|
|
@ -238,6 +239,9 @@ void Enemy::OnDeathEvent() { |
|
|
|
|
if (game->enemyData[id].powerupDrop != PowerupType::NONE) { |
|
|
|
|
game->SpawnPowerup(game->enemyData[id].powerupDrop, pos); |
|
|
|
|
} |
|
|
|
|
if (game->PlayerHasMapUpgrade()){ |
|
|
|
|
game->RegenerateMinimap(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
vf2d FaceBall::GetPlayerPos() { |
|
|
|
@ -427,6 +431,51 @@ void FaceBall::LoadLevel(int level) |
|
|
|
|
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.02f,(float)exitCoords.y + 0.5f},0,0.4f }; |
|
|
|
|
RegenerateMinimap(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void FaceBall::RegenerateMinimap(){ |
|
|
|
|
vf2d mapCenter = {float(ScreenWidth()-364),float(164)}; |
|
|
|
|
vf2d mapSprSize = {float(mapSpr->width),float(mapSpr->height)}; |
|
|
|
|
SetDrawTarget(mapSpr); |
|
|
|
|
Clear(BLACK); |
|
|
|
|
const int MAP_VISIBILITY=6; |
|
|
|
|
for (int x=0;x<MAP_SIZE.x;x++){ |
|
|
|
|
for (int y=0;y<MAP_SIZE.y;y++){ |
|
|
|
|
float dist = std::sqrtf(std::pow(player.GetPos().x-x,2)+std::pow(player.GetPos().z-y,2)); |
|
|
|
|
if (dist<MAP_VISIBILITY){ |
|
|
|
|
try{ |
|
|
|
|
MapSquare&square=map.at(y).at(x); |
|
|
|
|
vf2d squareLoc = vf2d{x*minimapGridSize.x,y*minimapGridSize.y}; |
|
|
|
|
if (square.wallN){ |
|
|
|
|
DrawLine(squareLoc,squareLoc+vf2d{1.f,0.f}*minimapGridSize,{255,255,255,uint8_t((1-(float(dist)/MAP_VISIBILITY))*255)}); |
|
|
|
|
} |
|
|
|
|
if (square.wallS){ |
|
|
|
|
DrawLine(squareLoc+vf2d{0,1.f}*minimapGridSize,squareLoc+vf2d{1,1}*minimapGridSize,{255,255,255,uint8_t((1-(float(dist)/MAP_VISIBILITY))*255)}); |
|
|
|
|
} |
|
|
|
|
if (square.wallE){ |
|
|
|
|
DrawLine(squareLoc+vf2d{1,0}*minimapGridSize,squareLoc+vf2d{1,1}*minimapGridSize,{255,255,255,uint8_t((1-(float(dist)/MAP_VISIBILITY))*255)}); |
|
|
|
|
} |
|
|
|
|
if (square.wallW){ |
|
|
|
|
DrawLine(squareLoc,squareLoc+vf2d{0,1}*minimapGridSize,{255,255,255,uint8_t((1-(float(dist)/MAP_VISIBILITY))*255)}); |
|
|
|
|
} |
|
|
|
|
if (hasMapUpgrade){ |
|
|
|
|
for (Enemy&e:enemies){ |
|
|
|
|
if (!e.isDead()){ |
|
|
|
|
if (vi2d{int(e.pos.x),int(e.pos.z)}==vi2d{x,y}){ |
|
|
|
|
FillCircle(vi2d{int(squareLoc.x+0.5*minimapGridSize.x),int(squareLoc.y+0.5*minimapGridSize.y)},3,enemyData[e.GetID()].col*(1-(float(dist)/MAP_VISIBILITY))); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} catch (std::out_of_range const& exc) { |
|
|
|
|
std::cout << exc.what() << '\n'; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
SetDrawTarget(nullptr); |
|
|
|
|
mapDecal->Update(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool FaceBall::CheckCollision(vec3d movementVector,vf2d pos,float radius){ |
|
|
|
@ -1626,6 +1675,10 @@ void FaceBall::HandleKeys(float fElapsedTime) { |
|
|
|
|
if (GetKey(olc::F1).bPressed) { |
|
|
|
|
freeRoam = !freeRoam; |
|
|
|
|
} |
|
|
|
|
if (vi2d{int(player.GetPos().x),int(player.GetPos().z)}!=playerRoundedCoords){ |
|
|
|
|
playerRoundedCoords = vi2d{int(player.GetPos().x),int(player.GetPos().z)}; |
|
|
|
|
RegenerateMinimap(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void FaceBall::AddWall(int dir, vi2d gridSquare) { |
|
|
|
@ -1694,6 +1747,9 @@ bool FaceBall::OnUserCreate() |
|
|
|
|
mapWalls.texture = wall_tex; |
|
|
|
|
mapFloor.texture = floor_tex; |
|
|
|
|
|
|
|
|
|
mapSpr=new Sprite(minimapGridSize.x*20,minimapGridSize.y*20); |
|
|
|
|
mapDecal=new Decal(mapSpr); |
|
|
|
|
|
|
|
|
|
InitializeEnemyData(); |
|
|
|
|
InitializePowerupColors(); |
|
|
|
|
|
|
|
|
@ -1800,20 +1856,23 @@ bool Bullet::Update(float fElapsedTime) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void FaceBall::HurtPlayer(EnemyID id,int damage,bool blinking) { |
|
|
|
|
if (shieldDuration >= 0) { |
|
|
|
|
damage = 0; |
|
|
|
|
} |
|
|
|
|
hp = std::max(0, hp - damage); |
|
|
|
|
if (hp <= 0) { |
|
|
|
|
respawnTimer = 3.0f; |
|
|
|
|
} |
|
|
|
|
lastHitBy = id; |
|
|
|
|
lastHitByBlinking = blinking; |
|
|
|
|
if (shieldDuration < 0) { |
|
|
|
|
screenCol = enemyData[lastHitBy].col; |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
screenCol = WHITE; |
|
|
|
|
if (respawnTimer<=0.0f){ |
|
|
|
|
if (shieldDuration >= 0) { |
|
|
|
|
damage = 0; |
|
|
|
|
} |
|
|
|
|
hp = std::max(0, hp - damage); |
|
|
|
|
if (hp <= 0) { |
|
|
|
|
RegenerateMinimap(); |
|
|
|
|
respawnTimer = 3.0f; |
|
|
|
|
} |
|
|
|
|
lastHitBy = id; |
|
|
|
|
lastHitByBlinking = blinking; |
|
|
|
|
if (shieldDuration < 0) { |
|
|
|
|
screenCol = enemyData[lastHitBy].col; |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
screenCol = WHITE; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -1936,6 +1995,7 @@ void FaceBall::RenderHud(float fElapsedTime) { |
|
|
|
|
hudShakeAmt = std::sinf(40 * hudShakeTime); |
|
|
|
|
hudAdjustment.x += hudShakeAmt * 2; |
|
|
|
|
hudAdjustment.y += hudShakeAmt * 4; |
|
|
|
|
hudOffset += hudShakeAmt * 2; |
|
|
|
|
} |
|
|
|
|
vf2d hudLoc = { hudAdjustment.x + (hp>0?hudOffset:0),hudAdjustment.y}; |
|
|
|
|
if (hp > 0) { |
|
|
|
@ -1982,6 +2042,10 @@ void FaceBall::RenderHud(float fElapsedTime) { |
|
|
|
|
if (camoDuration > 0) { |
|
|
|
|
DrawPartialDecal({ hudOffset + float(ScreenWidth() / 10 - 16), float(ScreenHeight() / 4 + ScreenHeight() / 4 * 2 - 16 * 4) }, vf2d{ 32,32 }*4, powerups_tex, { 5 * 32,0 }, { 32,32 },camoDuration>7?WHITE:camoDuration>2?std::abs(std::sin(10*camoDuration))>0.65?WHITE:BLACK: std::abs(std::sin(30 * camoDuration)) > 0.75 ? WHITE : BLACK); |
|
|
|
|
} |
|
|
|
|
vf2d mapCenter = {float(ScreenWidth()-364),float(164)}; |
|
|
|
|
SetDrawTarget(nullptr); |
|
|
|
|
DrawDecal(vf2d{mapCenter.x+hudOffset/2,mapCenter.y}-vf2d{2.5f,2.5f},dot,{5,5},GREEN); |
|
|
|
|
DrawRotatedDecal({mapCenter.x+hudOffset/2,mapCenter.y},mapDecal,-fYaw-PI/2,vf2d{int(player.GetPos().x)+0.5f,int(player.GetPos().z)+0.5f}*minimapGridSize,{1,1}); |
|
|
|
|
SetDecalMode(DecalMode::NORMAL); |
|
|
|
|
} |
|
|
|
|
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) }); |
|
|
|
@ -2106,7 +2170,8 @@ void FaceBall::RunEnemyAI(Enemy& e,float fElapsedTime,int myIndex) { |
|
|
|
|
}break; |
|
|
|
|
} |
|
|
|
|
}break; |
|
|
|
|
case ISHOOT: { |
|
|
|
|
case ISHOOT: |
|
|
|
|
case ISHOOT_MAP: { |
|
|
|
|
e.rot += dat.rotSpd * fElapsedTime; |
|
|
|
|
if (e.CanShoot()) { |
|
|
|
|
e.ShootBullet(myIndex); |
|
|
|
@ -2149,9 +2214,19 @@ void FaceBall::RunEnemyAI(Enemy& e,float fElapsedTime,int myIndex) { |
|
|
|
|
} |
|
|
|
|
}break; |
|
|
|
|
} |
|
|
|
|
if (e.roundedCoords!=vi2d{int(e.pos.x),int(e.pos.z)}){ |
|
|
|
|
e.roundedCoords=vi2d{int(e.pos.x),int(e.pos.z)}; |
|
|
|
|
if (hasMapUpgrade){ |
|
|
|
|
RegenerateMinimap(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool FaceBall::PlayerHasMapUpgrade(){ |
|
|
|
|
return hasMapUpgrade; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool FaceBall::OnUserUpdate(float fElapsedTime) |
|
|
|
|
{ |
|
|
|
|
fElapsedTime = std::min(0.01667f, fElapsedTime); |
|
|
|
@ -2178,6 +2253,7 @@ bool FaceBall::OnUserUpdate(float fElapsedTime) |
|
|
|
|
!CheckPlayerCollision({0,0,0},{e.pos.x,e.pos.z},e.radius*6)){ |
|
|
|
|
enemies.push_back(e); |
|
|
|
|
wave2Enemies.erase(wave2Enemies.begin()+i); |
|
|
|
|
RegenerateMinimap(); |
|
|
|
|
goto spawningDone; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -2189,6 +2265,7 @@ bool FaceBall::OnUserUpdate(float fElapsedTime) |
|
|
|
|
!CheckPlayerCollision({0,0,0},{e.pos.x,e.pos.z},e.radius*6)){ |
|
|
|
|
enemies.push_back(e); |
|
|
|
|
wave3Enemies.erase(wave3Enemies.begin()+i); |
|
|
|
|
RegenerateMinimap(); |
|
|
|
|
goto spawningDone; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -2204,6 +2281,7 @@ bool FaceBall::OnUserUpdate(float fElapsedTime) |
|
|
|
|
!CheckPlayerCollision({0,0,0},{e.pos.x,e.pos.z},e.radius*6)){ |
|
|
|
|
enemies.push_back(e); |
|
|
|
|
wave2Enemies.erase(wave2Enemies.begin()+i); |
|
|
|
|
RegenerateMinimap(); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -2270,6 +2348,7 @@ bool FaceBall::OnUserUpdate(float fElapsedTime) |
|
|
|
|
}break; |
|
|
|
|
case PowerupType::MAP: { |
|
|
|
|
hasMapUpgrade = true; |
|
|
|
|
RegenerateMinimap(); |
|
|
|
|
}break; |
|
|
|
|
case PowerupType::COIN: { |
|
|
|
|
AddScore(1000); |
|
|
|
|