function OnSceneLoad(screen)
	play_field.game_state = game_state;
	
	SIZE_X = 24;
	SIZE_Y = 15;
	
	--Запоминает непроходимые тупики
	REMEMBER = 1;
	SHARK_SPEED = 20 / 100;
	
    game_state = {}    
    LoadData(screen)
    local pf = play_field
    local level = pf:GetLevelScreen()
    game_state.custom_cursors = {}
    game_state.locked_objects = {}
    game_state.active_objects = {}
    --level:AddTaskSafe(CreateTask('', '', ''))
    --zone = CreateZoomZone('')
    game_state.locker = ReferenceCounter()
    game_state.active_zone = nil
    game_state.inventory_zones = {}
	game_state.screen = screen;
	game_state.game_completed = false;
	game_state.game_skip  = false;
	game_state.timer = screen:GetTimer()
	
	AddMiniGamesGUI(screen);
    
    game_state.HELP_STRING = "HELP_MINIGAME_34";
    
    --игровое поле
    current_color = 0;
	X = 1;
    R = 2;
    G = 3;
    B = 4;
    
    Field = {};
    Field[1] = {X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X}
    Field[2] = {X, 0, 0, 0, R, 0, 0, 0, 0, 0, 0, 0, 0, 0, G, 0, X, 0, X, 0, X, X, X, X}
    Field[3] = {X, 0, X, 0, X, 0, X, X, X, 0, X, X, X, X, X, 0, X, 0, X, 0, X, X, X, X}
    Field[4] = {X, 0, X, 0, X, 0, 0, 0, X, 0, B, 0, 0, 0, X, 0, X, 0, B, 0, X, X, X, X}
    Field[5] = {X, G, X, X, X, 0, X, X, X, 0, X, 0, X, X, X, 0, X, 0, X, 0, X, X, X, X}
    Field[6] = {X, 0, 0, 0, B, 0, 0, 0, 0, 0, X, 0, 0, 0, 0, 0, R, 0, X, 0, X, X, X, X}
    Field[7] = {X, 0, X, X, X, 0, X, X, X, X, X, G, X, X, X, X, X, 0, X, R, X, X, X, X}
    Field[8] = {X, 0, X, 0, 0, 0, X, 0, 0, 0, 0, 0, X, 0, 0, 0, 0, 0, X, 0, X, X, X, X}
    Field[9] = {X, 0, X, X, X, X, X, 0, X, 0, X, 0, X, 0, X, X, X, 0, X, 0, 0, 0, 0, X}
    Field[10]= {0, 0, R, 0, 0, 0, 0, 0, X, R, X, 0, X, B, X, 0, R, 0, X, 0, X, X, 0, X}
    Field[11]= {X, X, X, X, X, 0, X, 0, X, 0, X, 0, X, 0, X, 0, X, 0, X, 0, X, X, X, X}
    Field[12]= {X, 0, 0, 0, 0, 0, X, 0, X, 0, X, 0, 0, 0, X, 0, X, 0, X, G, X, X, X, X}
    Field[13]= {X, G, X, X, X, X, X, X, X, 0, X, X, X, X, X, 0, X, B, X, 0, X, X, X, X}
    Field[14]= {X, 0, 0, 0, 0, 0, 0, B, 0, 0, 0, 0, 0, 0, 0, 0, X, 0, 0, 0, X, X, X, X}
    Field[15]= {X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X}
    
    Turn = {};
    
    Shark = {};
    Shark.Pos = {2, 10};
    Shark.Obj = screen:GetObject('shark_up');
    Shark.Obj:GetAnimation():Stop();
    Shark.IsPlayed = false;
    Shark.Obj:SetXY(Shark.Pos[1] * 39 + 35, Shark.Pos[2] * 36 + 24);
    Shark.OldDirection = 3;
    Shark.Direction = 1;
	
	switch_1 = screen:GetObject('rychag_2');
	switch_2 = screen:GetObject('rychag');
	cage =  screen:GetObject('kletka');
	
	switch_1:SetOpacity(0.0);
	switch_2:SetOpacity(1.0);
	
	switch_flag = false;
	catch_shark = false;
	
	minigames_gui.skip_pause = true;
	
	InitChain1(screen)	
	InitChain2(screen)	
	AddSheriffEyeLogic(screen)
	
	move_effector = nil;
    
	ShowAll();
	
	TimerDo(game_state.timer, SKIP_START_TIME + 0.1, ShowComics1);
    screen:SetLayer(2);
