ALOT, titlescreen, sound, enemies

This commit is contained in:
Ben
2020-09-06 07:32:55 +01:00
parent 8198922b43
commit 8a0afcb605
22 changed files with 306 additions and 90 deletions

View File

@@ -29,67 +29,125 @@ class Game : public olc::PixelGameEngine
for (int i = 0; i < 5; i++)
CreateLayer();
return true;
SetDrawTarget(uint8_t(0));
Clear(olc::BLANK);
return true;
}
void DisplayTitle(float fTime)
{
if (m_TimeAccumilator > 2.0f)
{
m_DeltaFade -= fTime * 200.0f;
if (m_DeltaFade < 0.1f) m_DeltaFade = 0.0f;
}
DrawString((ScreenWidth() / 2) - (7 * 7) * (std::string("The Great Machine").length() / 2), ScreenHeight() / 2, "The Great Machine", olc::Pixel(255, 255, 255, static_cast<int>(m_DeltaFade)), 6);
DrawString(5, ScreenHeight() - 15, "Powered by the OLC Pixel Game Engine", olc::Pixel(255, 255, 255, static_cast<int>(m_DeltaFade)));
DrawString(ScreenWidth() - (8 * (std::string("Copyright Benjamin Kyd 2020").length())) - 5, ScreenHeight() - 15, "Copyright Benjamin Kyd 2020", olc::Pixel(255, 255, 255, static_cast<int>(m_DeltaFade)));
DrawString((ScreenWidth() / 2) - (7 * 7) * (std::string("The Great Machine").length() / 2), ScreenHeight() / 2, "The Great Machine", olc::Pixel(255, 255, 255, static_cast<int>(_DeltaFade)), 6);
DrawString(5, ScreenHeight() - 15, "Powered by the OLC Pixel Game Engine", olc::Pixel(255, 255, 255, static_cast<int>(_DeltaFade)));
DrawString(ScreenWidth() - (8 * (std::string("Copyright Benjamin Kyd 2020").length())) - 5, ScreenHeight() - 15, "Copyright Benjamin Kyd 2020", olc::Pixel(255, 255, 255, static_cast<int>(_DeltaFade)));
}
bool OnUserUpdate(float fTime) override
{
m_TimeAccumilator += fTime;
_TimeAccumilator += fTime;
Clear({38, 36, 40});
// _Logger.Debug(m_TimeAccumilator);
//if (m_TimeAccumilator < 4.0f)
//{
//DisplayTitle(fTime);
//return true;
//}
SetDrawTarget(uint8_t(0));
Clear(olc::BLANK);
goto bruh;
if (_TimeAccumilator < 6.0f)
{
Clear({38, 36, 40});
if (_TimeAccumilator > 4.0f)
{
_DeltaFade -= fTime * 200.0f;
if (_DeltaFade < 0.1f) _DeltaFade = 0.0f;
}
DisplayTitle(fTime);
return true;
}
static bool IsFlicker = false;
if (_TimeAccumilator > 10.0f && _TimeAccumilator < 27.0f)
{
if (rand() % 60 < 1)
IsFlicker = true;
if (rand() % 20 < 1)
IsFlicker = false;
if (IsFlicker)
_Dungeon->IsLightOn = true;
else
_Dungeon->IsLightOn = false;
if (_TimeAccumilator > 13.0f)
{
_Dungeon->IsLightOn = false;
if (_TimeAccumilator > 26.0f)
{
_DeltaFade1 -= fTime * 200.0f;
if (_DeltaFade1 < 0.1f) _DeltaFade1 = 0.0f;
}
SetPixelMode(olc::Pixel::ALPHA);
if (_TimeAccumilator > 16.0f)
DrawString((ScreenWidth() / 2) - (7 * 3) * (std::string("the machine has done nothing for me").length() / 2), 40, "the machine has done nothing for me", olc::Pixel(255, 255, 255, static_cast<int>(_DeltaFade1)), 3);
if (_TimeAccumilator > 20.0f)
DrawString((ScreenWidth() / 2) - (7 * 3) * (std::string("the machine has left me with nothing").length() / 2), 120, "the machine has left me with nothing", olc::Pixel(255, 255, 255, static_cast<int>(_DeltaFade1)), 3);
if (_TimeAccumilator > 23.0f)
DrawString((ScreenWidth() / 2) - (7 * 5) * (std::string("i am nothing").length() / 2), 300, "i am nothing", olc::Pixel(255, 255, 255, static_cast<int>(_DeltaFade1)), 5);
}
}
if (_TimeAccumilator > 26.0f)
{
_Dungeon->IsFireLit = true;
}
bruh:
_Dungeon->Input(this, fTime);
_Dungeon->Update(this, fTime);
_Dungeon->Update(this, fTime);
_Dungeon->Draw(this, fTime);
_Dungeon->Draw(this, fTime);
for (int i = 0; i < 5; i++)
EnableLayer(i, true);
return true;
return true;
}
bool OnUserDestroy() override
{
delete _Dungeon;
return true;
}
private:
long float m_TimeAccumilator = 0;
float m_DeltaFade = 255.0f;
long float _TimeAccumilator = 0.0f;
float _DeltaFade = 255.0f;
float _DeltaFade1 = 255.0f;
};
#include <SFML/Audio.hpp>
int main()
{
Logger& _Logger = Logger::getInstance();
_Logger.InitializeFileLogging("./logs.log");
_Logger.InitializeLoggingThread();
_Logger.Debug("Initializing");
Game _Game;
_Game.Construct(1280, 720, 1, 1, false, false);
_Logger.Info("Game Constructed");
if (!_Game.Start())
{
_Logger.Panic("PGE Cannot start");
}
Game _Game;
_Game.Construct(1280, 720, 1, 1, false, false);
_Logger.Info("Game Constructed");
if (!_Game.Start())
{
_Logger.Panic("PGE Cannot start");
}
_Logger.~Logger();
}