rsi/player.lua

25 lines
532 B
Lua
Raw Normal View History

2023-08-27 12:32:38 +00:00
player={}
player.x=0
player.y=0
player.speed=0.2
player.direction=0
player.lastMoveTime=0
player.weapon={}
function player.update(dt)
local now=love.timer.getTime()
if (player.direction~=0) and (now-player.lastMoveTime>=player.speed) then
player.move(player.x+player.direction)
end -- check direction
end -- update
function player.move(dx)
player.lastMoveTime=love.timer.getTime()
if dx<0 or dx>game.field.width then
-- boundary shit goes here
else
player.x=dx
2023-08-27 23:00:22 +00:00
love.audio.setPosition(player.x, player.y, 3)
2023-08-27 12:32:38 +00:00
end -- if boundary
end