end                 

function InitChain1(screen)
    local comics1 = CreateComics(screen,                                                                  
                                 'Sheriff',
								 'eyes')
								 
	local comics2 = CreateComics(screen,                                                                  
                                 'akula')    

	comics2.OnHidden = function()
		minigames_gui.skip_pause = false;
		game_state.locker:Release()
		Shark.Obj:GetAnimation():Play();
		Shark.IsPlayed = true;
		Move()
	end
   
    game_state.chain1 = CreateChain('pixel',
                                    screen,
                                    comics1, GetString("COMICS_34_8"),
									comics2, GetString("COMICS_34_9"))				            									
	
end

function ShowComics1()
	game_state.chain1.Start();
end

function InitChain2(screen)
    local comics2 = CreateComics(screen,                                                                  
                                 'Sheriff',
								 'eyes')
								 
	local comics1 = CreateComics(screen,                                                                  
                                 'akula')
                                 
    comics2.OnHidden = function()
		game_state.locker:Release()    
		OnCompletedGame();
    end	               
    
    game_state.finish_dialog = CreateChain('pixel_2',
                                    screen,
                                    comics1, GetString("COMICS_34_10"),
									comics2, GetString("COMICS_34_11"))			
end

function OnScreenShown()
end

function InitTurns()
	local Buf = {false, false, false, false}
	Turn[4] = Shark.OldDirection;
	Buf[Shark.OldDirection] = true;
	
	for i = 1, 3 do
		local rand = 0;
		repeat
			rand = math.random(4);	
		until Buf[rand] == false;
		Buf[rand] = true;
		Turn[i] = rand;
	end
end

function Move()
	if(game_state.game_completed  == false and game_state.game_skip == false) then
		Shark.Obj:SetXY(Shark.Pos[1] * 39 + 35, Shark.Pos[2] * 36 + 24); -- корректируем кординаты
		
		InitTurns();
		
		--Находим все возможные пути в заданном направлении
		local BufArray = {};
		local Counter = 0;
		repeat
			Counter = Counter + 1;
			if(Counter > 4) then
				break;
			end
			FindPath(BufArray, Turn[Counter]);
		until table.getn(BufArray) > 0
		
		Path = GetPath(BufArray);--выбираем путь
		
		--Shark.Pos[1] = Shark.Pos[1] + Path.RangeX;
		--Shark.Pos[2] = Shark.Pos[2] + Path.RangeY;
		--Shark.Obj:Move(Path.RangeX * 39, Path.RangeY * 36, Time);
		Shark.Direction = Path.Dir;
			
		if(Path.RangeX < 0) then
			Shark.OldDirection = 1;
		end
		if(Path.RangeX > 0) then
			Shark.OldDirection = 3;
		end
		if(Path.RangeY < 0) then
			Shark.OldDirection = 2;
		end
		if(Path.RangeY > 0) then
			Shark.OldDirection = 4;
		end
		
		Shark.Obj:SetAngle(Shark.OldDirection * M_PI / 2 + M_PI);
		
		MoveUpdate();
	end
	--GTimerDoString("Move()", Time);
end

