diff --git a/.gitignore b/.gitignore
index f14bb3fa..69048e50 100644
--- a/.gitignore
+++ b/.gitignore
@@ -789,6 +789,8 @@ ASALocalRun/
# MFractors (Xamarin productivity tool) working folder
.mfractor/
+./bin
+./bin-int/
# Local History for Visual Studio
.localhistory/
diff --git a/Editor/Editor.cpp b/Editor/Editor.cpp
index 5a728644..cf7a6533 100644
--- a/Editor/Editor.cpp
+++ b/Editor/Editor.cpp
@@ -86,15 +86,15 @@ public:
void OnUpdate(Timestep ts)
{
- if (Input::IsKeyPress(GLFW_KEY_W))
+ if (Input::IsKeyDown(GLFW_KEY_W))
velocity.z = 5.0f;
- else if (Input::IsKeyPress(GLFW_KEY_S))
+ else if (Input::IsKeyDown(GLFW_KEY_S))
velocity.z = -5.0f;
else
velocity.z = 0.0f;
- if (Input::IsKeyPress(GLFW_KEY_A))
+ if (Input::IsKeyDown(GLFW_KEY_A))
velocity.x = 5.0f;
- else if (Input::IsKeyPress(GLFW_KEY_D))
+ else if (Input::IsKeyDown(GLFW_KEY_D))
velocity.x = -5.0f;
else
velocity.x = 0.0f;
@@ -159,16 +159,18 @@ int main()
while (!Engine::GetCurrentWindow()->ShouldClose())
{
+ Engine::Tick();
+
Engine::Draw();
- if (Input::IsKeyPress(GLFW_KEY_F8))
+ if (Input::IsKeyPressed(GLFW_KEY_F8))
Engine::ExitPlayMode();
editor.Draw();
Engine::EndDraw();
- Engine::Tick();
+
}
Engine::Close();
diff --git a/Editor/resources/Interface/Testing.css b/Editor/resources/Interface/Testing.css
index ef92915e..2eead7f5 100644
--- a/Editor/resources/Interface/Testing.css
+++ b/Editor/resources/Interface/Testing.css
@@ -1,6 +1,8 @@
-.button {
- width: 100%;
- height: 100%;
+
+
+.hello{
+ width: 400px;
+ height: 200px;
}
.screen{
@@ -8,20 +10,11 @@
width: 100%;
justify-content: center;
flex-direction: row;
- align-content:flex-end;
+ align-content:flex-start;
}
-.container {
- height: 50px;
- width: 50%;
- flex-direction: row;
- justify-content: space-between;
- align-content: center;
- align-self:center;
- padding: 8px;
-}
+.rect{
+ height: 200px;
+ width: 200px;
-.items{
- height: 30px;
- width: 30px;
}
diff --git a/Editor/resources/Interface/Testing.interface b/Editor/resources/Interface/Testing.interface
index c8a25d58..c12e00d1 100644
--- a/Editor/resources/Interface/Testing.interface
+++ b/Editor/resources/Interface/Testing.interface
@@ -1,23 +1,12 @@
diff --git a/Editor/resources/Scenes/level.scene b/Editor/resources/Scenes/level.scene
new file mode 100644
index 00000000..fbddfefa
--- /dev/null
+++ b/Editor/resources/Scenes/level.scene
@@ -0,0 +1,62 @@
+{
+ "Entities": [
+ {
+ "GetComponent()": {
+ "Name": "Camera"
+ },
+ "GetComponent()": {
+ "HasParent": false,
+ "Type": "ParentComponent"
+ },
+ "GetComponent()": {
+ "Rotation": {
+ "x": 0.0,
+ "y": 0.0,
+ "z": 0.0
+ },
+ "Scale": {
+ "x": 1.0,
+ "y": 1.0,
+ "z": 1.0
+ },
+ "Translation": {
+ "x": 0.0,
+ "y": 0.0,
+ "z": 0.0
+ },
+ "Type": "TransformComponent"
+ }
+ }
+ ],
+ "Name": "",
+ "m_Environement": {
+ "AmbientColor": {
+ "w": 1.0141871010880041e-38,
+ "x": 4.489836626909252e+21,
+ "y": 7.618957098799247e+31,
+ "z": 1.0141871010880041e-38
+ },
+ "ProceduralSkybox": {
+ "AtmosphereRadius": 6380000.0,
+ "MieScattering": {
+ "x": 1.9999999494757503e-05,
+ "y": 1.9999999494757503e-05,
+ "z": 1.9999999494757503e-05
+ },
+ "RayleighScattering": {
+ "x": 5.80000005356851e-06,
+ "y": 1.3500000022759195e-05,
+ "z": 3.310000101919286e-05
+ },
+ "SunDirection": {
+ "x": 0.20000000298023224,
+ "y": 0.9591699838638306,
+ "z": 0.20000000298023224
+ },
+ "SunIntensity": 100.0,
+ "SurfaceRadius": 6360000.0
+ },
+ "VolumetricFog": 0.949999988079071,
+ "VolumetricStepCount": 100.0
+ }
+}
\ No newline at end of file
diff --git a/Editor/resources/Scenes/test.scene b/Editor/resources/Scenes/test.scene
new file mode 100644
index 00000000..e2584be9
--- /dev/null
+++ b/Editor/resources/Scenes/test.scene
@@ -0,0 +1,108 @@
+{
+ "Entities": [
+ {
+ "NameComponent": {
+ "Name": "Trenchbroom map"
+ },
+ "ParentComponent": {
+ "HasParent": false
+ },
+ "QuakeMapComponent": {
+ "HasCollisions": false,
+ "Path": "C:\\Dev\\Nuake\\Editor\\resources\\Maps\\texture_test.map"
+ },
+ "TransformComponent": {
+ "Rotation": {
+ "x": 0.0,
+ "y": 0.0,
+ "z": 0.0
+ },
+ "Scale": {
+ "x": 1.0,
+ "y": 1.0,
+ "z": 1.0
+ },
+ "Translation": {
+ "x": 9.199999809265137,
+ "y": 5.599999904632568,
+ "z": 0.0
+ },
+ "Type": "TransformComponent"
+ }
+ },
+ {
+ "LightComponent": {
+ "CastShadows": true,
+ "Color": {
+ "x": 1.0,
+ "y": 1.0,
+ "z": 1.0
+ },
+ "Direction": {
+ "x": 0.20000000298023224,
+ "y": 0.9591699838638306,
+ "z": 0.20000000298023224
+ },
+ "IsVolumetric": false,
+ "Strength": 10.0,
+ "SyncDirectionWithSky": true,
+ "Type": 0
+ },
+ "NameComponent": {
+ "Name": "Light"
+ },
+ "ParentComponent": {
+ "HasParent": false
+ },
+ "TransformComponent": {
+ "Rotation": {
+ "x": 0.0,
+ "y": -0.0,
+ "z": 0.0
+ },
+ "Scale": {
+ "x": 1.0,
+ "y": 1.0,
+ "z": 1.0
+ },
+ "Translation": {
+ "x": 7.035792350769043,
+ "y": 5.795107364654541,
+ "z": -0.9431453943252563
+ },
+ "Type": "TransformComponent"
+ }
+ }
+ ],
+ "Name": "",
+ "m_Environement": {
+ "AmbientColor": {
+ "w": 0.0,
+ "x": null,
+ "y": 0.0,
+ "z": 0.0
+ },
+ "ProceduralSkybox": {
+ "AtmosphereRadius": 6380000.0,
+ "MieScattering": {
+ "x": 1.9999999494757503e-05,
+ "y": 1.9999999494757503e-05,
+ "z": 1.9999999494757503e-05
+ },
+ "RayleighScattering": {
+ "x": 5.80000005356851e-06,
+ "y": 1.3500000022759195e-05,
+ "z": 3.310000101919286e-05
+ },
+ "SunDirection": {
+ "x": 0.20000000298023224,
+ "y": 0.9591699838638306,
+ "z": 0.20000000298023224
+ },
+ "SunIntensity": 100.0,
+ "SurfaceRadius": 6360000.0
+ },
+ "VolumetricFog": 0.949999988079071,
+ "VolumetricStepCount": 100.0
+ }
+}
\ No newline at end of file
diff --git a/Editor/resources/Scenes/test.scene.scene b/Editor/resources/Scenes/test.scene.scene
new file mode 100644
index 00000000..0f285f04
--- /dev/null
+++ b/Editor/resources/Scenes/test.scene.scene
@@ -0,0 +1,70 @@
+{
+ "Entities": [
+ {
+ "CameraComponent": {
+ "CameraInstance": {
+ "AspectRatio": 1.7777777910232544,
+ "Exposure": 1.0,
+ "Fov": 88.0,
+ "Speed": 1.0,
+ "m_Type": 1
+ }
+ },
+ "NameComponent": {
+ "Name": "Camera"
+ },
+ "ParentComponent": {
+ "HasParent": false
+ },
+ "TransformComponent": {
+ "Rotation": {
+ "x": 0.0,
+ "y": 0.0,
+ "z": 0.0
+ },
+ "Scale": {
+ "x": 1.0,
+ "y": 1.0,
+ "z": 1.0
+ },
+ "Translation": {
+ "x": 0.0,
+ "y": 0.0,
+ "z": 0.0
+ },
+ "Type": "TransformComponent"
+ }
+ }
+ ],
+ "Name": "",
+ "m_Environement": {
+ "AmbientColor": {
+ "w": 9.275544859982045e-39,
+ "x": 1.0193902624158886e-38,
+ "y": 8.449025394560124e-39,
+ "z": 9.275544859982045e-39
+ },
+ "ProceduralSkybox": {
+ "AtmosphereRadius": 6380000.0,
+ "MieScattering": {
+ "x": 1.9999999494757503e-05,
+ "y": 1.9999999494757503e-05,
+ "z": 1.9999999494757503e-05
+ },
+ "RayleighScattering": {
+ "x": 5.80000005356851e-06,
+ "y": 1.3500000022759195e-05,
+ "z": 3.310000101919286e-05
+ },
+ "SunDirection": {
+ "x": 0.20000000298023224,
+ "y": 0.9591699838638306,
+ "z": 0.20000000298023224
+ },
+ "SunIntensity": 100.0,
+ "SurfaceRadius": 6360000.0
+ },
+ "VolumetricFog": 0.949999988079071,
+ "VolumetricStepCount": 100.0
+ }
+}
\ No newline at end of file
diff --git a/Editor/resources/Scripts/Engine.wren b/Editor/resources/Scripts/Engine.wren
new file mode 100644
index 00000000..4ccbd944
--- /dev/null
+++ b/Editor/resources/Scripts/Engine.wren
@@ -0,0 +1,15 @@
+class Engine {
+ foreign static Log(msg)
+}
+
+class Vector3 {
+ construct new(x, y, z) {
+ _x = x
+ _y = y
+ _z = z
+ }
+}
+
+class Entity {
+ foreign GetComponent(type)
+}
\ No newline at end of file
diff --git a/Editor/resources/Scripts/test.wren b/Editor/resources/Scripts/test.wren
new file mode 100644
index 00000000..fc35bfea
--- /dev/null
+++ b/Editor/resources/Scripts/test.wren
@@ -0,0 +1,18 @@
+import "Scripts/Engine" for Engine
+class Test {
+ init() {
+ System.print("hello init")
+ }
+
+ update(t) {
+ System.print("hello update %(t)")
+ }
+
+ exit() {
+ System.print("hello exit ")
+ }
+
+ static hello() {
+ Engine.Log("Hello from foreign")
+ }
+}
\ No newline at end of file
diff --git a/Editor/src/EditorInterface.cpp b/Editor/src/EditorInterface.cpp
index 49559889..dc84726b 100644
--- a/Editor/src/EditorInterface.cpp
+++ b/Editor/src/EditorInterface.cpp
@@ -675,10 +675,10 @@ void EditorInterface::DrawDirectoryExplorer()
}
}
- ImGui::EndTable();
+
}
-
+ ImGui::EndTable();
}
ImGui::End();
}
diff --git a/Nuake/Engine.cpp b/Nuake/Engine.cpp
index 93fadfb0..23c1ccca 100644
--- a/Nuake/Engine.cpp
+++ b/Nuake/Engine.cpp
@@ -1,6 +1,8 @@
#include "Engine.h"
#include "src/Core/Physics/PhysicsManager.h"
#include
+
+#include "../Core/Input.h"
#include "src/Core/FileSystem.h"
#include "src/Scripting/ScriptingEngine.h"
@@ -47,9 +49,11 @@ void Engine::Tick()
// Play mode update vs editor update.
if (Engine::IsPlayMode)
- GetCurrentScene()->Update(timestep);
+ CurrentWindow->Update(timestep);
else
GetCurrentScene()->EditorUpdate(timestep);
+
+ Input::Update();
}
void Engine::EnterPlayMode()
diff --git a/Nuake/src/Core/FileSystem.cpp b/Nuake/src/Core/FileSystem.cpp
index 3bdce5b4..eadf4f07 100644
--- a/Nuake/src/Core/FileSystem.cpp
+++ b/Nuake/src/Core/FileSystem.cpp
@@ -124,7 +124,7 @@ std::string FileSystem::ReadFile(const std::string& path, bool absolute)
// Use a while loop together with the getline() function to read the file line by line
while (getline(MyReadFile, fileContent))
{
- allFile.append(fileContent);
+ allFile.append(fileContent + "\n");
}
// Close the file
diff --git a/Nuake/src/Core/Input.cpp b/Nuake/src/Core/Input.cpp
index 7655a32a..043920e2 100644
--- a/Nuake/src/Core/Input.cpp
+++ b/Nuake/src/Core/Input.cpp
@@ -3,39 +3,70 @@
#include
Input* Input::s_Instance;
-// TODO: Key press, and release system.
+std::map Input::m_Keys = std::map();
+bool Input::m_MouseButtons[5] = { false, false, false, false, false };
+#pragma region Keys
+// Only true if the key is currently being pressed
+bool Input::IsKeyDown(int keycode)
+{
+ auto window = Window::Get()->GetHandle();
+ int state = glfwGetKey(window, keycode);
+ bool result = state == GLFW_PRESS;
+
+ m_Keys[keycode] = state;
+
+ return result;
+}
+
+// Only true if the key is pressed for the first frame. no repeat.
bool Input::IsKeyPressed(int keycode)
{
auto window = Window::Get()->GetHandle();
-
int state = glfwGetKey(window, keycode);
+ bool result = state == GLFW_PRESS;
- return state == GLFW_PRESS || state == GLFW_REPEAT;
+ // First time pressed?
+ if (m_Keys.find(keycode) == m_Keys.end() || m_Keys[keycode] == false)
+ {
+ if (result)
+ m_Keys[keycode] = true;
+
+ return result;
+ }
+
+ return false;
}
-bool Input::IsKeyPress(int keycode)
-{
- auto window = Window::Get()->GetHandle();
- int state = glfwGetKey(window, keycode);
- return state == GLFW_PRESS;
-}
bool Input::IsKeyReleased(int keycode)
{
auto window = Window::Get()->GetHandle();
int state = glfwGetKey(window, keycode);
- return state == GLFW_RELEASE;
-}
+ bool result = state == GLFW_RELEASE;
+ // First time pressed?
+ if (m_Keys.find(keycode) == m_Keys.end())
+ return result;
+
+ if (result && m_Keys[keycode] == true)
+ {
+ return true;
+ }
+
+
+ return false;
+}
+#pragma endregion
+
+#pragma region Mouse
+
+// Visibility
void Input::HideMouse() {
auto window = Window::Get()->GetHandle();
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);
}
-
-
-// TODO: Rename
bool Input::IsMouseHidden() {
auto window = Window::Get()->GetHandle();
return glfwGetInputMode(window, GLFW_CURSOR) == GLFW_CURSOR_DISABLED;
@@ -46,7 +77,9 @@ void Input::ShowMouse() {
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_NORMAL);
}
-bool Input::IsMouseButtonPressed(int button)
+
+// Action
+bool Input::IsMouseButtonDown(int button)
{
auto window = Window::Get()->GetHandle();
auto state = glfwGetMouseButton(window, button);
@@ -54,6 +87,29 @@ bool Input::IsMouseButtonPressed(int button)
return state == GLFW_PRESS;
}
+bool Input::IsMouseButtonPressed(int button)
+{
+ auto window = Window::Get()->GetHandle();
+ auto state = glfwGetMouseButton(window, button);
+
+ if (m_MouseButtons[button] == false && state == GLFW_PRESS)
+ {
+ m_MouseButtons[button] = true;
+ return true;
+ }
+
+ return false;
+}
+
+bool Input::IsMouseButtonReleased(int button)
+{
+ auto window = Window::Get()->GetHandle();
+ auto state = glfwGetMouseButton(window, button);
+
+ return state == GLFW_RELEASE && m_MouseButtons[button] == true;
+}
+
+// Position
float Input::GetMouseX()
{
auto window = Window::Get()->GetHandle();
@@ -74,15 +130,16 @@ float Input::GetMouseY()
return (float)ypos;
}
-std::pair Input::GetMousePosition()
+Vector2 Input::GetMousePosition()
{
auto window = Window::Get()->GetHandle();
double xpos, ypos;
glfwGetCursorPos(window, &xpos, &ypos);
- return { (float)xpos, (float)ypos };
+ return Vector2(xpos, ypos);
}
+#pragma endregion
bool Input::Init()
{
@@ -91,4 +148,20 @@ bool Input::Init()
return false;
}
+void Input::Update()
+{
+ // Reset all input to false.
+ for (auto& k : m_Keys)
+ {
+ if(!IsKeyDown(k.first))
+ k.second = false;
+ }
+
+ for (int i = 0; i < 5; i++)
+ {
+ if(!IsMouseButtonDown(i))
+ m_MouseButtons[i] = false;
+ }
+}
+
diff --git a/Nuake/src/Core/Input.h b/Nuake/src/Core/Input.h
index 382b6d86..d3dd7c50 100644
--- a/Nuake/src/Core/Input.h
+++ b/Nuake/src/Core/Input.h
@@ -1,25 +1,31 @@
#pragma once
#include
-
-
+#include "../Core/Maths.h"
+#include