From 0a25d11ac5646588112a1992be2bdc005adbd032 Mon Sep 17 00:00:00 2001 From: Simon Kellet Date: Mon, 22 Jul 2024 23:29:55 +0100 Subject: [PATCH] hitbox now circle and slower going backwards --- player.lua | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/player.lua b/player.lua index 0c6d37a..681ac25 100644 --- a/player.lua +++ b/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