function MoveObj(obj, dx, dy, time)
    -- TODO: Need using adopt policy
    
    move_effector = CreateAnimationEffector()--AnimationEffector()
    move_effector:AttachTo(obj)
    move_effector:SetKey(_TRACK_X, 0.0, obj:GetX())
    move_effector:SetKey(_TRACK_Y, 0.0, obj:GetY())
    move_effector:SetKey(_TRACK_X, time, obj:GetX() + dx)
	move_effector:SetKey(_TRACK_Y, time, obj:GetY() + dy)
    move_effector:Play()
end

function MoveUpdate()
	if(game_state.game_completed  == false and game_state.game_skip == false) then
	
		if(Path.RangeX > 0.0) then
			Path.RangeX = Path.RangeX - 1.0;
			if(Field[Shark.Pos[2]][Shark.Pos[1] + 1] > 0) then
				Move();
				return;
			end
			Shark.Pos[1] = Shark.Pos[1] + 1; 
			MoveObj(Shark.Obj, 39.0, 0.0, SHARK_SPEED);
		end
		
		if(Path.RangeX < 0.0) then
			Path.RangeX = Path.RangeX + 1.0;
			if(Field[Shark.Pos[2]][Shark.Pos[1] - 1]  > 0) then
				Move();
				return;
			end
			Shark.Pos[1] = Shark.Pos[1] - 1; 
			MoveObj(Shark.Obj, -39.0, 0.0, SHARK_SPEED);
		end
		
		if(Path.RangeY > 0.0) then
			Path.RangeY = Path.RangeY - 1.0;
			if(Field[Shark.Pos[2] + 1][Shark.Pos[1]] > 0) then
				Move();
				return;
			end
			Shark.Pos[2] = Shark.Pos[2] + 1; 
			MoveObj(Shark.Obj, 0.0, 36.0, SHARK_SPEED);
		end
		
		if(Path.RangeY < 0.0) then
			Path.RangeY = Path.RangeY + 1.0;
			if(Field[Shark.Pos[2] - 1][Shark.Pos[1]] > 0) then
				Move();
				return;
			end
			Shark.Pos[2] = Shark.Pos[2] - 1; 
			MoveObj(Shark.Obj, 0.0, -36.0, SHARK_SPEED);
		end
	
	
		if(Path.RangeX ~= 0 or Path.RangeY ~= 0) then
			TimerDo(game_state.timer, SHARK_SPEED, MoveUpdate);
		else
			TimerDo(game_state.timer, SHARK_SPEED, Move);
		end
	end
end

function GetPath(Array)
	if(table.getn(Array) > 0) then
		return Array[math.random(table.getn(Array))];
	else
		return nil;
	end
end

function FindPath(Array, Direction)
	
	if Direction == 1 then --смотрим вправо
		for i = Shark.Pos[1] + 1, SIZE_X do
			if(LookAflat(Array, i, Shark.Pos[2]) == nil) then
				break;
			end
		end		
	end
	
	if Direction == 3 then --смотрим влево
		for i = Shark.Pos[1] - 1, 1, -1 do
			if(LookAflat(Array, i, Shark.Pos[2]) == nil) then
				break;
			end
		end		
	end
	
	if Direction == 2 then --смотрим низ
		for j = Shark.Pos[2] + 1, SIZE_Y do
			if(LookUpright(Array, Shark.Pos[1], j) == nil) then
				break;
			end
		end		
	end
	
	if Direction == 4 then --смотрим вверх
		for j = Shark.Pos[2] - 1, 1, -1 do
			if(LookUpright(Array, Shark.Pos[1], j) == nil) then
				break;
			end
		end		
	end
end


function LookAflat(Array, i, j)
	if(Field[j] == nil or Field[j][i] == nil) then
		return nil;
	else
		if (Field[j][i] > 0 and math.abs(i - Shark.Pos[1]) > 2) then
			local rangeX = i - Shark.Pos[1]; 
			if(rangeX < 0) then
				rangeX = rangeX + 1
			else
				rangeX = rangeX - 1;
			end
			AddPath(Array, Shark.Direction, rangeX, 0.0);
		else
			if (Field[j - 1][i] ~= 1) then
				AddPath(Array, 2, i - Shark.Pos[1], 0.0);
			end
			if (Field[j + 1][i] ~= 1) then
				AddPath(Array, 4, i - Shark.Pos[1], 0.0);
			end
		end
	end
	
	if(Field[j][i] > 0) then
		return nil
	else
		return 1;
	end;
