Added evmod_assets and started using it for scripts
Signed-off-by: Robear Selwans <robear.selwans@outlook.com>
This commit is contained in:
18
res/scripts/Scene0/camera.lua
Normal file
18
res/scripts/Scene0/camera.lua
Normal file
@@ -0,0 +1,18 @@
|
||||
this.on_init = function()
|
||||
this.speed = 0.1
|
||||
end
|
||||
|
||||
this.on_fixedupdate = function()
|
||||
if Input.getKeyDown(Input.KeyCode.Up) then
|
||||
this.position = this.position + Vec3:new(0, 1, 0) * this.speed
|
||||
end
|
||||
if Input.getKeyDown(Input.KeyCode.Down) then
|
||||
this.position = this.position - Vec3:new(0, 1, 0) * this.speed
|
||||
end
|
||||
if Input.getKeyDown(Input.KeyCode.Right) then
|
||||
this.position = this.position + Vec3:new(1, 0, 0) * this.speed
|
||||
end
|
||||
if Input.getKeyDown(Input.KeyCode.Left) then
|
||||
this.position = this.position - Vec3:new(1, 0, 0) * this.speed
|
||||
end
|
||||
end
|
||||
15
res/scripts/Scene0/child.lua
Normal file
15
res/scripts/Scene0/child.lua
Normal file
@@ -0,0 +1,15 @@
|
||||
this.on_init = function ()
|
||||
this.custom_eulerangles = Vec3:new()
|
||||
this.custom_angularvelocity = Vec3:new(0, 0.01, 0)
|
||||
end
|
||||
|
||||
this.on_fixedupdate = function ()
|
||||
print('Scene0 OnFixedUpdate Entity #' .. this.entityID)
|
||||
if Input.getKeyDown(Input.KeyCode.Left) then
|
||||
this.custom_eulerangles:add(Vec3:new(0,0.01,0))
|
||||
end
|
||||
if Input.getKeyDown(Input.KeyCode.Right) then
|
||||
this.custom_eulerangles:sub(Vec3:new(0,0.01,0))
|
||||
end
|
||||
this.eulerAngles = this.custom_eulerangles
|
||||
end
|
||||
22
res/scripts/Scene0/player.lua
Normal file
22
res/scripts/Scene0/player.lua
Normal file
@@ -0,0 +1,22 @@
|
||||
this.on_collisionenter = function(other)
|
||||
other.position = other.position + Vec3:new(3.2, 0, 0)
|
||||
end
|
||||
|
||||
this.on_update = function ()
|
||||
rb = this:getComponent(Rigidbody)
|
||||
if Input.getKeyDown(Input.KeyCode.Space) then
|
||||
rb:addForce(Vec3:new(0, 100, 0))
|
||||
end
|
||||
if Input.getKeyDown(Input.KeyCode.D) then
|
||||
rb:addForce(Vec3:new(10, 0, 0))
|
||||
end
|
||||
if Input.getKeyDown(Input.KeyCode.A) then
|
||||
rb:addForce(Vec3:new(-10, 0, 0))
|
||||
end
|
||||
if Input.getKeyDown(Input.KeyCode.W) then
|
||||
rb:addForce(Vec3:new(0, 0, -10))
|
||||
end
|
||||
if Input.getKeyDown(Input.KeyCode.S) then
|
||||
rb:addForce(Vec3:new(0, 0, 10))
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user