2023-11-14 00:32:05 -08:00
|
|
|
#include "MainMenu.h"
|
|
|
|
|
2024-01-26 09:01:01 -08:00
|
|
|
#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>
|
2023-11-14 00:32:05 -08:00
|
|
|
|
|
|
|
#include "TestLevel.h"
|
|
|
|
|
2024-01-26 09:01:01 -08:00
|
|
|
MainMenu::MainMenu(const ehs::Str_8& id)
|
2023-11-14 00:32:05 -08:00
|
|
|
: Level(id)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2024-01-26 09:01:01 -08:00
|
|
|
void MainMenu::SetupResources(lwe::GpuInterface* inf)
|
2023-11-14 00:32:05 -08:00
|
|
|
{
|
2024-01-26 09:01:01 -08:00
|
|
|
Level::SetupResources(inf);
|
2023-11-14 00:32:05 -08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainMenu::Setup()
|
|
|
|
{
|
|
|
|
Level::Setup();
|
|
|
|
|
|
|
|
AddSystem(new lwe::CameraSystem());
|
|
|
|
AddSystem(new lwe::RigidBodySystem());
|
|
|
|
AddSystem(new lwe::GuiSystem());
|
|
|
|
|
2024-01-26 09:01:01 -08:00
|
|
|
lwe::Entity cam("Camera");
|
2023-11-14 00:32:05 -08:00
|
|
|
|
|
|
|
lwe::Camera* com = new lwe::Camera("Main");
|
2024-01-26 09:01:01 -08:00
|
|
|
cam.AddComponent(com);
|
2023-11-14 00:32:05 -08:00
|
|
|
|
2024-01-26 09:01:01 -08:00
|
|
|
AddEntity((lwe::Entity&&)cam);
|
2023-11-14 00:32:05 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainMenu::PostInitialize(lwe::GpuCmdBuffer* cmdBuffer)
|
|
|
|
{
|
|
|
|
Level::PostInitialize(cmdBuffer);
|
|
|
|
}
|
|
|
|
|
2024-01-26 09:01:01 -08:00
|
|
|
void MainMenu::OnUpdate(lwe::RenderWindow* win, ehs::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
|
|
|
|
2024-01-26 09:01:01 -08:00
|
|
|
ehs::Vec2_f client = win->GetScale();
|
2023-11-14 00:32:05 -08:00
|
|
|
|
|
|
|
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});
|
|
|
|
}
|