|
|
|
@ -12,23 +12,25 @@ input.setControlSwitch(input.CONTROL_SWITCH.Magic, false)
|
|
|
|
|
input.setControlSwitch(input.CONTROL_SWITCH.VanityMode, false)
|
|
|
|
|
input.setControlSwitch(input.CONTROL_SWITCH.ViewMode, false)
|
|
|
|
|
|
|
|
|
|
testing.registerLocalTest('playerMovement',
|
|
|
|
|
testing.registerLocalTest('playerRotation',
|
|
|
|
|
function()
|
|
|
|
|
local startTime = core.getSimulationTime()
|
|
|
|
|
local pos = self.position
|
|
|
|
|
|
|
|
|
|
while core.getSimulationTime() < startTime + 0.5 do
|
|
|
|
|
local endTime = core.getSimulationTime() + 1
|
|
|
|
|
while core.getSimulationTime() < endTime do
|
|
|
|
|
self.controls.jump = false
|
|
|
|
|
self.controls.run = true
|
|
|
|
|
self.controls.movement = 0
|
|
|
|
|
self.controls.sideMovement = 0
|
|
|
|
|
local progress = (core.getSimulationTime() - startTime) / 0.5
|
|
|
|
|
self.controls.yawChange = util.normalizeAngle(math.rad(90) * progress - self.rotation.z)
|
|
|
|
|
self.controls.yawChange = util.normalizeAngle(math.rad(90) - self.rotation.z) * 0.5
|
|
|
|
|
coroutine.yield()
|
|
|
|
|
end
|
|
|
|
|
testing.expectEqualWithDelta(self.rotation.z, math.rad(90), 0.05, 'Incorrect rotation')
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
while core.getSimulationTime() < startTime + 1.5 do
|
|
|
|
|
testing.registerLocalTest('playerForwardRunning',
|
|
|
|
|
function()
|
|
|
|
|
local startPos = self.position
|
|
|
|
|
local endTime = core.getSimulationTime() + 1
|
|
|
|
|
while core.getSimulationTime() < endTime do
|
|
|
|
|
self.controls.jump = false
|
|
|
|
|
self.controls.run = true
|
|
|
|
|
self.controls.movement = 1
|
|
|
|
@ -36,12 +38,18 @@ testing.registerLocalTest('playerMovement',
|
|
|
|
|
self.controls.yawChange = 0
|
|
|
|
|
coroutine.yield()
|
|
|
|
|
end
|
|
|
|
|
direction = (self.position - pos) / types.Actor.runSpeed(self)
|
|
|
|
|
testing.expectEqualWithDelta(direction.x, 1, 0.1, 'Run forward, X coord')
|
|
|
|
|
testing.expectEqualWithDelta(direction.y, 0, 0.1, 'Run forward, Y coord')
|
|
|
|
|
local direction, distance = (self.position - startPos):normalize()
|
|
|
|
|
local normalizedDistance = distance / types.Actor.runSpeed(self)
|
|
|
|
|
testing.expectEqualWithDelta(normalizedDistance, 1, 0.2, 'Normalized forward runned distance')
|
|
|
|
|
testing.expectEqualWithDelta(direction.x, 0, 0.1, 'Run forward, X coord')
|
|
|
|
|
testing.expectEqualWithDelta(direction.y, 1, 0.1, 'Run forward, Y coord')
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
pos = self.position
|
|
|
|
|
while core.getSimulationTime() < startTime + 2.5 do
|
|
|
|
|
testing.registerLocalTest('playerDiagonalWalking',
|
|
|
|
|
function()
|
|
|
|
|
local startPos = self.position
|
|
|
|
|
local endTime = core.getSimulationTime() + 1
|
|
|
|
|
while core.getSimulationTime() < endTime do
|
|
|
|
|
self.controls.jump = false
|
|
|
|
|
self.controls.run = false
|
|
|
|
|
self.controls.movement = -1
|
|
|
|
@ -49,9 +57,11 @@ testing.registerLocalTest('playerMovement',
|
|
|
|
|
self.controls.yawChange = 0
|
|
|
|
|
coroutine.yield()
|
|
|
|
|
end
|
|
|
|
|
direction = (self.position - pos) / types.Actor.walkSpeed(self)
|
|
|
|
|
local direction, distance = (self.position - startPos):normalize()
|
|
|
|
|
local normalizedDistance = distance / types.Actor.walkSpeed(self)
|
|
|
|
|
testing.expectEqualWithDelta(normalizedDistance, 1, 0.2, 'Normalized diagonally walked distance')
|
|
|
|
|
testing.expectEqualWithDelta(direction.x, -0.707, 0.1, 'Walk diagonally, X coord')
|
|
|
|
|
testing.expectEqualWithDelta(direction.y, 0.707, 0.1, 'Walk diagonally, Y coord')
|
|
|
|
|
testing.expectEqualWithDelta(direction.y, -0.707, 0.1, 'Walk diagonally, Y coord')
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
@ -60,4 +70,3 @@ return {
|
|
|
|
|
},
|
|
|
|
|
eventHandlers = testing.eventHandlers
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|