TechDemo/Levels/MainMenu.cpp
2024-02-20 23:07:28 -08:00

61 lines
1.3 KiB
C++

#include "MainMenu.h"
#include <lwe/RenderWindow.h>
#include <lwe/GameLoop.h>
#include <lwe/Entity.h>
#include <lwe/gpu/GpuMesh.h>
#include <lwe/gpu/GpuFontAtlas.h>
#include <lwe/systems/CameraSystem.h>
#include <lwe/systems/RigidBodySystem.h>
#include <lwe/systems/GuiSystem.h>
#include <lwe/coms/Camera.h>
#include "TestLevel.h"
MainMenu::MainMenu(const ehs::Str_8& id)
: Level(id)
{
}
void MainMenu::SetupResources(lwe::GpuInterface* inf)
{
Level::SetupResources(inf);
}
void MainMenu::Setup(lwe::GpuInterface* inf)
{
Level::Setup(inf);
AddSystem(new lwe::CameraSystem());
AddSystem(new lwe::RigidBodySystem());
AddSystem(new lwe::GuiSystem());
lwe::Entity cam("Camera");
lwe::Camera* com = new lwe::Camera("Main");
cam.AddComponent(com);
AddEntity((lwe::Entity&&)cam);
}
void MainMenu::PostInitialize(lwe::GpuCmdBuffer* cmdBuffer)
{
Level::PostInitialize(cmdBuffer);
}
void MainMenu::OnUpdate(lwe::RenderWindow* win, ehs::Input* input, const float delta)
{
Level::OnUpdate(win, input, delta);
ehs::Vec2_f client = win->GetScale();
lwe::Entity* sp = GetEntity("SinglePlayer");
if (sp)
sp->SetPos({client.x * 0.5f - sp->GetScale().x * 0.5f, sp->GetPos().y, 0.0f});
lwe::Entity* mp = GetEntity("MultiPlayer");
if (mp)
mp->SetPos({client.x * 0.5f - mp->GetScale().x * 0.5f, mp->GetPos().y, 0.0f});
}