|
|
|
@@ -1,62 +1,63 @@
|
|
|
|
|
#include "TestLevel.h"
|
|
|
|
|
|
|
|
|
|
#include <LWE/GarbageCollector.h>
|
|
|
|
|
#include <LWE/IO/Console.h>
|
|
|
|
|
#include <LWE/IO/File.h>
|
|
|
|
|
#include <LWE/IO/Socket/DNS.h>
|
|
|
|
|
#include <LWE/Json/Json.h>
|
|
|
|
|
#include <LWE/GameLoop.h>
|
|
|
|
|
#include <LWE/IO/RenderWindow.h>
|
|
|
|
|
#include <LWE/IO/Image/Img.h>
|
|
|
|
|
#include <LWE/IO/Model/Model.h>
|
|
|
|
|
#include <LWE/IO/FontAtlas.h>
|
|
|
|
|
#include <LWE/IO/CubeMap.h>
|
|
|
|
|
#include <LWE/IO/Audio/Audio.h>
|
|
|
|
|
#include <LWE/Systems/TimerSystem.h>
|
|
|
|
|
#include <LWE/Systems/GuiSystem.h>
|
|
|
|
|
#include <LWE/Systems/RigidBodySystem.h>
|
|
|
|
|
#include <LWE/Systems/GuiSystem.h>
|
|
|
|
|
#include <LWE/Systems/AudioSystem.h>
|
|
|
|
|
#include <LWE/Systems/CameraSystem.h>
|
|
|
|
|
#include <LWE/Systems/SkyboxSystem.h>
|
|
|
|
|
#include <LWE/Systems/LightSystem.h>
|
|
|
|
|
#include <LWE/Systems/SolidColorSystem.h>
|
|
|
|
|
#include <LWE/Systems/NetSystem.h>
|
|
|
|
|
#include <LWE/Systems/PhongSystem.h>
|
|
|
|
|
#include <LWE/Components/Camera.h>
|
|
|
|
|
#include <LWE/Components/PlyController.h>
|
|
|
|
|
#include <LWE/Components/Skybox.h>
|
|
|
|
|
#include <LWE/Components/AmbientPointLight.h>
|
|
|
|
|
#include <LWE/Components/PointLight.h>
|
|
|
|
|
#include <LWE/Components/SolidColor.h>
|
|
|
|
|
#include <LWE/Components/Phong.h>
|
|
|
|
|
#include "LWE/Timer.h"
|
|
|
|
|
#include <LWE/Components/AudioSource3D.h>
|
|
|
|
|
#include <LWE/Components/AABB2D.h>
|
|
|
|
|
#include <LWE/Components/Circle.h>
|
|
|
|
|
#include <LWE/Components/OBB3D.h>
|
|
|
|
|
#include <LWE/Components/Projectile.h>
|
|
|
|
|
#include <LWE/Components/Health.h>
|
|
|
|
|
#include <LWE/Components/Networked.h>
|
|
|
|
|
#include <LWE/Gui/LabelGui.h>
|
|
|
|
|
#include <LWE/Gui/SolidBoxGui.h>
|
|
|
|
|
#include <LWE/Gui/ButtonGui.h>
|
|
|
|
|
#include <LWE/Gui/CheckBoxGui.h>
|
|
|
|
|
#include <LWE/Gui/TextFieldGui.h>
|
|
|
|
|
#include <LWE/Gui/ImgGui.h>
|
|
|
|
|
#include <LWE/Gui/PanelGui.h>
|
|
|
|
|
#include <LWE/Gui/CollectionGui.h>
|
|
|
|
|
#include <LWE/Systems/BillboardSystem.h>
|
|
|
|
|
#include <LWE/Components/Billboard.h>
|
|
|
|
|
#include <LWE/IO/HID/Keyboard.h>
|
|
|
|
|
#include <LWE/IO/HID/Mouse.h>
|
|
|
|
|
#include <ehs/GarbageCollector.h>
|
|
|
|
|
#include <ehs/io/Console.h>
|
|
|
|
|
#include <ehs/io/File.h>
|
|
|
|
|
#include <ehs/io/socket/DNS.h>
|
|
|
|
|
#include <ehs/io/audio/Audio.h>
|
|
|
|
|
#include <ehs/io/hid/Keyboard.h>
|
|
|
|
|
#include <ehs/io/hid/Mouse.h>
|
|
|
|
|
|
|
|
|
|
#include <lwe/GameLoop.h>
|
|
|
|
|
#include <lwe/RenderWindow.h>
|
|
|
|
|
#include <lwe/gpu/GpuModel.h>
|
|
|
|
|
#include <lwe/gpu/GpuFontAtlas.h>
|
|
|
|
|
#include <lwe/gpu/GpuImg.h>
|
|
|
|
|
#include <lwe/gpu/GpuCubeMap.h>
|
|
|
|
|
#include <lwe/systems/TimerSystem.h>
|
|
|
|
|
#include <lwe/systems/GuiSystem.h>
|
|
|
|
|
#include <lwe/systems/RigidBodySystem.h>
|
|
|
|
|
#include <lwe/systems/GuiSystem.h>
|
|
|
|
|
#include <lwe/systems/AudioSystem.h>
|
|
|
|
|
#include <lwe/systems/CameraSystem.h>
|
|
|
|
|
#include <lwe/systems/SkyboxSystem.h>
|
|
|
|
|
#include <lwe/systems/LightSystem.h>
|
|
|
|
|
#include <lwe/systems/SolidColorSystem.h>
|
|
|
|
|
#include <lwe/systems/NetSystem.h>
|
|
|
|
|
#include <lwe/systems/PhongSystem.h>
|
|
|
|
|
#include <lwe/coms/Camera.h>
|
|
|
|
|
#include <lwe/coms/PlyController.h>
|
|
|
|
|
#include <lwe/coms/Skybox.h>
|
|
|
|
|
#include <lwe/coms/AmbientPointLight.h>
|
|
|
|
|
#include <lwe/coms/PointLight.h>
|
|
|
|
|
#include <lwe/coms/SolidColor.h>
|
|
|
|
|
#include <lwe/coms/Phong.h>
|
|
|
|
|
#include "lwe/Timer.h"
|
|
|
|
|
#include <lwe/coms/AudioSource3D.h>
|
|
|
|
|
#include <lwe/coms/AABB2D.h>
|
|
|
|
|
#include <lwe/coms/Circle.h>
|
|
|
|
|
#include <lwe/coms/OBB3D.h>
|
|
|
|
|
#include <lwe/coms/Projectile.h>
|
|
|
|
|
#include <lwe/coms/Health.h>
|
|
|
|
|
#include <lwe/coms/Networked.h>
|
|
|
|
|
#include <lwe/gui/LabelGui.h>
|
|
|
|
|
#include <lwe/gui/SolidBoxGui.h>
|
|
|
|
|
#include <lwe/gui/ButtonGui.h>
|
|
|
|
|
#include <lwe/gui/CheckBoxGui.h>
|
|
|
|
|
#include <lwe/gui/TextFieldGui.h>
|
|
|
|
|
#include <lwe/gui/ImgGui.h>
|
|
|
|
|
#include <lwe/gui/PanelGui.h>
|
|
|
|
|
#include <lwe/gui/CollectionGui.h>
|
|
|
|
|
#include <lwe/gui/WindowGui.h>
|
|
|
|
|
#include <lwe/systems/BillboardSystem.h>
|
|
|
|
|
#include <lwe/coms/Billboard.h>
|
|
|
|
|
|
|
|
|
|
TestLevel::TestLevel()
|
|
|
|
|
: count(0), cooldown(0.0f)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TestLevel::TestLevel(const lwe::Str_8& id)
|
|
|
|
|
TestLevel::TestLevel(const ehs::Str_8& id)
|
|
|
|
|
: Level(id), count(0), cooldown(0.0f)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
@@ -79,30 +80,30 @@ TestLevel& TestLevel::operator=(const TestLevel& level)
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TestLevel::SetupResources()
|
|
|
|
|
void TestLevel::SetupResources(lwe::GpuInterface* inf)
|
|
|
|
|
{
|
|
|
|
|
lwe::FontAtlas* arial_24 = new lwe::FontAtlas("Resources/Fonts/Arial_24.ehf");
|
|
|
|
|
lwe::GpuFontAtlas* arial_24 = new lwe::GpuFontAtlas("resources/fonts/Arial_24.ehf", inf);
|
|
|
|
|
AddResource(arial_24);
|
|
|
|
|
|
|
|
|
|
lwe::Model* vampire = new lwe::Model("Resources/Models/Vampire.ehm");
|
|
|
|
|
vampire->Calculate();
|
|
|
|
|
lwe::GpuModel* vampire = new lwe::GpuModel("resources/models/Vampire.ehm", inf);
|
|
|
|
|
//vampire->Calculate();
|
|
|
|
|
AddResource(vampire);
|
|
|
|
|
AddResource(lwe::Img::FromFile_Heap("Resources/Textures/Character_Diffuse.png", lwe::IMG_ASPECT_COLOR));
|
|
|
|
|
AddResource(lwe::Img::FromFile_Heap("Resources/Textures/Character_Normal.png", lwe::IMG_ASPECT_COLOR));
|
|
|
|
|
AddResource(lwe::Img::FromFile_Heap("Resources/Textures/Character_Specular.png", lwe::IMG_ASPECT_COLOR));
|
|
|
|
|
AddResource(new lwe::GpuImg("resources/textures/Character_Diffuse.png", inf, lwe::IMG_ASPECT_COLOR));
|
|
|
|
|
AddResource(new lwe::GpuImg("resources/textures/Character_Normal.png", inf, lwe::IMG_ASPECT_COLOR));
|
|
|
|
|
AddResource(new lwe::GpuImg("Resources/Textures/Character_Specular.png", inf, lwe::IMG_ASPECT_COLOR));
|
|
|
|
|
|
|
|
|
|
lwe::Mesh* portrait = new lwe::Mesh("Portrait", lwe::portraitVerts, lwe::portraitIndices);
|
|
|
|
|
lwe::GpuMesh* portrait = new lwe::GpuMesh(inf, ehs::portrait);
|
|
|
|
|
//portrait->Calculate();
|
|
|
|
|
AddResource(portrait);
|
|
|
|
|
|
|
|
|
|
lwe::Mesh* portraitGUI = new lwe::Mesh("PortraitGUI", lwe::portraitGuiVerts, lwe::portraitGuiIndices);
|
|
|
|
|
lwe::GpuMesh* portraitGUI = new lwe::GpuMesh(inf, ehs::portraitGui);
|
|
|
|
|
AddResource(portraitGUI);
|
|
|
|
|
|
|
|
|
|
AddResource(new lwe::Model("Resources/Models/Cube.ehm"));
|
|
|
|
|
AddResource(new lwe::Model("Resources/Models/Sphere.ehm"));
|
|
|
|
|
AddResource(new lwe::Model("Resources/Models/PointLight.ehm"));
|
|
|
|
|
AddResource(new lwe::GpuModel("Resources/Models/Cube.ehm", inf));
|
|
|
|
|
AddResource(new lwe::GpuModel("Resources/Models/Sphere.ehm", inf));
|
|
|
|
|
AddResource(new lwe::GpuModel("Resources/Models/PointLight.ehm", inf));
|
|
|
|
|
|
|
|
|
|
lwe::CubeMap* cm = new lwe::CubeMap("Resources/Textures/Skybox", "Skybox");
|
|
|
|
|
lwe::GpuCubeMap* cm = new lwe::GpuCubeMap(inf, "Resources/Textures/Skybox", "Skybox");
|
|
|
|
|
AddResource(cm);
|
|
|
|
|
|
|
|
|
|
AddResource(lwe::Audio::FromFile_Heap("Resources/Audio/sample.wav", lwe::DataType::FLOAT));
|
|
|
|
@@ -235,7 +236,7 @@ void TestLevel::Setup()
|
|
|
|
|
lwe::CollectionGui* stats = new lwe::CollectionGui("Stats");
|
|
|
|
|
stats->SetScale({250.0f, 127.0f});
|
|
|
|
|
|
|
|
|
|
stats->AddResource(new lwe::FontAtlas("Resources/Fonts/Arial_24.ehf"));
|
|
|
|
|
stats->AddResource(new lwe::GpuFontAtlas("resources/fonts/Arial_24.ehf", inf));
|
|
|
|
|
|
|
|
|
|
lwe::SolidBoxGui* bckgrd = new lwe::SolidBoxGui("Background");
|
|
|
|
|
bckgrd->SetScale({250.0f, 127.0f});
|
|
|
|
@@ -248,31 +249,31 @@ void TestLevel::Setup()
|
|
|
|
|
|
|
|
|
|
lwe::LabelGui* deltaTime = new lwe::LabelGui("DeltaTime", "Arial_24", "Delta Time: 0");
|
|
|
|
|
deltaTime->SetColor({1.0f});
|
|
|
|
|
deltaTime->SetPosition({0.0f, 24.0f});
|
|
|
|
|
deltaTime->SetPosition({0.0f, 24.0f, 0.0f});
|
|
|
|
|
stats->AddChild(deltaTime);
|
|
|
|
|
|
|
|
|
|
lwe::LabelGui* gbg = new lwe::LabelGui("Garbage", "Arial_24", "Garbage: 0");
|
|
|
|
|
gbg->SetColor({1.0f});
|
|
|
|
|
gbg->SetPosition({0.0f, 48.0f});
|
|
|
|
|
gbg->SetPosition({0.0f, 48.0f, 0.0f});
|
|
|
|
|
stats->AddChild(gbg);
|
|
|
|
|
|
|
|
|
|
lwe::LabelGui* playback = new lwe::LabelGui("Playback", "Arial_24", "Playback: 0:0 / 0:0");
|
|
|
|
|
playback->SetColor({1.0f});
|
|
|
|
|
playback->SetPosition({0.0f, 72.0f});
|
|
|
|
|
playback->SetPosition({0.0f, 72.0f, 0.0f});
|
|
|
|
|
stats->AddChild(playback);
|
|
|
|
|
|
|
|
|
|
lwe::LabelGui* volume = new lwe::LabelGui("Volume", "Arial_24", "Volume: 0");
|
|
|
|
|
volume->SetColor({1.0f});
|
|
|
|
|
volume->SetPosition({0.0f, 96.0f});
|
|
|
|
|
volume->SetPosition({0.0f, 96.0f, 0.0f});
|
|
|
|
|
stats->AddChild(volume);
|
|
|
|
|
|
|
|
|
|
guiSys->AddGui(stats);
|
|
|
|
|
|
|
|
|
|
lwe::Serializer<lwe::UInt_64> args(lwe::Endianness::LE);
|
|
|
|
|
ehs::Serializer<ehs::UInt_64> args(ehs::Endianness::LE);
|
|
|
|
|
args.Write(stats);
|
|
|
|
|
args.SetOffset(0);
|
|
|
|
|
|
|
|
|
|
timerSys->Add({0, 1.0f, args, [](lwe::Timer* timer, lwe::Serializer<lwe::UInt_64>& args)
|
|
|
|
|
timerSys->Add({0, 1.0f, args, [](lwe::Timer* timer, ehs::Serializer<ehs::UInt_64>& args)
|
|
|
|
|
{
|
|
|
|
|
lwe::GameLoop* gl = (lwe::GameLoop*)timer->GetParent("GameLoop");
|
|
|
|
|
|
|
|
|
@@ -280,16 +281,23 @@ void TestLevel::Setup()
|
|
|
|
|
args.SetOffset(0);
|
|
|
|
|
|
|
|
|
|
lwe::LabelGui* deltaTime = (lwe::LabelGui*)stats->GetChild("DeltaTime");
|
|
|
|
|
deltaTime->SetText("Delta Time: " + lwe::Str_8::FromNum(gl->GetRawDeltaTime()));
|
|
|
|
|
deltaTime->SetText("Delta Time: " + ehs::Str_8::FromNum(gl->GetRawDeltaTime()));
|
|
|
|
|
|
|
|
|
|
lwe::LabelGui* gbg = (lwe::LabelGui*)stats->GetChild("Garbage");
|
|
|
|
|
gbg->SetText("Garbage: " + lwe::Str_8::FromNum(lwe::GarbageCollector::Size()));
|
|
|
|
|
gbg->SetText("Garbage: " + ehs::Str_8::FromNum(ehs::GarbageCollector::Size()));
|
|
|
|
|
}});
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
lwe::PanelGui* testPanel = new lwe::PanelGui("TestPanel");
|
|
|
|
|
testPanel->SetPosition({300.0f, 200.0f});
|
|
|
|
|
testPanel->SetPosition({300.0f, 200.0f, 0.0f});
|
|
|
|
|
testPanel->SetScale({400.0f, 400.0f});
|
|
|
|
|
guiSys->AddGui(testPanel);
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
lwe::WindowGui* testWin = new lwe::WindowGui("TestWindow", "Hello world!");
|
|
|
|
|
testWin->SetPosition({300.0f, 200.0f, 0.0f});
|
|
|
|
|
testWin->SetScale({400.0f, 400.0f});
|
|
|
|
|
guiSys->AddGui(testWin);
|
|
|
|
|
|
|
|
|
|
lwe::Entity* player = new lwe::Entity("Player");
|
|
|
|
|
|
|
|
|
@@ -304,7 +312,7 @@ void TestLevel::Setup()
|
|
|
|
|
plyMdl->SetPos({0.0f, 0.0f, -0.5f});
|
|
|
|
|
//player->AddComponent(plyMdl);
|
|
|
|
|
|
|
|
|
|
AddTemplate(player);
|
|
|
|
|
AddTemplate((lwe::Entity&&)player);
|
|
|
|
|
|
|
|
|
|
lwe::Entity* plyPuppet = new lwe::Entity("Puppet");
|
|
|
|
|
plyPuppet->AddComponent(new lwe::OBB3D("Head", 1.0f, 1.0f));
|
|
|
|
@@ -317,7 +325,7 @@ void TestLevel::Setup()
|
|
|
|
|
puppetMdl->SetPos({0.0f, 0.0f, -0.5f});
|
|
|
|
|
//plyPuppet->AddComponent(puppetMdl);
|
|
|
|
|
|
|
|
|
|
AddTemplate(plyPuppet);
|
|
|
|
|
AddTemplate((lwe::Entity&&)plyPuppet);
|
|
|
|
|
|
|
|
|
|
CreateEntity(player->GetHashId(), "Player");
|
|
|
|
|
|
|
|
|
@@ -326,7 +334,7 @@ void TestLevel::Setup()
|
|
|
|
|
lwe::Skybox* skybox = new lwe::Skybox("Skybox", "Skybox");
|
|
|
|
|
skyboxEnt->AddComponent(skybox);
|
|
|
|
|
|
|
|
|
|
AddEntity(skyboxEnt);
|
|
|
|
|
AddEntity((lwe::Entity&&)skyboxEnt);
|
|
|
|
|
|
|
|
|
|
lwe::Entity* ent = new lwe::Entity("Main");
|
|
|
|
|
ent->SetScale({0.25f, 0.25f, 0.25f});
|
|
|
|
@@ -350,11 +358,11 @@ void TestLevel::Setup()
|
|
|
|
|
entCollider->SetPos({0.0f, 1.1f, 0.0f});
|
|
|
|
|
entCollider->SetCollidedCb([](lwe::RigidBody* a, lwe::RigidBody* b)
|
|
|
|
|
{
|
|
|
|
|
lwe::Entity* aOwner = (lwe::Entity*)a->GetParent();
|
|
|
|
|
lwe::Entity* aOwner = a->GetEntity();
|
|
|
|
|
lwe::Health* health = (lwe::Health*)aOwner->GetComponent("Health");
|
|
|
|
|
health->TakeDamage(10);
|
|
|
|
|
|
|
|
|
|
lwe::Entity* bOwner = (lwe::Entity*)b->GetParent();
|
|
|
|
|
lwe::Entity* bOwner = b->GetEntity();
|
|
|
|
|
bOwner->Delete();
|
|
|
|
|
|
|
|
|
|
if (health->GetHealth() <= 0)
|
|
|
|
@@ -372,16 +380,16 @@ void TestLevel::Setup()
|
|
|
|
|
ph->SetAnimation("Test");
|
|
|
|
|
ent->AddComponent(ph);
|
|
|
|
|
|
|
|
|
|
AddEntity(ent);
|
|
|
|
|
AddEntity((lwe::Entity&&)ent);
|
|
|
|
|
|
|
|
|
|
lwe::Entity* sun = new lwe::Entity("Sun");
|
|
|
|
|
sun->SetPos({-5.0f, 0.0f, 5.0f});
|
|
|
|
|
lwe::Entity sun("Sun");
|
|
|
|
|
sun.SetPos({-5.0f, 0.0f, 5.0f});
|
|
|
|
|
|
|
|
|
|
lwe::AmbientPointLight* sunLight = new lwe::AmbientPointLight("Light");
|
|
|
|
|
sunLight->SetDiffuse({1.0f, 0.77254901960784313725490196078431f, 0.56078431372549019607843137254902f});
|
|
|
|
|
sun->AddComponent(sunLight);
|
|
|
|
|
sun.AddComponent(sunLight);
|
|
|
|
|
|
|
|
|
|
AddEntity(sun);
|
|
|
|
|
AddEntity((lwe::Entity&&)sun);
|
|
|
|
|
|
|
|
|
|
lwe::Entity* emergency = new lwe::Entity("Emergency");
|
|
|
|
|
emergency->SetPos({5.0f, 0.0f, 5.0f});
|
|
|
|
@@ -390,14 +398,14 @@ void TestLevel::Setup()
|
|
|
|
|
pl->SetColor({1.0f, 0.0f, 0.0f});
|
|
|
|
|
emergency->AddComponent(pl);
|
|
|
|
|
|
|
|
|
|
AddEntity(emergency);
|
|
|
|
|
AddEntity((lwe::Entity&&)emergency);
|
|
|
|
|
|
|
|
|
|
lwe::Entity* testEnt = new lwe::Entity("Test");
|
|
|
|
|
|
|
|
|
|
lwe::Billboard* testBb = new lwe::Billboard("TestBB", "Character_Diffuse");
|
|
|
|
|
testEnt->AddComponent(testBb);
|
|
|
|
|
|
|
|
|
|
AddEntity(testEnt);
|
|
|
|
|
AddEntity((lwe::Entity&&)testEnt);
|
|
|
|
|
|
|
|
|
|
lwe::Entity* bullet = new lwe::Entity("Bullet");
|
|
|
|
|
bullet->SetScale({0.1f, 0.1f, 0.1f});
|
|
|
|
@@ -411,7 +419,7 @@ void TestLevel::Setup()
|
|
|
|
|
lwe::SolidColor* bulletMdl = new lwe::SolidColor("Mdl", {1.0f, 1.0f, 0.0f, 1.0f}, "Cube", "");
|
|
|
|
|
bullet->AddComponent(bulletMdl);
|
|
|
|
|
|
|
|
|
|
AddTemplate(bullet);
|
|
|
|
|
AddTemplate((lwe::Entity&&)bullet);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TestLevel::PostInitialize(lwe::GpuCmdBuffer* cmdBuffer)
|
|
|
|
@@ -454,21 +462,21 @@ void TestLevel::PostInitialize(lwe::GpuCmdBuffer* cmdBuffer)
|
|
|
|
|
*/
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TestLevel::OnUpdate(lwe::RenderWindow* win, lwe::Input* input, const float delta)
|
|
|
|
|
void TestLevel::OnUpdate(lwe::RenderWindow* win, ehs::Input* input, const float delta)
|
|
|
|
|
{
|
|
|
|
|
lwe::GameLoop* gl = (lwe::GameLoop*)GetParent("GameLoop");
|
|
|
|
|
lwe::GameLoop* gl = GetParent();
|
|
|
|
|
if (!gl)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
const lwe::InputHandler* ih = win->GetInputHandler();
|
|
|
|
|
const ehs::InputHandler* ih = win->GetInputHandler();
|
|
|
|
|
if (!ih)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
const lwe::Mouse* mouse = (lwe::Mouse*)ih->GetDeviceByType(LWE_HID_MOUSE);
|
|
|
|
|
const ehs::Mouse* mouse = (ehs::Mouse*)ih->GetDeviceByType(EHS_HID_MOUSE);
|
|
|
|
|
if (!mouse)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
const lwe::Keyboard* keyboard = (lwe::Keyboard*)ih->GetDeviceByType(LWE_HID_KEYBOARD);
|
|
|
|
|
const ehs::Keyboard* keyboard = (ehs::Keyboard*)ih->GetDeviceByType(EHS_HID_KEYBOARD);
|
|
|
|
|
if (!keyboard)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
@@ -476,7 +484,7 @@ void TestLevel::OnUpdate(lwe::RenderWindow* win, lwe::Input* input, const float
|
|
|
|
|
if (!ent)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
ent->SetRot(ent->GetRot() + lwe::Vec3_f(50.0f) * delta);
|
|
|
|
|
ent->SetRot(ent->GetRot() + ehs::Vec3_f(50.0f) * delta);
|
|
|
|
|
|
|
|
|
|
lwe::Entity* ply = GetEntity("Player");
|
|
|
|
|
if (ply && win->IsCursorConstrained() && !win->IsCursorVisible())
|
|
|
|
@@ -488,13 +496,13 @@ void TestLevel::OnUpdate(lwe::RenderWindow* win, lwe::Input* input, const float
|
|
|
|
|
if (camSys)
|
|
|
|
|
camSys->SetPrimary(ply->GetHashId(), cam->GetHashId());
|
|
|
|
|
|
|
|
|
|
if (cooldown <= 0.0f && mouse->IsDown(lwe::Mouse::LMB)) // Left Mouse Button
|
|
|
|
|
if (cooldown <= 0.0f && mouse->IsDown(ehs::Mouse::LMB)) // Left Mouse Button
|
|
|
|
|
{
|
|
|
|
|
lwe::AudioSource* gunshot = new lwe::AudioSource("Gunshot_" + lwe::Str_8::FromNum(count), "Gunshot");
|
|
|
|
|
lwe::AudioSource* gunshot = new lwe::AudioSource("Gunshot_" + ehs::Str_8::FromNum(count), "Gunshot");
|
|
|
|
|
gunshot->SetVolume(1.0f);
|
|
|
|
|
ply->AddComponent(gunshot);
|
|
|
|
|
|
|
|
|
|
lwe::Entity* bullet = CreateEntity("Bullet", "Bullet_" + lwe::Str_8::FromNum(count++));
|
|
|
|
|
lwe::Entity* bullet = CreateEntity("Bullet", "Bullet_" + ehs::Str_8::FromNum(count++));
|
|
|
|
|
bullet->SetPos(ply->GetPos() + cam->GetTransform().GetForward() * 2.0f);
|
|
|
|
|
bullet->SetScale({0.1f, 0.1f, 0.1f});
|
|
|
|
|
bullet->SetRot(ply->GetRot());
|
|
|
|
@@ -524,7 +532,7 @@ void TestLevel::OnUpdate(lwe::RenderWindow* win, lwe::Input* input, const float
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
lwe::LabelGui* fps = (lwe::LabelGui*)stats->GetChild("FPS");
|
|
|
|
|
fps->SetText("FPS: " + lwe::Str_8::FromNum(gl->GetTPS()));
|
|
|
|
|
fps->SetText("FPS: " + ehs::Str_8::FromNum(gl->GetTPS()));
|
|
|
|
|
|
|
|
|
|
lwe::AudioSource* source = (lwe::AudioSource*)ent->GetComponent("AudioSource3D", "Song");
|
|
|
|
|
if (!source)
|
|
|
|
@@ -536,24 +544,24 @@ void TestLevel::OnUpdate(lwe::RenderWindow* win, lwe::Input* input, const float
|
|
|
|
|
|
|
|
|
|
lwe::LabelGui* playback = (lwe::LabelGui*)stats->GetChild("Playback");
|
|
|
|
|
|
|
|
|
|
lwe::UInt_64 elapsed = source->GetFrameOffset() / audio->GetSampleRate();
|
|
|
|
|
lwe::UInt_64 duration = audio->GetFrameCount() / audio->GetSampleRate();
|
|
|
|
|
ehs::UInt_64 elapsed = source->GetFrameOffset() / audio->GetSampleRate();
|
|
|
|
|
ehs::UInt_64 duration = audio->GetFrameCount() / audio->GetSampleRate();
|
|
|
|
|
|
|
|
|
|
playback->SetText("Playback: " + lwe::Str_8::FromNum(elapsed / 60) + ":" + lwe::Str_8::FromNum(elapsed % 60) +
|
|
|
|
|
" / " + lwe::Str_8::FromNum(duration / 60) + ":" + lwe::Str_8::FromNum(duration % 60));
|
|
|
|
|
playback->SetText("Playback: " + ehs::Str_8::FromNum(elapsed / 60) + ":" + ehs::Str_8::FromNum(elapsed % 60) +
|
|
|
|
|
" / " + ehs::Str_8::FromNum(duration / 60) + ":" + ehs::Str_8::FromNum(duration % 60));
|
|
|
|
|
|
|
|
|
|
if (win->IsCursorConstrained() && !win->IsCursorVisible())
|
|
|
|
|
{
|
|
|
|
|
if (keyboard->IsJustReleased(lwe::Keyboard::Left))
|
|
|
|
|
if (keyboard->IsJustReleased(ehs::Keyboard::Left))
|
|
|
|
|
source->SetVolume(source->GetVolume() - 0.25f);
|
|
|
|
|
|
|
|
|
|
if (keyboard->IsJustReleased(lwe::Keyboard::Right))
|
|
|
|
|
if (keyboard->IsJustReleased(ehs::Keyboard::Right))
|
|
|
|
|
source->SetVolume(source->GetVolume() + 0.25f);
|
|
|
|
|
|
|
|
|
|
lwe::LabelGui* volume = (lwe::LabelGui*)stats->GetChild("Volume");
|
|
|
|
|
volume->SetText("Volume: " + lwe::Str_8::FromNum(source->GetVolume()));
|
|
|
|
|
volume->SetText("Volume: " + ehs::Str_8::FromNum(source->GetVolume()));
|
|
|
|
|
|
|
|
|
|
if (keyboard->IsJustReleased(lwe::Keyboard::P))
|
|
|
|
|
if (keyboard->IsJustReleased(ehs::Keyboard::P))
|
|
|
|
|
{
|
|
|
|
|
if (source->IsPlaying())
|
|
|
|
|
source->Pause();
|
|
|
|
@@ -561,7 +569,7 @@ void TestLevel::OnUpdate(lwe::RenderWindow* win, lwe::Input* input, const float
|
|
|
|
|
source->Play();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (keyboard->IsJustReleased(lwe::Keyboard::Backspace))
|
|
|
|
|
if (keyboard->IsJustReleased(ehs::Keyboard::Backspace))
|
|
|
|
|
source->Reset();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|