function DeleteRes()
	DeleteResource("a10007");
	DeleteResource("a10008");
	DeleteResource("a10009");
	DeleteResource("a10010");
	DeleteResource("a10011");
	DeleteResource("mini_complete");
	DeleteResource("mini_skip");
	DeleteResource("arrow2");
	DeleteResource("arrow3");
end;

function mini_create()
	init_mini(1);
	create_mini(8128);
end;
-- CreateConsole()

local ppos = 0;
local rot = 0;
kostil=false;
local priexali = false;
Down = 0;
Left = 90;
Up = 180;
Right = 270;
Direction = Down;
Direction_o = Down;
Way = nil;
local pos = 0;
local pos_o = 0;
local xx=178;
local yy=78;
flags.start_mini=true;
i=0;
WaitRender();

function gameinput(sender, obj_id, attachedID)
MiniInterfaceHandler( sender, obj_id );

	-- if sender==1 or sender==8128 then
		-- PolyCoord(1)	
	-- return;end
	
	if sender == 33 then
		if plushes_were_closed then
			clear_satelite_leaf("peak");		
		else
			MiniInterfaceHandler( sender, obj_id );
			
		
					speciale_action(2,obj.arrow_m.id,true);
					StartAnimation(obj.arrow_m.id);	
					playeffect("018")
			-- end
			
			
			CreateWindow(CWX,CWY,"300",10,nil,100,230);
		
		end;
	end;
	
		
	
	
	if sender == 26 then
		if i==3 then
			RemoveWindow(8,2.8,"DestroyMyWindow")
		return;end
		
	
			if i==1 then		
				set_text(1000025,"666")
				c1(set_text(1000025,"666"))
				speciale_action(2,obj.arrow_m1.id)
				i=i+1
			return;end
		if i==2 then
			RemoveWindow(8,2.8,"DestroyMyWindow")
			i=i+1
		return;end
			speciale_action(2,obj.arrow_m.id)	
			StartAnimation(obj.arrow_m1.id);
			playeffect("018")
			set_text(1000025,"301")			
			c1(set_text(1000025,"301"))		
			speciale_action(2,obj.arrow_m1.id,true)				
			i=i+1;		
	
	
	return; end;
	
	if sender == 10 then 
		flags.mini1 = true;
		mini_start=false;
			-- clear_satelite_leaf("peak");
			LevelEnd(1)
		flags.mini_go=false;
		flags.mini0=true;
	return; end;
	
	if sender==30 then
		if mini_start then
			setstatemenu()
			StopAllEffects()
			StopMusic()
			mini_start=false;
		return;end
		
		delete_tree_leaf("Root",nazvlevela);	
		NextLevel(30)	
	return;end
	
	
	if sender==41 and not priexali then
	if obj_id ==10007 then
		BlockCursor(false)
		if xx==486 and yy==682  then
		-- c("")
				StartTravel(10007,1,nil,nil, { "InstantiationOfLine",2, xx,yy,502,704,3,true});
				kostil=true
				xx=502
				yy=704				
		end
		
		if xx==502 and yy==704  then
				kostil1=true;
				StartTravel(10007,1,nil,nil, { "InstantiationOfLine",2, 502,704,591,704,1,true});				
				pos=55
		end
	end
	if pos == 55 then
			priexali= true
			finish_mini_game(true);
	end;
	return;end
	
	if sender == 7 then
	
		-- if kostil then xx=494; yy=704; px[pos]=591  ;py[pos]=704 
				-- StartTravel(10007,1,nil,nil, { "InstantiationOfLine",2, xx,yy,px[pos],py[pos],1,true});
				-- set_visible_object(100077, false);
				-- set_visible_object(10007, true);
				-- xx=px[pos];
				-- yy=py[pos];	
				-- pos = 55
				-- playeffect("029")
				-- BlockCursor(true)
				
		-- return;end;
		ppos = MyMove(Direction,Way,pos);
		
		
	
	
		
		if ppos == nil then
			return;
		else
			if ppos < 0 or ppos > 55 then
				return;
			else
				pos_o = pos;				
				pos = ppos;	
				if kostil then xx=486; yy=704; px[pos]=591  ;py[pos]=704 end
				StartTravel(10007,1,nil,nil, { "InstantiationOfLine",2, xx,yy,px[pos],py[pos],1,true});
				set_visible_object(100077, false);
				set_visible_object(10007, true);
				xx=px[pos];
				yy=py[pos];
				
				
				
				playeffect("029")
				BlockCursor(true)
				
			end;
		end;
	return; end;
		
	-- if sender == 1 then
	
		-- BlockCursor(false)
		-- MiniInterfaceHandler( 1, obj_id );
	-- end;
	if sender == 1 then
		
	-- Move()
		if obj_id==554 then		
			local x,y = GetCursorPos();
			if x>=0 and x<=126 and attachedID>=0 and y<=54  or x>=0 and x<=239 and attachedID>=629 and y<=768 then
			return; end;
			addactivobjecttogame(id_point,"point",x-11,y-12,"","");
			speciale_action(4,id_point)
			speciale_action(2,id_point,true)
			id_point=id_point+1;
			local part = -1;
			if x == px[pos] then
				x = x + 1;
			end;
			if y == py[pos] then
				y = y + 1;
			end;
			if x > px[pos] and y > py[pos] then
				part = 4;
			end;
			if x < px[pos] and y > py[pos] then
				part = 3;
			end;
			if x < px[pos] and y < py[pos] then
				part = 2;
			end;
			if x > px[pos] and y < py[pos] then
				part = 1;
			end;
			
			x = px[pos] - x;
			if x < 0 then
				x = -x;
			end;
			y = py[pos] - y;
			if y < 0 then
				y = -y;
			end;
			SetHotPoint(10007,9,15);
				if part == 1 then
					if x >= y then
						Way = Right;
					else
						Way = Up;
					end;
				end;

				if part == 2 then
					if x >= y then
						Way = Left;
					else
						Way = Up;
					end;
				end;

				if part == 3 then
					if x >= y then
						Way = Left;
					else
						Way = Down;
					end;
				end;

				if part == 4 then
					if x >= y then
						Way = Right;
					else
						Way = Down;
					end;
				end;
				Direction_o = Direction;
				Direction = Way;
				RotateObject(10007,Direction, Way,1);
			end	
	return; end;

return; end;


-- function Move()

-- height,width= GetObjectSize(10007)
-- x,y=GetObjectPosition(10007)

-- c("height= "..height.." width= "..width.."\n")
-- c("x= "..x.." y= "..y.."\n")
-- c("x+(height/2)= "..x+(height/2).." y+(width/2)= "..y+(width/2).."\n")
-- StartTravel(10007,2,nil,nil,{"InstantiationOfCircleR",3,x+(height/2),y+(width/2),x+(height/2 )+10,y+(width/2)+10,30*0.0175, 60*0.0175, 6,false},{"InstantiationOfLine",2,-20,-20,140,430,8,false})	
-- StartTravel(obj.delta.id,1,nil,"Dust",{"InstantiationOfLine",2,-20,-20,140,430,8,false})
-- StartTravel(10007,1,nil,nil, { "InstantiationOfLine",2, x,y,x+10,y+10,2,true});
-- end

