X-Git-Url: http://git.purplebirdman.com/lightcycles-love.git/blobdiff_plain/0c014b54ddd52d3ca1ed007a7c2562dfa9514c99..18a43fb911d7fe4acd109e1a319d0cae4ead35e9:/player.lua diff --git a/player.lua b/player.lua index 387b54f..0a37a0b 100644 --- a/player.lua +++ b/player.lua @@ -1,7 +1,7 @@ require 'vec2' Player = {} -Player.name = 'player' +Player.name = 'none' Player.color = {255, 0, 0} Player.width = 5 Player.height = 5 @@ -30,6 +30,10 @@ function Player:new(o) return o end +function Player:__tostring() + return self.name +end + function Player:drawPath() if #self.path >= 4 then love.graphics.setLineWidth(2) @@ -40,7 +44,13 @@ end function Player:draw() love.graphics.setColor(self.color) - love.graphics.rectangle('fill', self.position.x, self.position.y, self.width, self.height) + love.graphics.rectangle( + 'fill', + self.position.x-self.width/2, + self.position.y-self.height/2, + self.width, + self.height + ) -- add current position self:recordPosition() @@ -50,8 +60,8 @@ function Player:draw() end function Player:recordPosition() - table.insert(self.path, self.position.x + self.width/2) - table.insert(self.path, self.position.y + self.height/2) + table.insert(self.path, self.position.x) + table.insert(self.path, self.position.y) end function Player:multiple_keys_are_pressed()