forked from Revolutionary-Games/Thrive
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Revolutionary-Games#21 from Revolutionary-Games/li…
…ghts Scriptable Lights
- Loading branch information
Showing
17 changed files
with
557 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
test.lua | ||
sandbox |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
local background = Entity("background") | ||
|
||
-- Set up skyplane | ||
local skyplane = SkyPlaneComponent() | ||
skyplane.workingCopy.plane.normal = Vector3(0, 0, 1) | ||
skyplane.workingCopy.plane.d = 1000 | ||
skyplane:touch() | ||
background:addComponent(skyplane) | ||
|
||
local onupdate = OnUpdateComponent() | ||
background:addComponent(onupdate) | ||
onupdate.callback = function(entityId, milliseconds) | ||
skyplane.workingCopy.plane.d = (skyplane.workingCopy.plane.d + milliseconds) % 10000 | ||
skyplane:touch() | ||
end | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
local light = Entity("light") | ||
|
||
-- Transform | ||
light.transform = TransformComponent() | ||
light.transform.workingCopy.scale = Vector3(0.01, 0.01, 0.01) | ||
light.transform.workingCopy.position.z = 2.0; | ||
light.transform:touch() | ||
light:addComponent(light.transform) | ||
|
||
|
||
lightSceneNode = OgreSceneNodeComponent() | ||
light:addComponent(lightSceneNode) | ||
lightComponent = OgreLightComponent() | ||
lightComponent.workingCopy:setRange(200) | ||
lightComponent:touch() | ||
light:addComponent(lightComponent) | ||
lightEntity = OgreEntityComponent(OgreEntityComponent.PT_SPHERE) | ||
light:addComponent(lightEntity) | ||
onupdate = OnUpdateComponent() | ||
light:addComponent(onupdate) | ||
time = 0 | ||
onupdate.callback = function(entityId, milliseconds) | ||
time = time + milliseconds / 1000 | ||
light.transform.workingCopy.position.x = 5 * math.sin(time) | ||
light.transform.workingCopy.position.y = 5 * math.cos(time) | ||
light.transform:touch() | ||
end | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
background.lua | ||
light.lua | ||
player.lua |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
local player = Entity("player") | ||
playerTransform = TransformComponent() | ||
player:addComponent(playerTransform) | ||
playerSceneNode = OgreSceneNodeComponent() | ||
player:addComponent(playerSceneNode) | ||
player:addComponent(OgreEntityComponent("Sinbad.mesh")) | ||
|
||
playerTransform.workingCopy.position = Vector3(0, 0, 0) | ||
playerTransform:touch() | ||
|
||
playerMovable = MovableComponent() | ||
player:addComponent(playerMovable) | ||
|
||
playerInput = OnKeyComponent() | ||
player:addComponent(playerInput) | ||
MOVEMENT_SPEED = 10 | ||
playerInput.onPressed = function (entityId, event) | ||
if event.key == KeyEvent.KC_W then | ||
playerMovable.velocity.y = playerMovable.velocity.y + MOVEMENT_SPEED | ||
elseif event.key == KeyEvent.KC_S then | ||
playerMovable.velocity.y = playerMovable.velocity.y - MOVEMENT_SPEED | ||
elseif event.key == KeyEvent.KC_A then | ||
playerMovable.velocity.x = playerMovable.velocity.x - MOVEMENT_SPEED | ||
elseif event.key == KeyEvent.KC_D then | ||
playerMovable.velocity.x = playerMovable.velocity.x + MOVEMENT_SPEED | ||
end | ||
end | ||
|
||
playerInput.onReleased = function (entityId, event) | ||
if event.key == KeyEvent.KC_W then | ||
playerMovable.velocity.y = playerMovable.velocity.y - MOVEMENT_SPEED | ||
elseif event.key == KeyEvent.KC_S then | ||
playerMovable.velocity.y = playerMovable.velocity.y + MOVEMENT_SPEED | ||
elseif event.key == KeyEvent.KC_A then | ||
playerMovable.velocity.x = playerMovable.velocity.x + MOVEMENT_SPEED | ||
elseif event.key == KeyEvent.KC_D then | ||
playerMovable.velocity.x = playerMovable.velocity.x - MOVEMENT_SPEED | ||
end | ||
end | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +0,0 @@ | ||
background = Entity("background") | ||
skyplane = SkyPlaneComponent() | ||
skyplane.workingCopy.plane.normal = Vector3(0, 0, 1) | ||
skyplane.workingCopy.plane.d = 1000 | ||
skyplane:touch() | ||
background:addComponent(skyplane) | ||
|
||
onupdate = OnUpdateComponent() | ||
background:addComponent(onupdate) | ||
onupdate.callback = function(entityId, milliseconds) | ||
skyplane.workingCopy.plane.d = (skyplane.workingCopy.plane.d + milliseconds) % 10000 | ||
skyplane:touch() | ||
end | ||
|
||
player = Entity("player") | ||
playerTransform = TransformComponent() | ||
player:addComponent(playerTransform) | ||
playerSceneNode = OgreSceneNodeComponent() | ||
player:addComponent(playerSceneNode) | ||
player:addComponent(OgreEntityComponent("Sinbad.mesh")) | ||
|
||
playerTransform.position = Vector3(0, 0, 0) | ||
playerTransform:touch() | ||
|
||
playerMovable = MovableComponent() | ||
player:addComponent(playerMovable) | ||
|
||
playerInput = OnKeyComponent() | ||
player:addComponent(playerInput) | ||
MOVEMENT_SPEED = 10 | ||
playerInput.onPressed = function (entityId, event) | ||
if event.key == KeyEvent.KC_W then | ||
playerMovable.velocity.y = playerMovable.velocity.y + MOVEMENT_SPEED | ||
elseif event.key == KeyEvent.KC_S then | ||
playerMovable.velocity.y = playerMovable.velocity.y - MOVEMENT_SPEED | ||
elseif event.key == KeyEvent.KC_A then | ||
playerMovable.velocity.x = playerMovable.velocity.x - MOVEMENT_SPEED | ||
elseif event.key == KeyEvent.KC_D then | ||
playerMovable.velocity.x = playerMovable.velocity.x + MOVEMENT_SPEED | ||
end | ||
end | ||
|
||
playerInput.onReleased = function (entityId, event) | ||
if event.key == KeyEvent.KC_W then | ||
playerMovable.velocity.y = playerMovable.velocity.y - MOVEMENT_SPEED | ||
elseif event.key == KeyEvent.KC_S then | ||
playerMovable.velocity.y = playerMovable.velocity.y + MOVEMENT_SPEED | ||
elseif event.key == KeyEvent.KC_A then | ||
playerMovable.velocity.x = playerMovable.velocity.x + MOVEMENT_SPEED | ||
elseif event.key == KeyEvent.KC_D then | ||
playerMovable.velocity.x = playerMovable.velocity.x - MOVEMENT_SPEED | ||
end | ||
end | ||
|
||
|
||
|
||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.