end

function LookUpright(Array, i, j)
	if(Field[j] == nil) then
		return nil;
	else
		if(Field[j][i] > 0 and math.abs(j - Shark.Pos[2]) > 2) then
			local rangeY = j - Shark.Pos[2]; 
			if(rangeY < 0) then
				rangeY = rangeY + 1
			else
				rangeY = rangeY - 1;
			end
			AddPath(Array, Shark.Direction, 0.0, rangeY);
		else
			if (Field[j][i - 1] ~= 1) then
				AddPath(Array, 3, 0.0, j - Shark.Pos[2]);
			else
				if (Field[j][i + 1] ~= 1) then
					AddPath(Array, 1, 0.0, j - Shark.Pos[2]);
				end
			end
		end
	end
	
	if(Field[j][i] > 0) then
		return nil
	else
		return 1;
	end;
end

function AddPath(Array, Dir, rangeX, rangeY)
	Array[table.getn(Array) + 1] = {};
	Array[table.getn(Array)].Dir = Dir;
	Array[table.getn(Array)].RangeX = rangeX;
	Array[table.getn(Array)].RangeY = rangeY; 
end

function ShowAll()
	local RED_AMOUNT = 6;
	local GREEN_AMOUNT = 5; 
	local BLUE_AMOUNT = 6;
	
	for i = 1, RED_AMOUNT do	
		game_state.screen:GetObject(i..'_red2'):SetVisible(false);
		game_state.screen:GetObject(i..'_gate_Red'):SetVisible(true);
	end
	
	for i = 1, GREEN_AMOUNT do	
		game_state.screen:GetObject(i..'_green2'):SetVisible(false);
		game_state.screen:GetObject(i..'_gate_Green'):SetVisible(true);
	end
	
	for i = 1, BLUE_AMOUNT do	
		game_state.screen:GetObject(i..'_blue2'):SetVisible(false);
		game_state.screen:GetObject(i..'_gate_Blue'):SetVisible(true);
	end
	
	for i = 1, SIZE_X do
		for j = 1, SIZE_Y do
			if(Field[j][i] < 0) then	
				Field[j][i] = Field[j][i] + 10;
			end
		end
	end
end

function HideGate(color)
	if(current_color ~= color) then
		local RED_AMOUNT = 6;
		local GREEN_AMOUNT = 5; 
		local BLUE_AMOUNT = 6;
		
		if color == R then
			for i = 1, RED_AMOUNT do	
				game_state.screen:GetObject(i..'_red2'):SetVisible(true);
				game_state.screen:GetObject(i..'_gate_Red'):SetVisible(false);
			end
			current_color = R;
		end
		if color == G then
			for i = 1, GREEN_AMOUNT do	
				game_state.screen:GetObject(i..'_green2'):SetVisible(true);
				game_state.screen:GetObject(i..'_gate_Green'):SetVisible(false);
			end
			current_color = G;

		end
		if color == B then
			for i = 1, BLUE_AMOUNT do	
				game_state.screen:GetObject(i..'_blue2'):SetVisible(true);
				game_state.screen:GetObject(i..'_gate_Blue'):SetVisible(false);
			end
			current_color = B;
		end
		
		for i = 1, SIZE_X do
			for j = 1, SIZE_Y do
				if(Field[j][i] == color) then	
					Field[j][i] = Field[j][i] - 10;
				end
			end
		end
	else
		current_color = 0;
	end
end

function OnSceneFree(screen)
    FreeData(screen)
end

function OnUpdate(dt)
	if(game_state.game_completed == true and move_effector ~= nil) then
		move_effector:Stop();
		move_effector:Destroy();
		move_effector = nil;
	end
