VoidShot/scripts/inputs.lua
Hannah-Dagemark c9a1ef3d82 World Gen #1, Inventory #1
-- Added loading of .vsmf map files
-- Updated some variable names
-- Added developer information to the top left of the screen
-- Added a trial inventory
2023-09-15 20:52:30 +02:00

64 lines
No EOL
2.4 KiB
Lua

function mouseOver(object)
local mx, my = love.mouse.getPosition()
local time = 0
if mx > object.x and mx < object.x + object.width then
if my > object.y and my < object.y + object.height then
return true
end
end
return false
end
function keyboard_input_held(object, dt)
object.bools.isWalking = false
object.bools.isRunning = false
mouse.x, mouse.y = love.mouse.getPosition
if love.keyboard.isDown("lshift") then
object.bools.isRunning = true
end
if love.keyboard.isDown(keybinds.left) and love.keyboard.isDown(keybinds.right) then
-- you're stopped now :3c
elseif love.keyboard.isDown(keybinds.left) then
object.bools.isWalking = true
if math.abs(object.physics.velocityX) + 0.1 < object.functions.getRunningSpeed(object.bools.isRunning) then object.physics.velocityX = object.physics.velocityX - 0.1 else object.physics.velocityX = object.functions.getRunningSpeed(object.bools.isRunning)* -1 end
elseif love.keyboard.isDown(keybinds.right) then
object.bools.isWalking = true
if math.abs(object.physics.velocityX) < object.functions.getRunningSpeed(object.bools.isRunning) then object.physics.velocityX = object.physics.velocityX + 0.1 else object.physics.velocityX = object.functions.getRunningSpeed(object.bools.isRunning) end
end
end
function love.mousemoved(x, y)
if x > player.x then
player.bools.isFacingRight = true
else
player.bools.isFacingRight = false
end
end
function love.keypressed(key)
if Scene == "gameTest" then
if key == keybinds.jump and player.bools.isAirborne == false then player.physics.velocityY = player.physics.velocityY - 5 end
if key == keybinds.interact then
check_space.interactables(player.x, player.y)
end
if key == keybinds.create then
NPCs[#NPCs+1] = character.create({"attributes", "functions","bools","physics"}, false)
NPCs[#NPCs].x = math.random(0, window.x-20)
NPCs[#NPCs].y = window.y/2-window.y/20
NPCs[#NPCs].width = 20
NPCs[#NPCs].height = 80
end
if key == keybinds.primary then
player.current_equip = 1
end
if key == keybinds.secondary then
player.current_equip = 2
end
else
if key == keybinds.jump then
titleCard.duration = true
end
end
end