diff options
Diffstat (limited to 'src/player.lua')
-rw-r--r-- | src/player.lua | 38 |
1 files changed, 0 insertions, 38 deletions
diff --git a/src/player.lua b/src/player.lua deleted file mode 100644 index 16a54dd..0000000 --- a/src/player.lua +++ /dev/null @@ -1,38 +0,0 @@ -local player = { - x = 250, - y = 250, -} - -local SPEED = 170 -local SPRINT_SPEED = 280 - -function player:move(dt,world) - local speed = - (love.keyboard.isScancodeDown("lshift","rshift") and SPRINT_SPEED or SPEED) - local vx = 0 - local vy = 0 - - if love.keyboard.isScancodeDown('w','up') then vy = vy - 1 end - if love.keyboard.isScancodeDown('s','down') then vy = vy + 1 end - if love.keyboard.isScancodeDown('a','left') then vx = vx - 1 end - if love.keyboard.isScancodeDown('d','right') then vx = vx + 1 end - - local sf = math.sqrt(vx*vx+vy*vy) - if sf == 0 then return end - vx = vx / sf - vy = vy / sf - - local tx = self.x + vx * dt * speed - local ty = self.y + vy * dt * speed - - local ax, ay = world:move("player",tx,ty) - self.x = ax - self.y = ay -end - -function player:draw() - love.graphics.setColor(0.91,0.62,0) - love.graphics.rectangle("fill", self.x,self.y, 10,10) -end - -return player |