end

function OnExit()
end

function OnObjectMouseEnter(object)
    DefaultOnObjectMouseEnter(object)
    local obj_name = object:GetName();
 
    if(obj_name == "knopka_red") or (obj_name == "knopka_green") or (obj_name == "knopka_blue") then
		object:SetOpacity(0.1);
	end
end

function OnObjectMouseLeave(object)
    DefaultOnObjectMouseLeave(object)
    local obj_name = object:GetName();
	if(obj_name == "knopka_red") or (obj_name == "knopka_green") or (obj_name == "knopka_blue") then
		object:SetOpacity(1.0);
	end
end

function OnObjectMouseDown(object)
    obj_name = object:GetName()
    local pf = play_field
    local is_wrong_click = true

    is_wrong_click = DefaultOnObjectMouseDown(object)

	if(game_state.game_completed == true or game_state.game_skip == true) then
		return;
	end

	local ButtonPressSound = function()
		local s = CreateSoundEntity("34_ButtonPress")
		s:AttachTo(play_field)
		s:Play(false)
	end
	
	local LeverPressSound = function()
		local s = CreateSoundEntity("34_LeverPress")
		s:AttachTo(play_field)
		s:Play(false)
	end
	
	if(obj_name == "knopka_red") then
		ButtonPressSound()
		ShowAll();
		HideGate(R);
	end
	if(obj_name == "knopka_green") then
		ButtonPressSound()
		ShowAll();
		HideGate(G);
	end
	if(obj_name == "knopka_blue") then
		ButtonPressSound()
		ShowAll();
		HideGate(B);
	end
	
	if(obj_name == 'rychag' and switch_flag == false) then
		LeverPressSound()
		switch_2:ChangeOpacity(1.0, 0.0, 0.2);
		switch_1:ChangeOpacity(0.0, 1.0, 0.2);
		DropCage();		
	end
	
	if(obj_name == 'rychag_2' and switch_flag == false) then
		LeverPressSound()
		switch_2:ChangeOpacity(0.0, 1.0, 0.2);
		switch_1:ChangeOpacity(1.0, 0.0, 0.2);
		LiftCage()
	end
	
    if is_wrong_click then
        --pf:ShowWrongObjectEffect()
    end    
end

function DropCage()
	cage:Move(0.0, 115.0, 0.2);
	Field[9][22] = X;
	Field[9][23] = X;
	Field[10][23] = X;
	if(Shark.Pos[1] > 21 and Shark.Pos[1] < 24 and Shark.Pos[2] > 8 and Shark.Pos[2] < 11) then
		catch_shark = true;
		switch_flag = true;
		game_state.game_completed = true;
		TimerDoString("ShowDoneButton()", 0.5, game_state.screen:GetTimer());
		Shark.Obj:GetAnimation():Stop();
		Shark.Obj:SetXY(931.0, 365.0);
		Shark.Obj:SetAngle(M_PI);
		Shark.Obj:ChangeOpacity(0.0, 1.0, 0.2);
		move_effector:Stop();
		move_effector:Destroy();
		move_effector = nil;
		Shark.IsPlayed = false;
	end
end

function LiftCage()
	cage:Move(0.0, -115.0, 0.2);
	Field[9][22] = 0;
	Field[9][23] = 0;
	Field[10][23] = 0;
end

function SkipMiniGame()
	if(game_state.game_skip == false) then
		cage:SetXY(cage:GetX(), cage:GetY() + 115.0);
		catch_shark = true;
		switch_flag = true;
		game_state.game_skip  = true;
		Shark.Obj:GetAnimation():Stop();
		Shark.Obj:SetXY(931.0, 365.0);
		Shark.Obj:SetAngle(M_PI);
		Shark.Obj:ChangeOpacity(0.0, 1.0, 0.2);
		move_effector:Stop();
		move_effector:Destroy();
		move_effector = nil;
		Shark.IsPlayed = false;
		
		return 0.5;
	end
	
	return -1.0; 
