

function OnInit() //before the entity is placed in the world, init visuals here, so it knows the size dimensions
	this:SetPersistent(false); //don't save us with the map
	
		//this:SetImage("lua_script.png", nil); 
	this:SetImage("invisible.png", nil);
	//this:SetAttach(C_ENTITY_CAMERA, Vector2(0,0); //so we are always on screen and processed	
	this:SetName("DoomWall"); //so we can find it by name later
	this:GetBrainManager():Add("DoomWall","walls_block=false");
	local musicFileName = "wall.ogg";
	_G.g_gridSize = 10;
	 _G.g_totalWaves = 10;
  local color = "0=0=100=255";
  if (g_isDebug == true) then
  
  g_level = 7;
  end
  
  if (g_level == 1) then
	//simple
	this:GetBrainManager():SendToBrainByName("DoomWall","set_shape_size=2");
 _G.g_totalWaves = 3;
  
	SetShape(0,0);
	SetShape(1,0); 
	
	//they probably also need help if this is the first time...
		if (_G.g_currentWave == 0) then
		
			local entText = GetEntityByName("help_template"):Clone(nil, GetEntityByName("help_template"):GetPos());
			entText:SetPersistent(false);	
			entText:GetBrainManager():Add("FadeIn", "fade_speed_ms=1000");		
			Schedule(5000, entText:GetID(), "this:GetBrainManager():Add('FadeOutAndDelete','fade_speed_ms=1000')");
	
		end
	end
		

  if (g_level == 2) then
	musicFileName = "wall2.ogg";
	color = "0=100=0=255";

	//simple L shape
	this:GetBrainManager():SendToBrainByName("DoomWall","set_shape_size=2");

	SetShape(0,0);
	SetShape(1,0);  
	SetShape(1,1);  
	end

	 if (g_level == 3) then
		//cross shape

color = "91=4=82=255"; //purple

	this:GetBrainManager():SendToBrainByName("DoomWall","set_shape_size=3");

	SetShape(1,0);
	SetShape(1,1);  
	SetShape(0,1);  
	SetShape(2,1);  
	SetShape(1,2);  
	end

 	 if (g_level == 4) then
musicFileName = "wall3.ogg";
// *--*
// ****
		color = "80=110=0=255";
_G.g_gridSize = 7;

	this:GetBrainManager():SendToBrainByName("DoomWall","set_shape_size=4");

	SetShape(0,0);
	SetShape(3,0);  
	SetShape(0,1);  
	SetShape(1,1);  
	SetShape(2,1);  
	SetShape(3,1);  
	end
	
	 if (g_level == 5) then
musicFileName = "wall2.ogg";
//donut
// ***
// *-*
// ***			
color = "63=58=1=255";  //brown	
	_G.g_gridSize = 8;
	
	this:GetBrainManager():SendToBrainByName("DoomWall","set_shape_size=3");

	SetShape(0,0); SetShape(1,0); SetShape(2,0);
	SetShape(0,1); SetShape(2,1);
	SetShape(0,2); SetShape(1,2); SetShape(2,2);
	
	end
	
		 if (g_level == 6) then

//snake 

// *-
// -*
// --*
		
	_G.g_gridSize = 20;
	this:GetBrainManager():SendToBrainByName("DoomWall","set_shape_size=3");
	SetShape(0,0); 
	SetShape(1,1); 
		SetShape(2,2); 
	end
	
	 if (g_level == 7) then

color = "80=0=0=255";
musicFileName = "wall3.ogg";

//***
// *
// *
		
	_G.g_gridSize = 10;
	this:GetBrainManager():SendToBrainByName("DoomWall","set_shape_size=3");
	SetShape(0,0);  SetShape(1,0); SetShape(2,0);
	SetShape(1,1); 
		SetShape(1,2); 
	end
	
	g_SmartSound:SetMusic("audio/" .. musicFileName, false, false);

	//now we can init the real grid
		this:GetBrainManager():SendToBrainByName("DoomWall","set_color=" .. color .. ";gridSize=" .. tostring(g_gridSize)); //our C++ brain, it also overrides its size

	
end

function SetShape(x,y)

 this:GetBrainManager():SendToBrainByName("DoomWall","set_shape=" .. x .. "=".. y); //our C++ brain, it also overrides its size

end

function OnPostInit() //run during the entity's first logic update
	//this:SetLayerByName("Hidden Data"); //we can only see the image when using the editor
	
	//show one time message in a bit
	//g_SmartSound:SetMusic("audio/moremusic.ogg", true, true);
		
end


function OnKill()  //run when removed
end