mirror of
https://github.com/antopilo/Nuake.git
synced 2026-09-15 20:08:54 +03:00
Added Wren scripting with module system 📚
Added Input pressed, released system Added interface button support with wren onclick callback
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -1,23 +1,12 @@
|
||||
<Canvas
|
||||
script="Interface/Testing.lua"
|
||||
script="Scripts/test Test"
|
||||
groups="screen"
|
||||
color="25 25 25 255"
|
||||
color="25 25 25 9"
|
||||
>
|
||||
<Rect
|
||||
color="50 50 50 255"
|
||||
groups="container"
|
||||
padding="8px 8px 8px 8px"
|
||||
>
|
||||
<p>Hello world!</p>
|
||||
<Rect groups="items" color="200 0 200 255"></Rect>
|
||||
<Rect groups="items" color="200 0 200 255"></Rect>
|
||||
<Rect groups="items" color="200 0 200 255"></Rect>
|
||||
<Rect groups="items" color="200 0 200 255"></Rect>
|
||||
<Rect groups="items" color="200 0 200 255"></Rect>
|
||||
<Rect groups="items" color="200 0 200 255"></Rect>
|
||||
<Rect groups="items" color="200 0 200 255"></Rect>
|
||||
<Rect groups="items" color="200 0 200 255"></Rect>
|
||||
<Rect groups="items" color="200 0 200 255"></Rect>
|
||||
<Rect groups="items" color="200 0 200 255"></Rect>
|
||||
<p groups="hello">Hello, world</p>
|
||||
<Rect onclick="hello()"
|
||||
groups="rect"
|
||||
color="128 128 255 255">
|
||||
</Rect>
|
||||
<Slider value="sliderValue"/>
|
||||
</Canvas>
|
||||
|
||||
62
Editor/resources/Scenes/level.scene
Normal file
62
Editor/resources/Scenes/level.scene
Normal file
@@ -0,0 +1,62 @@
|
||||
{
|
||||
"Entities": [
|
||||
{
|
||||
"GetComponent<NameComponent>()": {
|
||||
"Name": "Camera"
|
||||
},
|
||||
"GetComponent<ParentComponent>()": {
|
||||
"HasParent": false,
|
||||
"Type": "ParentComponent"
|
||||
},
|
||||
"GetComponent<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": 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
|
||||
}
|
||||
}
|
||||
108
Editor/resources/Scenes/test.scene
Normal file
108
Editor/resources/Scenes/test.scene
Normal file
@@ -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
|
||||
}
|
||||
}
|
||||
70
Editor/resources/Scenes/test.scene.scene
Normal file
70
Editor/resources/Scenes/test.scene.scene
Normal file
@@ -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
|
||||
}
|
||||
}
|
||||
15
Editor/resources/Scripts/Engine.wren
Normal file
15
Editor/resources/Scripts/Engine.wren
Normal file
@@ -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)
|
||||
}
|
||||
18
Editor/resources/Scripts/test.wren
Normal file
18
Editor/resources/Scripts/test.wren
Normal file
@@ -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")
|
||||
}
|
||||
}
|
||||
@@ -675,10 +675,10 @@ void EditorInterface::DrawDirectoryExplorer()
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::EndTable();
|
||||
|
||||
}
|
||||
|
||||
|
||||
ImGui::EndTable();
|
||||
}
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user