lots of rewrite

This commit is contained in:
Paul Liverman
2015-05-06 23:13:50 -07:00
parent 013e24e285
commit da9e427512
10 changed files with 916 additions and 189 deletions

View File

@@ -1,11 +1,35 @@
return function(x, y, rotation)
local self = {}
local class = require "lib.middleclass"
local Node = class('Node')
function Node:initialize(x, y, rotation)
self.x = x or 0
self.y = y or 0
self.rotation = rotation or 0
self.docked = false
return self
self.dockedShip = false
end
--TODO docking needs to check distance between ships and only allow
-- docking when close enough
function Node:dock(Ship)
if self.dockedShip or Ship.dockedTo then
error("Attempted to dock to Node with something already docked to it!")
else
self.dockedShip = Ship
Ship.dockedTo = self
Ship:setPosition(self.x, self.y, self.rotation)
end
end
function Node:undock()
if not self.dockedShip then
error("Attempted to undock a ship from a Node with no docked ship.")
else
self.dockedShip.dockedTo = false
self.dockedShip = false
end
end
return Node