TechDemo/Levels/MainMenu.cpp

61 lines
1.3 KiB
C++
Raw Normal View History

2023-11-14 00:32:05 -08:00
#include "MainMenu.h"
#include <LWE/IO/RenderWindow.h>
#include <LWE/GameLoop.h>
#include <LWE/Entity.h>
#include <LWE/IO/Model/Mesh.h>
#include <LWE/IO/FontAtlas.h>
#include <LWE/Systems/CameraSystem.h>
#include <LWE/Systems/RigidBodySystem.h>
#include <LWE/Systems/GuiSystem.h>
#include <LWE/Components/Camera.h>
#include "TestLevel.h"
MainMenu::MainMenu(const lwe::Str_8& id)
: Level(id)
{
}
void MainMenu::SetupResources()
{
Level::SetupResources();
}
void MainMenu::Setup()
{
Level::Setup();
AddSystem(new lwe::CameraSystem());
AddSystem(new lwe::RigidBodySystem());
AddSystem(new lwe::GuiSystem());
lwe::Entity* cam = new lwe::Entity("Camera");
lwe::Camera* com = new lwe::Camera("Main");
cam->AddComponent(com);
AddEntity(cam);
}
void MainMenu::PostInitialize(lwe::GpuCmdBuffer* cmdBuffer)
{
Level::PostInitialize(cmdBuffer);
}
2023-12-05 16:02:42 -08:00
void MainMenu::OnUpdate(lwe::RenderWindow* win, lwe::Input* input, const float delta)
2023-11-14 00:32:05 -08:00
{
2023-12-05 16:02:42 -08:00
Level::OnUpdate(win, input, delta);
2023-11-14 00:32:05 -08:00
lwe::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});
}