Played around with MainScene to test hot-reloading

Signed-off-by: Robear Selwans <robear.selwans@outlook.com>
This commit is contained in:
2021-06-09 09:26:15 +02:00
parent a61957066b
commit aad7ae5e11
10 changed files with 170 additions and 28 deletions

View File

@@ -3,6 +3,22 @@
"nodes": [
{
"id": "Camera",
"components": [
{
"type": "TransformComponent",
"position": [0.0, 0.0, 5.0],
"rotation": [0.0, 0.0, 0.0],
"scale": [1.0, 1.0, 1.0]
},
{
"type": "ScriptComponent",
"script_name": "MainCameraController",
"script_path": "scripts://MainScene/Camera.lua"
}
],
"children": [
{
"id": "RotationHelper",
"components": [
{
"type": "TransformComponent",
@@ -13,15 +29,36 @@
{
"type": "CameraComponent",
"view": "Perspective",
"fov": 60,
"fov": 90,
"near": 0.001,
"far": 1000,
"aspectRatio": 1.3333
},
{
"type": "ScriptComponent",
"script_name": "MainCameraController",
"script_path": "scripts://MainScene/camera.lua"
"script_name": "MainCameraRotationHelper",
"script_path": "scripts://MainScene/CameraHelper.lua"
}
]
}
]
},
{
"id": "SideCamera",
"components": [
{
"type": "TransformComponent",
"position": [25.0, 0.0, -15.0],
"rotation": [0.0, 90.0, 0.0],
"scale": [1.0, 1.0, 1.0]
},
{
"type": "CameraComponent",
"view": "Perspective",
"fov": 90,
"near": 0.001,
"far": 1000,
"aspectRatio": 1.3333
}
]
},
@@ -30,7 +67,7 @@
"components": [
{
"type": "TransformComponent",
"position": [0.0, 10.0, -15.0],
"position": [0.0, 0.0, -15.0],
"rotation": [0.0, 0.0, 0.0],
"scale": [1.0, 1.0, 1.0]
},
@@ -47,7 +84,7 @@
{
"type": "ScriptComponent",
"script_name": "MainPlayerController",
"script_path": "scripts://MainScene/player.lua"
"script_path": "scripts://MainScene/Player.lua"
}
],
"children": [
@@ -81,18 +118,29 @@
{
"type": "ScriptComponent",
"script_name": "MainChildController",
"script_path": "scripts://MainScene/child.lua"
"script_path": "scripts://MainScene/Child.lua"
}
]
}
]
},
{
"id": "Map",
"components": [
{
"type": "TransformComponent",
"position": [0.0, 0.0, 0.0],
"rotation": [0.0, 0.0, 0.0],
"scale": [1.0, 1.0, 1.0]
}
],
"children": [
{
"id": "Ground",
"components": [
{
"type": "TransformComponent",
"position": [0.0, -15.0, -15.0],
"position": [0.0, -5.0, -15.0],
"rotation": [0.0, 0.0, 0.0],
"scale": [1.0, 1.0, 1.0]
},
@@ -103,11 +151,97 @@
"restitution": 0.0,
"collisionShape": {
"type": "Box",
"halfExtents": [10.0, 10.0, 10.0]
"halfExtents": [10.0, 1.0, 10.0]
}
}
]
},
{
"id": "Ceiling",
"components": [
{
"type": "TransformComponent",
"position": [0.0, 5.0, -15.0],
"rotation": [0.0, 0.0, 0.0],
"scale": [1.0, 1.0, 1.0]
},
{
"type": "RigidbodyComponent",
"rigidbodyType": "Static",
"mass": 0.0,
"restitution": 0.0,
"collisionShape": {
"type": "Box",
"halfExtents": [10.0, 1.0, 10.0]
}
}
]
},
{
"id": "WallRight",
"components": [
{
"type": "TransformComponent",
"position": [9.0, 0.0, -14.0],
"rotation": [0.0, 0.0, 0.0],
"scale": [1.0, 1.0, 1.0]
},
{
"type": "RigidbodyComponent",
"rigidbodyType": "Static",
"mass": 0.0,
"restitution": 0.0,
"collisionShape": {
"type": "Box",
"halfExtents": [1.0, 4.0, 9.0]
}
}
]
},
{
"id": "WallLeft",
"components": [
{
"type": "TransformComponent",
"position": [-9.0, 0.0, -14.0],
"rotation": [0.0, 0.0, 0.0],
"scale": [1.0, 1.0, 1.0]
},
{
"type": "RigidbodyComponent",
"rigidbodyType": "Static",
"mass": 0.0,
"restitution": 0.0,
"collisionShape": {
"type": "Box",
"halfExtents": [1.0, 4.0, 9.0]
}
}
]
},
{
"id": "WallBack",
"components": [
{
"type": "TransformComponent",
"position": [0.0, 0.0, -24.0],
"rotation": [0.0, 0.0, 0.0],
"scale": [1.0, 1.0, 1.0]
},
{
"type": "RigidbodyComponent",
"rigidbodyType": "Static",
"mass": 0.0,
"restitution": 0.0,
"collisionShape": {
"type": "Box",
"halfExtents": [10.0, 4.0, 1.0]
}
}
]
}
]
}
],
"activeCamera": "Camera"
"activeCamera": "Camera.RotationHelper"
}

View File

@@ -1,5 +1,5 @@
{
"id":"SisyphusoScene",
"id":"SideScene",
"nodes": [
{
"id": "Camera",
@@ -21,7 +21,7 @@
{
"type": "ScriptComponent",
"script_name": "SideCameraController",
"script_path": "scripts://SideScene/camera.lua"
"script_path": "scripts://SideScene/Camera.lua"
}
]
},
@@ -48,7 +48,7 @@
{
"type": "ScriptComponent",
"script_name": "SidePlayerController",
"script_path": "scripts://SideScene/player.lua"
"script_path": "scripts://SideScene/Player.lua"
}
],
"children": [
@@ -74,7 +74,7 @@
{
"type": "ScriptComponent",
"script_name": "SideChildController",
"script_path": "scripts://SideScene/child.lua"
"script_path": "scripts://SideScene/Child.lua"
}
]
}
@@ -102,7 +102,7 @@
{
"type": "ScriptComponent",
"script_name": "SideGhostController",
"script_path": "scripts://SideScene/ghost.lua"
"script_path": "scripts://SideScene/Ghost.lua"
}
]
},

View File

@@ -3,12 +3,10 @@ this.on_init = function()
this.original_position = this.position
this.angles = Vec3:new()
this.mouse_sens = 0.01
Input.lockCursor()
end
this.on_update = function()
local deltaMouseMovement = Input.getDeltaMousePos()
this.angles.x = this.angles.x - deltaMouseMovement.y * this.mouse_sens
this.angles.y = this.angles.y - deltaMouseMovement.x * this.mouse_sens
this.eulerAngles = this.angles
end

View File

@@ -0,0 +1,10 @@
this.on_init = function()
this.angles = Vec3:new()
this.mouse_sens = 0.01
end
this.on_update = function()
local deltaMouseMovement = Input.getDeltaMousePos()
this.angles.x = this.angles.x - deltaMouseMovement.y * this.mouse_sens
this.eulerAngles = this.angles
end