it works
This commit is contained in:
parent
c6547c1121
commit
d5e8a6945e
6 changed files with 77 additions and 28 deletions
17
port.lua
17
port.lua
|
|
@ -48,23 +48,24 @@ function Port:new(position, rotation, color)
|
|||
end
|
||||
|
||||
function Port:rotateClockwise()
|
||||
local swap = self.position.x
|
||||
self.position.x = -self.position.y
|
||||
self.position.y = swap
|
||||
self.scanOffset = (self.scanOffset == 1) == self.alignment and 1 or 0
|
||||
self.position.x, self.position.y = -self.position.y, self.position.x
|
||||
self.scanOffset = (self.scanOffset == 1) ~= self.alignment and 1 or 0
|
||||
self.alignment = not self.alignment
|
||||
end
|
||||
|
||||
---@param offset GridPoint
|
||||
function Port:draw( offset )
|
||||
love.graphics.setColor(self.color)
|
||||
local sox = self.alignment and 0 or self.scanOffset
|
||||
local soy = self.alignment and self.scanOffset or 0
|
||||
|
||||
local drawPoint = GridPoint:new(
|
||||
offset.x + self.position.x + self.scanOffset,
|
||||
offset.y + self.position.y + self.scanOffset
|
||||
offset.x + self.position.x + sox,
|
||||
offset.y + self.position.y + soy
|
||||
)
|
||||
local x, y = drawPoint:globalCoords()
|
||||
x = self.alignment and x - Config.cellSize / 2 or x - Config.portWidth / 2 - Config.cellSize / 2
|
||||
y = self.alignment and y - Config.portWidth / 2 - Config.cellSize / 2 or y - Config.cellSize / 2
|
||||
x = self.alignment and x or x - Config.portWidth / 2
|
||||
y = self.alignment and y - Config.portWidth / 2 or y
|
||||
local w = self.alignment and Config.cellSize or Config.portWidth
|
||||
local h = self.alignment and Config.portWidth or Config.cellSize
|
||||
love.graphics.rectangle("fill", x, y, w, h)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue