|
|
@ -849,6 +849,10 @@ void FaceBall::HandleKeys(float fElapsedTime) { |
|
|
|
vec3d zMovement{ 0,0,vForward.z }; |
|
|
|
vec3d zMovement{ 0,0,vForward.z }; |
|
|
|
player.UpdatePos(Vector_Add(player.GetPos(), zMovement)); |
|
|
|
player.UpdatePos(Vector_Add(player.GetPos(), zMovement)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
float distanceToExit = std::sqrtf(std::powf(player.GetPos().x - exit.pos.x, 2) + std::powf(player.GetPos().z - exit.pos.z, 2)); |
|
|
|
|
|
|
|
if (distanceToExit < player.GetRadius() + exit.radius) { |
|
|
|
|
|
|
|
mode = LEVELCOMPLETE; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (GetKey(S).bHeld) { |
|
|
|
if (GetKey(S).bHeld) { |
|
|
@ -990,6 +994,22 @@ bool Bullet::Update(float fElapsedTime) { |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void FaceBall::RenderHud(float fElapsedTime) { |
|
|
|
|
|
|
|
if (!GetKey(olc::D).bHeld && !GetKey(olc::A).bHeld) { |
|
|
|
|
|
|
|
hudOffsetAcc += 20 * fElapsedTime; |
|
|
|
|
|
|
|
while (hudOffsetAcc >= 1) { |
|
|
|
|
|
|
|
hudOffset /= 2; |
|
|
|
|
|
|
|
hudOffsetAcc--; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
SetDecalMode(DecalMode::NORMAL); |
|
|
|
|
|
|
|
DrawDecal({ -32 + hudOffset,-18 }, hud, { 1.05,1.05 }); |
|
|
|
|
|
|
|
DrawStringDecal({ 112 + hudOffset,4 }, "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 }); |
|
|
|
|
|
|
|
FillRectDecal({ 0,0 }, vf2d{ (float)ScreenWidth(),(float)ScreenHeight() }, { (uint8_t)0,(uint8_t)0,(uint8_t)0,(uint8_t)screenAlpha }); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void FaceBall::SubtractTag() { |
|
|
|
void FaceBall::SubtractTag() { |
|
|
|
tagsRemaining = std::max(0, tagsRemaining - 1); |
|
|
|
tagsRemaining = std::max(0, tagsRemaining - 1); |
|
|
|
if (!exitWallsCleared&&tagsRemaining <= 0) { |
|
|
|
if (!exitWallsCleared&&tagsRemaining <= 0) { |
|
|
@ -1132,22 +1152,21 @@ bool FaceBall::OnUserUpdate(float fElapsedTime) |
|
|
|
case GAME: { |
|
|
|
case GAME: { |
|
|
|
HandleKeys(fElapsedTime); |
|
|
|
HandleKeys(fElapsedTime); |
|
|
|
RenderWorld(); |
|
|
|
RenderWorld(); |
|
|
|
if (!GetKey(olc::D).bHeld && !GetKey(olc::A).bHeld) { |
|
|
|
RenderHud(fElapsedTime); |
|
|
|
hudOffsetAcc += 20 * fElapsedTime; |
|
|
|
|
|
|
|
while (hudOffsetAcc >= 1) { |
|
|
|
|
|
|
|
hudOffset /= 2; |
|
|
|
|
|
|
|
hudOffsetAcc--; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
SetDecalMode(DecalMode::NORMAL); |
|
|
|
|
|
|
|
DrawDecal({ -32+hudOffset,-18 }, hud, {1.05,1.05}); |
|
|
|
|
|
|
|
DrawStringDecal({ 112+hudOffset,4 }, "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}); |
|
|
|
|
|
|
|
}break; |
|
|
|
}break; |
|
|
|
case EDITOR: { |
|
|
|
case EDITOR: { |
|
|
|
editor.Update(fElapsedTime); |
|
|
|
editor.Update(fElapsedTime); |
|
|
|
}break; |
|
|
|
}break; |
|
|
|
|
|
|
|
case LEVELCOMPLETE: { |
|
|
|
|
|
|
|
RenderWorld(); |
|
|
|
|
|
|
|
RenderHud(fElapsedTime); |
|
|
|
|
|
|
|
if (screenAlpha < 255) { |
|
|
|
|
|
|
|
screenAlpha = std::min(255.f,screenAlpha+200 * fElapsedTime); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
DrawStringDecal({ 16,16 }, "Level " + std::to_string(level) + " complete!", WHITE, { 4,8 }); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}break; |
|
|
|
} |
|
|
|
} |
|
|
|
if (GetKey(olc::F5).bPressed) { |
|
|
|
if (GetKey(olc::F5).bPressed) { |
|
|
|
mode = (GAMEMODE)!(mode&1); |
|
|
|
mode = (GAMEMODE)!(mode&1); |
|
|
|