

EditorMarker = Entity:createSubClass();

function EditorMarker:init()
   self:setSize(64, 64);
   self:setSpriteFrame(0, 0, 64, 64);
   self:setFullbright(true);
   
   -- up/down
   self.ud = 0;

   -- left/right
   self.lr = 0;

end

function EditorMarker:update()

   local sx, sy = self:getSize();
   local x, y = self:getPos();

   if self.ud == -1 then
      
      y = levelActiveArea[2] * -1 - sy/2;

   elseif self.ud == 1 then

      y = levelActiveArea[2] + sy/2;

   end


   if self.lr == -1 then
      
      x = levelActiveArea[1] * -1 - sx/2;

   elseif self.lr == 1 then

      x = levelActiveArea[1] + sx/2;

   end
   

   self:setPos(x, y);

end

function updateTempMarkers()

   local forceRebuild = false;

   for i = 1,#levelEdgeMarkerEnts do
      if levelEdgeMarkerEnts[i] then
         if levelEdgeMarkerEnts[i]:getDead() then
            -- One of the markers became dead somehow.
            levelEdgeMarkerEnts[i] = nil;
            forceRebuild = true;
         end
      else
         -- One of the markers became nil somehow.
         forceRebuild = true;
      end
   end

   if (#levelEdgeMarkerEnts < 4) or (forceRebuild) then
      
      for i = 1,#levelEdgeMarkerEnts do
         if levelEdgeMarkerEnts[i] then
            levelEdgeMarkerEnts[i]:die();
         end
      end

      levelEdgeMarkerEnts = {};

      for i = 1,4 do

         local ent = EditorMarker:create();

         if (i == 1) or (i == 2) then
            ent.lr = -1;
         else
            ent.lr = 1;
         end

         if (i == 2) or (i == 3) then
            ent.ud = -1;
         else
            ent.ud = 1;
         end

         levelEdgeMarkerEnts[#levelEdgeMarkerEnts + 1] = ent;

      end

   end

end


