diff --git a/.idea/TechDemo.iml b/.idea/TechDemo.iml
new file mode 100644
index 0000000..f08604b
--- /dev/null
+++ b/.idea/TechDemo.iml
@@ -0,0 +1,2 @@
+
+
\ No newline at end of file
diff --git a/.idea/editor.xml b/.idea/editor.xml
new file mode 100644
index 0000000..f9a3953
--- /dev/null
+++ b/.idea/editor.xml
@@ -0,0 +1,87 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
new file mode 100644
index 0000000..1a4ace3
--- /dev/null
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 30bab2a..c2cdd87 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,5 +1,6 @@
+
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..2201786
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4a9af87..56c136b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -41,4 +41,4 @@ target_include_directories(TechDemo PRIVATE "${USER_HOME_DIRECTORY}/Libraries/LW
find_package(Vulkan REQUIRED)
-target_link_libraries(TechDemo PRIVATE Vulkan::Headers Vulkan::Vulkan xcb xcb-xfixes xcb-xinput wooting_analog_wrapper LWE z asound)
\ No newline at end of file
+target_link_libraries(TechDemo PRIVATE Vulkan::Headers Vulkan::Vulkan xcb xcb-cursor xcb-xfixes xcb-xinput wooting_analog_wrapper LWE z asound)
\ No newline at end of file
diff --git a/Levels/MainMenu.cpp b/Levels/MainMenu.cpp
index d5ee77b..2c89dc5 100644
--- a/Levels/MainMenu.cpp
+++ b/Levels/MainMenu.cpp
@@ -44,17 +44,9 @@ void MainMenu::PostInitialize(lwe::GpuCmdBuffer* cmdBuffer)
Level::PostInitialize(cmdBuffer);
}
-void MainMenu::OnUpdate(lwe::Input* input, const float delta)
+void MainMenu::OnUpdate(lwe::RenderWindow* win, lwe::Input* input, const float delta)
{
- Level::OnUpdate(input, delta);
-
- lwe::GameLoop* gl = (lwe::GameLoop*)GetParent("GameLoop");
- if (!gl)
- return;
-
- lwe::RenderWindow* win = gl->GetWindow();
- if (!win)
- return;
+ Level::OnUpdate(win, input, delta);
lwe::Vec2_f client = win->GetScale();
diff --git a/Levels/MainMenu.h b/Levels/MainMenu.h
index 5689696..e44e501 100644
--- a/Levels/MainMenu.h
+++ b/Levels/MainMenu.h
@@ -22,5 +22,5 @@ public:
void PostInitialize(lwe::GpuCmdBuffer* cmdBuffer) override;
- void OnUpdate(lwe::Input* input, const float delta) override;
+ void OnUpdate(lwe::RenderWindow* win, lwe::Input* input, const float delta) override;
};
\ No newline at end of file
diff --git a/Levels/TestLevel.cpp b/Levels/TestLevel.cpp
index 5f5d720..9c93611 100644
--- a/Levels/TestLevel.cpp
+++ b/Levels/TestLevel.cpp
@@ -23,7 +23,6 @@
#include
#include
#include
-#include
#include
#include
#include
@@ -39,17 +38,18 @@
#include
#include
#include
-#include
#include
#include
#include
+#include
+#include
#include
+#include
#include
#include
#include
#include
#include
-#include
TestLevel::TestLevel()
: count(0), cooldown(0.0f)
@@ -214,10 +214,10 @@ void TestLevel::Setup()
}
*/
- AddSystem(new lwe::DynamicsSystem());
- AddSystem(new lwe::RigidBodySystem());
- AddSystem(new lwe::CameraSystem());
+ //AddSystem(new lwe::AudioSystem());
AddSystem(new lwe::SkyboxSystem());
+ AddSystem(new lwe::RigidBodySystem(true));
+ AddSystem(new lwe::CameraSystem());
AddSystem(new lwe::PhongSystem());
AddSystem(new lwe::SolidColorSystem());
AddSystem(new lwe::BillboardSystem());
@@ -226,8 +226,6 @@ void TestLevel::Setup()
ls->SetAmbient({0.25f, 0.25f, 0.25f});
AddSystem(ls);
- //AddSystem(new lwe::AudioSystem());
-
lwe::TimerSystem* timerSys = new lwe::TimerSystem();
AddSystem(timerSys);
@@ -288,15 +286,15 @@ void TestLevel::Setup()
gbg->SetText("Garbage: " + lwe::Str_8::FromNum(lwe::GarbageCollector::Size()));
}});
- lwe::ButtonGui* testBttn = new lwe::ButtonGui("Test", "Test");
- testBttn->SetScale({200.0f, 50.0f});
- testBttn->SetPosition({400.0f, 400.0f});
- guiSys->AddGui(testBttn);
+ lwe::PanelGui* testPanel = new lwe::PanelGui("TestPanel");
+ testPanel->SetPosition({300.0f, 200.0f});
+ testPanel->SetScale({400.0f, 400.0f});
+ guiSys->AddGui(testPanel);
lwe::Entity* player = new lwe::Entity("Player");
//player->AddComponent(new lwe::Networked(true, false, lwe::EndpointOwner::ENDPOINT));
- player->AddComponent(new lwe::Point3D("Head"));
+ player->AddComponent(new lwe::Point3D("Head", 1.0f, 1.0f));
player->AddComponent(new lwe::PlyController("Head"));
//player->AddComponent(new lwe::Health(100, 100));
@@ -309,7 +307,7 @@ void TestLevel::Setup()
AddTemplate(player);
lwe::Entity* plyPuppet = new lwe::Entity("Puppet");
- plyPuppet->AddComponent(new lwe::OBB3D("Head"));
+ plyPuppet->AddComponent(new lwe::OBB3D("Head", 1.0f, 1.0f));
plyPuppet->AddComponent(new lwe::Camera("Head"));
plyPuppet->AddComponent(new lwe::Health(100, 100));
@@ -344,8 +342,25 @@ void TestLevel::Setup()
//as->EnableAttenuation(false);
ent->AddComponent(as);
- lwe::Sphere* sphere = new lwe::Sphere("Sphere", 5.0f);
- ent->AddComponent(sphere);
+ lwe::Health* entHealth = new lwe::Health(100, 100);
+ ent->AddComponent(entHealth);
+
+ lwe::OBB3D* entCollider = new lwe::OBB3D("Collider", 1.0f, 1.0f);
+ entCollider->SetScale({1.0f, 2.0f, 1.0f});
+ entCollider->SetPos({0.0f, 1.1f, 0.0f});
+ entCollider->SetCollidedCb([](lwe::RigidBody* a, lwe::RigidBody* b)
+ {
+ lwe::Entity* aOwner = (lwe::Entity*)a->GetParent();
+ lwe::Health* health = (lwe::Health*)aOwner->GetComponent("Health");
+ health->TakeDamage(10);
+
+ lwe::Entity* bOwner = (lwe::Entity*)b->GetParent();
+ bOwner->Delete();
+
+ if (health->GetHealth() <= 0)
+ aOwner->Delete();
+ });
+ ent->AddComponent(entCollider);
/*
lwe::AudioSource* as2 = new lwe::AudioSource("Song2", "sample");
@@ -388,8 +403,10 @@ void TestLevel::Setup()
bullet->SetScale({0.1f, 0.1f, 0.1f});
bullet->AddComponent(new lwe::Projectile(25));
- bullet->AddComponent(new lwe::Dynamics(50.0f));
- bullet->AddComponent(new lwe::Point3D("Tip"));
+
+ lwe::OBB3D* bulletCollider = new lwe::OBB3D("Collider", 1.0f, 1.0f);
+ bulletCollider->SetScale(0.1f);
+ bullet->AddComponent(bulletCollider);
lwe::SolidColor* bulletMdl = new lwe::SolidColor("Mdl", {1.0f, 1.0f, 0.0f, 1.0f}, "Cube", "");
bullet->AddComponent(bulletMdl);
@@ -437,23 +454,32 @@ void TestLevel::PostInitialize(lwe::GpuCmdBuffer* cmdBuffer)
*/
}
-void TestLevel::OnUpdate(lwe::Input* input, const float delta)
+void TestLevel::OnUpdate(lwe::RenderWindow* win, lwe::Input* input, const float delta)
{
lwe::GameLoop* gl = (lwe::GameLoop*)GetParent("GameLoop");
if (!gl)
return;
- lwe::GenericInputHandler* handler = (lwe::GenericInputHandler*)input->GetHandler("GenericInputHandler");
- if (!handler)
+ const lwe::InputHandler* ih = win->GetInputHandler();
+ if (!ih)
return;
- const lwe::Mouse* mouse = handler->GetPrimaryMouse();
- const lwe::Keyboard* keyboard = handler->GetPrimaryKeyboard();
+ const lwe::Mouse* mouse = (lwe::Mouse*)ih->GetDeviceByType(LWE_HID_MOUSE);
+ if (!mouse)
+ return;
+
+ const lwe::Keyboard* keyboard = (lwe::Keyboard*)ih->GetDeviceByType(LWE_HID_KEYBOARD);
+ if (!keyboard)
+ return;
lwe::Entity* ent = GetEntity("Main");
+ if (!ent)
+ return;
+
+ ent->SetRot(ent->GetRot() + lwe::Vec3_f(50.0f) * delta);
lwe::Entity* ply = GetEntity("Player");
- if (ply)
+ if (ply && win->IsCursorConstrained() && !win->IsCursorVisible())
{
lwe::PlyController* cam = (lwe::PlyController*)ply->GetComponent("PlyController", "Head");
if (cam)
@@ -473,8 +499,8 @@ void TestLevel::OnUpdate(lwe::Input* input, const float delta)
bullet->SetScale({0.1f, 0.1f, 0.1f});
bullet->SetRot(ply->GetRot());
- lwe::Dynamics* dynamics = (lwe::Dynamics*)bullet->GetComponent("Dynamics");
- dynamics->SetVelocity(cam->GetTransform().GetForward() * 100.0f);
+ lwe::OBB3D* rb = (lwe::OBB3D*)bullet->GetComponent("OBB3D", "Collider");
+ rb->SetVelocity(cam->GetTransform().GetForward() * 10.0f);
cooldown = 0.15f;
}
@@ -516,23 +542,26 @@ void TestLevel::OnUpdate(lwe::Input* input, const float delta)
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));
- if (keyboard->IsJustReleased(lwe::Keyboard::Left))
- source->SetVolume(source->GetVolume() - 0.25f);
-
- if (keyboard->IsJustReleased(lwe::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()));
-
- if (keyboard->IsJustReleased(lwe::Keyboard::P))
+ if (win->IsCursorConstrained() && !win->IsCursorVisible())
{
- if (source->IsPlaying())
- source->Pause();
- else
- source->Play();
- }
+ if (keyboard->IsJustReleased(lwe::Keyboard::Left))
+ source->SetVolume(source->GetVolume() - 0.25f);
- if (keyboard->IsJustReleased(lwe::Keyboard::Backspace))
- source->Reset();
+ if (keyboard->IsJustReleased(lwe::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()));
+
+ if (keyboard->IsJustReleased(lwe::Keyboard::P))
+ {
+ if (source->IsPlaying())
+ source->Pause();
+ else
+ source->Play();
+ }
+
+ if (keyboard->IsJustReleased(lwe::Keyboard::Backspace))
+ source->Reset();
+ }
}
diff --git a/Levels/TestLevel.h b/Levels/TestLevel.h
index de8728b..5f84046 100644
--- a/Levels/TestLevel.h
+++ b/Levels/TestLevel.h
@@ -27,5 +27,5 @@ public:
void PostInitialize(lwe::GpuCmdBuffer* cmdBuffer) override;
- void OnUpdate(lwe::Input* input, const float delta) override;
+ void OnUpdate(lwe::RenderWindow* win, lwe::Input* input, const float delta) override;
};
\ No newline at end of file
diff --git a/main.cpp b/main.cpp
index e9d5d1f..e4df70f 100644
--- a/main.cpp
+++ b/main.cpp
@@ -13,7 +13,6 @@
#include
#include
#include
-#include
#include
@@ -118,14 +117,14 @@ lwe::SInt_32 Main(lwe::Str_8* appName, lwe::Str_8* appVerId, lwe::Version* appVe
configFile.Release();
- lwe::Array args = lwe::Console::GetArgs_8();
+ lwe::Vector args = lwe::Console::GetArgs_8();
if (args.Size() > 1 && lwe::Str_8::Cmp(args[1], "-server"))
{
lwe::Console::Attach();
lwe::Console::SetTitle_8("TechDemo");
- LWE_LOG("Info", "TechDemo", 0, "Initializing server, standby.");
+ LWE_LOG("Info", 0, "Initializing server, standby.");
lwe::GameLoop gl((lwe::UInt_8)*(lwe::JsonNum*)config.RetrieveValue("engine.threadCount"), 0);
gl.EnableTimeLock(*(lwe::JsonBool*)config.RetrieveValue("engine.timeLocked"));
@@ -179,9 +178,6 @@ lwe::SInt_32 Main(lwe::Str_8* appName, lwe::Str_8* appVerId, lwe::Version* appVe
gl.EnableTimeLock(*(lwe::JsonBool*)config.RetrieveValue("engine.timeLocked"));
gl.SetMaxTPS((lwe::UInt_32)*(lwe::JsonNum*)config.RetrieveValue("engine.maxTPS"));
- lwe::Input* input = gl.GetInput();
- input->AddHandler(new lwe::GenericInputHandler());
-
lwe::Frame mainFrame("Main");
gl.AddFrame(&mainFrame);
mainFrame.AddLevel(new TestLevel("Test"));