|
|
@ -95,6 +95,7 @@ bool Enemy::isExplosive() { |
|
|
|
|
|
|
|
|
|
|
|
void Enemy::setExploded(bool exploded) { |
|
|
|
void Enemy::setExploded(bool exploded) { |
|
|
|
this->exploded = exploded; |
|
|
|
this->exploded = exploded; |
|
|
|
|
|
|
|
game->RegenerateMinimap(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Enemy Enemy::freshCopy(bool randomizeLoc){ |
|
|
|
Enemy Enemy::freshCopy(bool randomizeLoc){ |
|
|
@ -238,6 +239,9 @@ void Enemy::OnDeathEvent() { |
|
|
|
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); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (game->PlayerHasMapUpgrade()){ |
|
|
|
|
|
|
|
game->RegenerateMinimap(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
vf2d FaceBall::GetPlayerPos() { |
|
|
|
vf2d FaceBall::GetPlayerPos() { |
|
|
@ -427,6 +431,50 @@ void FaceBall::LoadLevel(int level) |
|
|
|
objects.push_back({ mapFloor,{0,0,0},0,0 }); |
|
|
|
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 });
|
|
|
|
//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 }; |
|
|
|
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); |
|
|
|
|
|
|
|
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<6){ |
|
|
|
|
|
|
|
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,WHITE); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (square.wallS){ |
|
|
|
|
|
|
|
DrawLine(squareLoc+vf2d{0,1.f}*minimapGridSize,squareLoc+vf2d{1,1}*minimapGridSize,WHITE); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (square.wallE){ |
|
|
|
|
|
|
|
DrawLine(squareLoc+vf2d{1,0}*minimapGridSize,squareLoc+vf2d{1,1}*minimapGridSize,WHITE); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (square.wallW){ |
|
|
|
|
|
|
|
DrawLine(squareLoc,squareLoc+vf2d{0,1}*minimapGridSize,WHITE); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
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); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} 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){ |
|
|
|
bool FaceBall::CheckCollision(vec3d movementVector,vf2d pos,float radius){ |
|
|
@ -1626,6 +1674,10 @@ void FaceBall::HandleKeys(float fElapsedTime) { |
|
|
|
if (GetKey(olc::F1).bPressed) { |
|
|
|
if (GetKey(olc::F1).bPressed) { |
|
|
|
freeRoam = !freeRoam; |
|
|
|
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) { |
|
|
|
void FaceBall::AddWall(int dir, vi2d gridSquare) { |
|
|
@ -1694,7 +1746,7 @@ bool FaceBall::OnUserCreate() |
|
|
|
mapWalls.texture = wall_tex; |
|
|
|
mapWalls.texture = wall_tex; |
|
|
|
mapFloor.texture = floor_tex; |
|
|
|
mapFloor.texture = floor_tex; |
|
|
|
|
|
|
|
|
|
|
|
mapSpr=new Sprite(128,128); |
|
|
|
mapSpr=new Sprite(minimapGridSize.x*20,minimapGridSize.y*20); |
|
|
|
mapDecal=new Decal(mapSpr); |
|
|
|
mapDecal=new Decal(mapSpr); |
|
|
|
|
|
|
|
|
|
|
|
InitializeEnemyData(); |
|
|
|
InitializeEnemyData(); |
|
|
@ -1803,11 +1855,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 (respawnTimer<=0.0f){ |
|
|
|
if (shieldDuration >= 0) { |
|
|
|
if (shieldDuration >= 0) { |
|
|
|
damage = 0; |
|
|
|
damage = 0; |
|
|
|
} |
|
|
|
} |
|
|
|
hp = std::max(0, hp - damage); |
|
|
|
hp = std::max(0, hp - damage); |
|
|
|
if (hp <= 0) { |
|
|
|
if (hp <= 0) { |
|
|
|
|
|
|
|
RegenerateMinimap(); |
|
|
|
respawnTimer = 3.0f; |
|
|
|
respawnTimer = 3.0f; |
|
|
|
} |
|
|
|
} |
|
|
|
lastHitBy = id; |
|
|
|
lastHitBy = id; |
|
|
@ -1818,6 +1872,7 @@ void FaceBall::HurtPlayer(EnemyID id,int damage,bool blinking) { |
|
|
|
else { |
|
|
|
else { |
|
|
|
screenCol = WHITE; |
|
|
|
screenCol = WHITE; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void FaceBall::Display3DKillerModel() { |
|
|
|
void FaceBall::Display3DKillerModel() { |
|
|
@ -1939,6 +1994,7 @@ void FaceBall::RenderHud(float fElapsedTime) { |
|
|
|
hudShakeAmt = std::sinf(40 * hudShakeTime); |
|
|
|
hudShakeAmt = std::sinf(40 * hudShakeTime); |
|
|
|
hudAdjustment.x += hudShakeAmt * 2; |
|
|
|
hudAdjustment.x += hudShakeAmt * 2; |
|
|
|
hudAdjustment.y += hudShakeAmt * 4; |
|
|
|
hudAdjustment.y += hudShakeAmt * 4; |
|
|
|
|
|
|
|
hudOffset += hudShakeAmt * 2; |
|
|
|
} |
|
|
|
} |
|
|
|
vf2d hudLoc = { hudAdjustment.x + (hp>0?hudOffset:0),hudAdjustment.y}; |
|
|
|
vf2d hudLoc = { hudAdjustment.x + (hp>0?hudOffset:0),hudAdjustment.y}; |
|
|
|
if (hp > 0) { |
|
|
|
if (hp > 0) { |
|
|
@ -1986,38 +2042,9 @@ void FaceBall::RenderHud(float fElapsedTime) { |
|
|
|
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); |
|
|
|
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)}; |
|
|
|
vf2d mapCenter = {float(ScreenWidth()-364),float(164)}; |
|
|
|
mapSpr= new Sprite{128,128}; |
|
|
|
|
|
|
|
vf2d mapSprSize = {float(mapSpr->width),float(mapSpr->height)}; |
|
|
|
|
|
|
|
SetDrawTarget(mapSpr); |
|
|
|
|
|
|
|
Clear(BLACK); |
|
|
|
|
|
|
|
vf2d center = mapSprSize/2; |
|
|
|
|
|
|
|
vf2d minimapGridSize={16,16}; |
|
|
|
|
|
|
|
for (int x=-5;x<=5;x++){ |
|
|
|
|
|
|
|
for (int y=-5;y<=5;y++){ |
|
|
|
|
|
|
|
try{ |
|
|
|
|
|
|
|
MapSquare&square=map.at(y+int(player.GetPos().z)).at(x+int(player.GetPos().x)); |
|
|
|
|
|
|
|
vf2d squareLoc = center+vf2d{x*minimapGridSize.x,y*minimapGridSize.y}; |
|
|
|
|
|
|
|
if (square.wallN){ |
|
|
|
|
|
|
|
DrawLine(squareLoc+vf2d{-0.5f,-0.5f}*minimapGridSize,squareLoc+vf2d{0.5f,-0.5f}*minimapGridSize,WHITE); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (square.wallS){ |
|
|
|
|
|
|
|
DrawLine(squareLoc+vf2d{-0.5f,0.5f}*minimapGridSize,squareLoc+vf2d{0.5f,0.5f}*minimapGridSize,WHITE); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (square.wallE){ |
|
|
|
|
|
|
|
DrawLine(squareLoc+vf2d{0.5f,-0.5f}*minimapGridSize,squareLoc+vf2d{0.5f,0.5f}*minimapGridSize,WHITE); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (square.wallW){ |
|
|
|
|
|
|
|
DrawLine(squareLoc+vf2d{-0.5f,-0.5f}*minimapGridSize,squareLoc+vf2d{-0.5f,0.5f}*minimapGridSize,WHITE); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} catch (std::out_of_range const& exc) { |
|
|
|
|
|
|
|
std::cout << exc.what() << '\n'; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
FillCircle(center,5,GREEN); |
|
|
|
|
|
|
|
SetDrawTarget(nullptr); |
|
|
|
SetDrawTarget(nullptr); |
|
|
|
mapDecal=new Decal(mapSpr); |
|
|
|
DrawDecal(vf2d{mapCenter.x+hudOffset/2,mapCenter.y}-vf2d{2.5f,2.5f},dot,{5,5},GREEN); |
|
|
|
DrawRotatedDecal(mapCenter-mapSprSize,mapDecal,-fYaw-PI/2,mapSprSize/2); |
|
|
|
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); |
|
|
|
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) }); |
|
|
|
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) }); |
|
|
@ -2186,13 +2213,21 @@ void FaceBall::RunEnemyAI(Enemy& e,float fElapsedTime,int myIndex) { |
|
|
|
} |
|
|
|
} |
|
|
|
}break; |
|
|
|
}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) |
|
|
|
bool FaceBall::OnUserUpdate(float fElapsedTime) |
|
|
|
{ |
|
|
|
{ |
|
|
|
delete mapSpr; |
|
|
|
|
|
|
|
delete mapDecal; |
|
|
|
|
|
|
|
fElapsedTime = std::min(0.01667f, fElapsedTime); |
|
|
|
fElapsedTime = std::min(0.01667f, fElapsedTime); |
|
|
|
gameTimer += fElapsedTime; |
|
|
|
gameTimer += fElapsedTime; |
|
|
|
switch (mode) { |
|
|
|
switch (mode) { |
|
|
@ -2217,6 +2252,7 @@ bool FaceBall::OnUserUpdate(float fElapsedTime) |
|
|
|
!CheckPlayerCollision({0,0,0},{e.pos.x,e.pos.z},e.radius*6)){ |
|
|
|
!CheckPlayerCollision({0,0,0},{e.pos.x,e.pos.z},e.radius*6)){ |
|
|
|
enemies.push_back(e); |
|
|
|
enemies.push_back(e); |
|
|
|
wave2Enemies.erase(wave2Enemies.begin()+i); |
|
|
|
wave2Enemies.erase(wave2Enemies.begin()+i); |
|
|
|
|
|
|
|
RegenerateMinimap(); |
|
|
|
goto spawningDone; |
|
|
|
goto spawningDone; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -2228,6 +2264,7 @@ bool FaceBall::OnUserUpdate(float fElapsedTime) |
|
|
|
!CheckPlayerCollision({0,0,0},{e.pos.x,e.pos.z},e.radius*6)){ |
|
|
|
!CheckPlayerCollision({0,0,0},{e.pos.x,e.pos.z},e.radius*6)){ |
|
|
|
enemies.push_back(e); |
|
|
|
enemies.push_back(e); |
|
|
|
wave3Enemies.erase(wave3Enemies.begin()+i); |
|
|
|
wave3Enemies.erase(wave3Enemies.begin()+i); |
|
|
|
|
|
|
|
RegenerateMinimap(); |
|
|
|
goto spawningDone; |
|
|
|
goto spawningDone; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -2243,6 +2280,7 @@ bool FaceBall::OnUserUpdate(float fElapsedTime) |
|
|
|
!CheckPlayerCollision({0,0,0},{e.pos.x,e.pos.z},e.radius*6)){ |
|
|
|
!CheckPlayerCollision({0,0,0},{e.pos.x,e.pos.z},e.radius*6)){ |
|
|
|
enemies.push_back(e); |
|
|
|
enemies.push_back(e); |
|
|
|
wave2Enemies.erase(wave2Enemies.begin()+i); |
|
|
|
wave2Enemies.erase(wave2Enemies.begin()+i); |
|
|
|
|
|
|
|
RegenerateMinimap(); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -2309,6 +2347,7 @@ bool FaceBall::OnUserUpdate(float fElapsedTime) |
|
|
|
}break; |
|
|
|
}break; |
|
|
|
case PowerupType::MAP: { |
|
|
|
case PowerupType::MAP: { |
|
|
|
hasMapUpgrade = true; |
|
|
|
hasMapUpgrade = true; |
|
|
|
|
|
|
|
RegenerateMinimap(); |
|
|
|
}break; |
|
|
|
}break; |
|
|
|
case PowerupType::COIN: { |
|
|
|
case PowerupType::COIN: { |
|
|
|
AddScore(1000); |
|
|
|
AddScore(1000); |
|
|
|