Started editing input system for smoother motion

Here I have prepared functions on the engine's side necessary for modified input system. I kept old functions in comments for reference.
This commit is contained in:
MrPixel92 2023-04-27 22:32:59 +03:00 committed by GitHub
parent e02526564a
commit 167450d39a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -8,6 +8,10 @@ local GUI = require("GUI")
local event = require("Event")
local filesystem = require("Filesystem")
local inputX = 0
local inputY = 0
local inputYaw = 0
---------------------------------------------------- Константы ------------------------------------------------------------------
local rayEngine = {}
@ -189,27 +193,46 @@ function rayEngine.rotate(angle)
end
function rayEngine.turnRight()
rayEngine.rotate(rayEngine.player.rotationSpeed)
inputYaw = 1
--rayEngine.rotate(rayEngine.player.rotationSpeed)
end
function rayEngine.turnLeft()
rayEngine.rotate(-rayEngine.player.rotationSpeed)
inputYaw = -1
--rayEngine.rotate(-rayEngine.player.rotationSpeed)
end
function rayEngine.stopY()
inputY = 0
end
function rayEngine.stopX()
inputX = 0
end
function rayEngine.stopYaw()
inputYaw = 0
end
function rayEngine.moveForward()
rayEngine.move(rayEngine.player.moveSpeed, 0)
inputY = 1
--rayEngine.move(rayEngine.player.moveSpeed, 0)
end
function rayEngine.moveBackward()
rayEngine.move(-rayEngine.player.moveSpeed, 0)
inputY = -1
--rayEngine.move(-rayEngine.player.moveSpeed, 0)
end
function rayEngine.moveLeft()
rayEngine.move(0, -rayEngine.player.moveSpeed)
inputX = -1
--rayEngine.move(0, -rayEngine.player.moveSpeed)
end
function rayEngine.moveRight()
rayEngine.move(0, rayEngine.player.moveSpeed)
inputX = 1
--rayEngine.move(0, rayEngine.player.moveSpeed)
end
function rayEngine.jump()
@ -524,6 +547,9 @@ end
function rayEngine.update()
local frameRenderClock = os.clock()
rayEngine.rotate(rayEngine.player.rotationSpeed * inputYaw)
rayEngine.move(rayEngine.player.moveSpeed * inputY, rayEngine.player.moveSpeed * inputX)
rayEngine.drawWorld()
if rayEngine.currentWeapon then rayEngine.drawWeapon() end
if rayEngine.minimapEnabled then rayEngine.drawMap(3, 2, 24, 24, 0.5) end