hitbox now circle and slower going backwards

main
Simon Kellet 5 months ago
parent 71d1f6e929
commit 0a25d11ac5
  1. 11
      player.lua

@ -3,19 +3,19 @@ cos = math.cos
sin = math.sin --optimisation
-- Constructor for the Player class
function Player:new(p, x, y, health, image, speed, max)
function Player:new(p, x, y, health, image, speed)
self.p = p
self.image = love.graphics.newImage(image)
self.x = x
self.y = y
self.health = health
self.speed = speed
self.max = max
self.width = self.image:getWidth()
self.height = self.image:getHeight()
-- Collision Stuff
self.collider = World:newRectangleCollider(x, y, 64, 64)
--self.collider = World:newRectangleCollider(x, y, 50, 62)
self.collider = World:newCircleCollider(x, y, 24)
self.collider:setFixedRotation(true)
if self.p == 1 then
@ -61,14 +61,13 @@ function Player:handleKeys(up, down, left, right, dt)
self.vx = cos(self.rotation) * (self.speed * dt)
self.vy = sin(self.rotation) * (self.speed * dt)
elseif love.keyboard.isDown(down) then
self.vx = cos(self.rotation) * (self.speed * dt) * -1
self.vy = sin(self.rotation) * (self.speed * dt) * -1
self.vx = cos(self.rotation) * (self.speed / 2 * dt) * -1
self.vy = sin(self.rotation) * (self.speed / 2 * dt) * -1
elseif love.keyboard.isDown(left) then
self.rotation = self.rotation - (self.rotSpeed * dt)
elseif love.keyboard.isDown(right) then
self.rotation = self.rotation + (self.rotSpeed * dt)
end
self.collider:setLinearVelocity(self.vx, self.vy)
end

Loading…
Cancel
Save