end

function OnObjectMouseUp(object)
end

function OnObjectWillBeFound(object)
end

function OnToolFound(tool)
end

function OnToolApply(tool, object)
    DefaultOnToolApply(tool, object)
end

function OnObjectReachPanel(object)
end

function OnButtonPress(title)
    DefaultOnButtonPress(title)
    OnMiniGameButtonPress(title);
end

function OnMouseMove(previous_pos, current_pos)
end

function OnSetTool(tool)
end

function CanBeHinted(obj)
    if locked_object[obj] ~= true then
        return true
    else
        return false
    end
end

function OnLostFocus()
	Shark.Obj:GetAnimation():Stop();
end

function OnGainFocus()
	Shark.Obj:GetAnimation():Play();
	if( Shark.IsPlayed == true) then
		Shark.Obj:GetAnimation():Play();
	end
end

-- CLEAR_ON_SAVE_BEGIN
-- Do not edit code listed below (generated by the editor on each save)
function LoadData(screen)
	local anim = CreateAnimation('data/Texture/Minigames/34_labirint/labirint_bak.jpg',0,0,1024,768,1,0)
	anim:SetHotSpot(512,384)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('labirint_bak',anim,512,384,99,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/34_labirint/migalka_red_2.png',0,0,39,30,1,0)
	anim:SetHotSpot(19,15)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('1_red',anim,154,351,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/34_labirint/migalka_red.png',0,0,75,71,1,0)
	anim:SetHotSpot(37,35)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('1_red2',anim,155,351,101,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/34_labirint/migalka_red_2.png',0,0,39,30,1,0)
	anim:SetHotSpot(19,15)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('2_red',anim,233,58,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/34_labirint/migalka_red.png',0,0,75,71,1,0)
	anim:SetHotSpot(37,35)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('2_red2',anim,236,57,101,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/34_labirint/migalka_red_2.png',0,0,39,30,1,0)
	anim:SetHotSpot(19,15)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('3_red',anim,468,377,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/34_labirint/migalka_red.png',0,0,75,71,1,0)
	anim:SetHotSpot(37,35)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('3_red2',anim,468,377,101,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/34_labirint/migalka_red_2.png',0,0,39,30,1,0)
	anim:SetHotSpot(19,15)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('4_red',anim,702,419,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/34_labirint/migalka_red_2.png',0,0,39,30,1,0)
	anim:SetHotSpot(19,15)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('5_red',anim,701,202,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/34_labirint/migalka_red.png',0,0,75,71,1,0)
	anim:SetHotSpot(37,35)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('4_red2',anim,703,420,101,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/34_labirint/migalka_red.png',0,0,75,71,1,0)
	anim:SetHotSpot(37,35)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('5_red2',anim,703,202,101,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/34_labirint/migalka_red_2.png',0,0,39,30,1,0)
	anim:SetHotSpot(19,15)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('6_red',anim,859,277,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/34_labirint/migalka_red.png',0,0,75,71,1,0)
	anim:SetHotSpot(37,35)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('6_red2',anim,861,274,101,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/34_labirint/migalka_green_2.png',0,0,40,36,1,0)
	anim:SetHotSpot(20,18)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('1_green',anim,151,200,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/34_labirint/migalka_green.png',0,0,54,55,1,0)
	anim:SetHotSpot(27,27)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('1_green2',anim,151,200,101,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/34_labirint/migalka_green_2.png',0,0,40,36,1,0)
	anim:SetHotSpot(20,18)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('2_green',anim,146,491,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/34_labirint/migalka_green.png',0,0,54,55,1,0)
	anim:SetHotSpot(27,27)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('2_green2',anim,148,491,101,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/34_labirint/migalka_green_2.png',0,0,40,36,1,0)
	anim:SetHotSpot(20,18)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('3_green',anim,542,274,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/34_labirint/migalka_green.png',0,0,54,55,1,0)
	anim:SetHotSpot(27,27)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('3_green2',anim,542,273,101,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/34_labirint/migalka_green_2.png',0,0,40,36,1,0)
	anim:SetHotSpot(20,18)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('4_green',anim,619,56,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/34_labirint/migalka_green.png',0,0,54,55,1,0)
	anim:SetHotSpot(27,27)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('4_green2',anim,620,55,101,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/34_labirint/migalka_green_2.png',0,0,40,36,1,0)
	anim:SetHotSpot(20,18)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('5_green',anim,856,450,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/34_labirint/migalka_green.png',0,0,54,55,1,0)
	anim:SetHotSpot(27,27)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('5_green2',anim,856,448,101,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/34_labirint/migalka_blue_2.png',0,0,34,37,1,0)
	anim:SetHotSpot(17,18)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('1_blue',anim,233,200,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/34_labirint/migalka_blue.png',0,0,76,71,1,0)
	anim:SetHotSpot(38,35)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('1_blue2',anim,233,203,101,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/34_labirint/migalka_blue_2.png',0,0,34,37,1,0)
	anim:SetHotSpot(17,18)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('2_blue',anim,350,490,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/34_labirint/migalka_blue.png',0,0,76,71,1,0)
	anim:SetHotSpot(38,35)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('2_blue2',anim,350,493,101,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/34_labirint/migalka_blue_2.png',0,0,34,37,1,0)
	anim:SetHotSpot(17,18)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('3_blue',anim,464,127,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/34_labirint/migalka_blue.png',0,0,76,71,1,0)
	anim:SetHotSpot(38,35)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('3_blue2',anim,465,130,101,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/34_labirint/migalka_blue_2.png',0,0,34,37,1,0)
	anim:SetHotSpot(17,18)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('4_blue',anim,619,383,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/34_labirint/migalka_blue.png',0,0,76,71,1,0)
	anim:SetHotSpot(38,35)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('4_blue2',anim,620,386,101,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/34_labirint/migalka_blue_2.png',0,0,34,37,1,0)
	anim:SetHotSpot(17,18)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('5_blue',anim,777,128,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/34_labirint/migalka_blue.png',0,0,76,71,1,0)
	anim:SetHotSpot(38,35)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('5_blue2',anim,778,132,101,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/34_labirint/migalka_blue_2.png',0,0,34,37,1,0)
	anim:SetHotSpot(17,18)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('6_blue',anim,777,487,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/34_labirint/migalka_blue.png',0,0,76,71,1,0)
	anim:SetHotSpot(38,35)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('6_blue2',anim,777,491,101,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/34_labirint/vorota_vertikal.png',0,0,54,65,1,0)
	anim:SetHotSpot(27,32)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('1_gate_Red',anim,158,384,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/34_labirint/vorota_vertikal.png',0,0,54,65,1,0)
	anim:SetHotSpot(27,32)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('1_gate_Blue',anim,242,238,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/34_labirint/vorota_vertikal.png',0,0,54,65,1,0)
	anim:SetHotSpot(27,32)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('2_gate_Red',anim,241,93,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/34_labirint/vorota_vertikal.png',0,0,54,65,1,0)
	anim:SetHotSpot(27,32)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('2_gate_Blue',anim,359,527,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/34_labirint/vorota_vertikal.png',0,0,54,65,1,0)
	anim:SetHotSpot(27,32)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('3_gate_Blue',anim,473,165,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/34_labirint/vorota_vertikal.png',0,0,54,65,1,0)
	anim:SetHotSpot(27,32)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('1_gate_Green',anim,630,93,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/34_labirint/vorota_vertikal.png',0,0,54,65,1,0)
	anim:SetHotSpot(27,32)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('3_gate_Red',anim,707,382,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/34_labirint/vorota_vertikal.png',0,0,54,65,1,0)
	anim:SetHotSpot(27,32)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('4_gate_Red',anim,708,237,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/34_labirint/vorota_vertikal.png',0,0,54,65,1,0)
	anim:SetHotSpot(27,32)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('4_gate_Blue',anim,788,166,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/34_labirint/vorota_gorizontal.png',0,0,54,65,1,0)
	anim:SetHotSpot(27,32)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('2_gate_Green',anim,111,493,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/34_labirint/vorota_gorizontal.png',0,0,54,65,1,0)
	anim:SetHotSpot(27,32)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('3_gate_Green',anim,112,204,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/34_labirint/vorota_gorizontal.png',0,0,54,65,1,0)
	anim:SetHotSpot(27,32)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('5_gate_Red',anim,426,379,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/34_labirint/vorota_gorizontal.png',0,0,54,65,1,0)
	anim:SetHotSpot(27,32)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('4_gate_Green',anim,504,273,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/34_labirint/vorota_gorizontal.png',0,0,54,65,1,0)
	anim:SetHotSpot(27,32)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('5_gate_Blue',anim,582,384,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/34_labirint/vorota_gorizontal.png',0,0,54,65,1,0)
	anim:SetHotSpot(27,32)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('6_gate_Blue',anim,737,490,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/34_labirint/vorota_gorizontal.png',0,0,54,65,1,0)
	anim:SetHotSpot(27,32)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('6_gate_Red',anim,817,277,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/34_labirint/vorota_gorizontal.png',0,0,54,65,1,0)
	anim:SetHotSpot(27,32)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('5_gate_Green',anim,816,448,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/34_labirint/shark_up.png',0,0,50,45,6,10)
	anim:SetHotSpot(25,22)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('shark_up',anim,49,383,100,90,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/34_labirint/rychag.png',0,0,62,128,1,0)
	anim:SetHotSpot(31,64)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('rychag',anim,696,663,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/34_labirint/rychag_2.png',0,0,57,63,1,0)
	anim:SetHotSpot(28,31)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('rychag_2',anim,696,704,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/34_labirint/knopka_blue.png',0,0,110,81,1,0)
	anim:SetHotSpot(55,40)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('knopka_blue',anim,364,669,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/34_labirint/knopka_green.png',0,0,105,77,1,0)
	anim:SetHotSpot(52,38)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('knopka_green',anim,478,668,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/34_labirint/knopka_red.png',0,0,99,84,1,0)
	anim:SetHotSpot(49,42)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('knopka_red',anim,583,666,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Minigames/34_labirint/kletka.png',0,0,129,426,1,0)
	anim:SetHotSpot(64,213)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('kletka',anim,936,95,105,0,1,1)
	local anim = CreateAnimation('data/Texture/Comics/Sheriff.dds',0,0,530,636,1,0)
	anim:SetHotSpot(266,256)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('Sheriff',anim,378,390,400,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/Common/pixel.jpg',0,0,8,8,1,0)
	anim:SetHotSpot(4,4)
	anim:SetBlendMode(2)
	anim:SetColor('0x00FFFFFF')
	screen:CreateObject('pixel',anim,512,384,501,0,128,96)
	local anim = CreateAnimation('data/Texture/Scenes/Common/pixel.jpg',0,0,8,8,1,0)
	anim:SetHotSpot(4,4)
	anim:SetBlendMode(2)
	anim:SetColor('0x00FFFFFF')
	screen:CreateObject('pixel_2',anim,512,384,502,0,128,96)
	local anim = CreateAnimation('data/Texture/Comics/eyes.png',0,0,79,33,1,0)
	anim:SetHotSpot(39,16)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('eyes',anim,369,212,500,0,1,1)
	local anim = CreateAnimation('data/Texture/Comics/akula.png',0,0,445,509,1,0)
	anim:SetHotSpot(222,254)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	screen:CreateObject('akula',anim,769,452,400,0,1,1)
end

function FreeData(screen)
end
-- CLEAR_ON_SAVE_END
