BUBBLE_PROX_N = 100.0 ;

function wait( seconds )
	local count = 0.0 ;
	while ( count < seconds ) do
		--DEBUG_OUTPUT( "Count: " .. count ) ;
		coroutine.yield( ) ;
		count = count + getDeltaT( ) ;
	end
end

function printiv( i, v )
	if ( ( type( v ) == "number" )
		or ( type( v ) == "string" ) ) then
		DEBUG_OUTPUT( i .. "=" .. v ) ;
	elseif ( type( v ) == "boolean" ) then
		-- can't concatenate boolean - so do it seperate
		local displayValue = "false" ;
		if ( v ) then
			displayValue = "true" ;
		end
		DEBUG_OUTPUT( i .. "=" .. displayValue ) ;
	end
end

function printAllGlobals( )
	DEBUG_OUTPUT( "\n---Globals Start---" ) ;
	table.foreach( _G, printiv ) ;
	DEBUG_OUTPUT( "---Globals End---\n" ) ;
end

function controlToString( controlString )
	if ( controlString == "mouse" ) then
		return getString( "mousecontrol" ) ;
	elseif ( controlString == "arrows" ) then
		return getString( "arrowcontrol" ) ;
	elseif ( controlString == "asdf" ) then
		return getString( "asdfcontrol" ) ;
	else
		return "other" ;
	end
end

function sinkFullTip( )
	if ( isIOS( ) and not areLevelsUnlocked( ) ) then
		-- demo version with just one level
		local numDifferentTips = 4
		local tipNumber = (getNumLevelsPlayed( )-1) % numDifferentTips ;
		if ( tipNumber == 0 ) then
			howToMoveTip( ) ;
		elseif ( tipNumber == 1 ) then
			helperArrowTip( ) ;
		elseif ( tipNumber == 2 ) then
			boostTip( ) ;
		elseif ( tipNumber == 3 ) then
			threeTouchTip( ) ;
		end
	end
end

function howToMoveTip( )
	clearTipVars( ) ;
	setTipTitle( getString( "howtomovetitle" ) ) ;
	if ( isIOS( ) ) then
		if ( getNumPlayers( ) == 1 ) then
			if ( getEffectiveControlMethod( ) == "accelerometer" ) then
				if ( isIPad( ) ) then
					setTipText( getString( "howtomovetiltipad" ) ) ;
				else
					setTipText( getString( "howtomovetiltiphone" ) ) ;
				end
				setTipImage( "tilt" ) ;
			elseif ( getEffectiveControlMethod( ) == "touch" ) then
				setTipText( getString( "howtomoveiostouch" ) ) ;
				setTipImage( "tap" ) ;
			elseif ( getEffectiveControlMethod( ) == "joystick" ) then
				setTipText( getString( "howtomovevirtualjoystick" ) ) ;
				setTipImage( "virtualjoystickmove" ) ;
			elseif ( getEffectiveControlMethod( ) == "physicaljoystick" ) then
				setTipText( getString( "howtomovephysicaljoystick" ) ) ;
				setTipImage( "joypadmove" ) ;
			elseif ( getEffectiveControlMethod( ) == "trackpad" ) then
				setTipText( getString( "howtomovetrackpad" ) ) ;
			end
		else
			setTipText( getString( "tiptwoplayer" ) ) ;
			setTipImage( "tap" ) ;
		end
	else
		if ( getNumPlayers( ) == 1 ) then
			if ( getEffectiveControlMethod( ) == "touch" ) then
				setTipText( getString( "howtomovedownloadabletap" ) ) ;
			else
				-- normal mouse/keyboard
				setTipText( getString( "howtomovetip" ) ) ;
				setTipImage( "mousearrows" ) ;
			end
		else
			setTipText( getString( "howtomovemultitip", getPlayerAnimalName(0), getPlayerAnimalName(1) ) ) ;
			setTipImage( "mousearrows" ) ;
		end
	end
	activateTipWindow( ) ;
end

function boostTip( )
	clearTipVars( ) ;
	if ( isIOS( ) ) then
		setTipTitle( getString( "boosttitle" ) ) ;
		if ( getNumPlayers( ) == 1 ) then
			if ( getEffectiveControlMethod( ) == "accelerometer" ) then
				setTipText( getString( "tiltboosttip" ) ) ;
				setTipImage( "tap" ) ;
				activateTipWindow( ) ;
			elseif ( getEffectiveControlMethod( ) == "joystick" ) then
				setTipText( getString( "virtualjoystickboosttip" ) ) ;
				setTipImage( "virtualjoystickboost" ) ;
				activateTipWindow( ) ;
			elseif ( getEffectiveControlMethod( ) == "physicaljoystick" ) then
				setTipText( getString( "physicaljoystickboosttip" ) ) ;
				setTipImage( "joypadboost" ) ;
				activateTipWindow( ) ;
			end
		end
	else
		setTipTitle( getString( "boosttitle" ) ) ;
		setTipImage( "boosttip" ) ;
		if ( getNumPlayers( ) == 1 ) then
			if ( not ( getEffectiveControlMethod( ) == "touch" ) ) then
				if ( getLastLevelUsingKeyboardTime( ) >= getLastLevelUsingMouseTime( ) ) then
					-- keyboard
					setTipText( getString( "keyboardboosttip" ) ) ;
					setTipImage( "keyboard" ) ;
					activateTipWindow( ) ;
				else
					-- mouse
					setTipText( getString( "mouseboosttip" ) ) ;
					activateTipWindow( ) ;
				end
			end
		else
			-- 2 player
			setTipText( getString( "boostmultitip", getPlayerAnimalName(0), getPlayerAnimalName(1) ) ) ;
			activateTipWindow( ) ;
		end
	end
end

function jumpTip( )
	clearTipVars( ) ;
	if ( isIOS( ) ) then
		setTipTitle( getString( "boosttitle" ) ) ;
		setTipImage( "boosttip" ) ;
		if ( getNumPlayers( ) == 1 ) then
			if ( getEffectiveControlMethod( ) == "accelerometer" ) then
				setTipText( getString( "tiltjumptip" ) ) ;
				setTipImage( "tap" ) ;
				activateTipWindow( ) ;
			elseif ( getEffectiveControlMethod( ) == "joystick" ) then
				setTipText( getString( "virtualjoystickjumptip" ) ) ;
				setTipImage( "virtualjoystickboost" ) ;
				activateTipWindow( ) ;
			elseif ( getEffectiveControlMethod( ) == "physicaljoystick" ) then
				setTipText( getString( "physicaljoystickjumptip" ) ) ;
				setTipImage( "joypadboost" ) ;
				activateTipWindow( ) ;
			end
		end
	else
		setTipTitle( getString( "boosttitle" ) ) ;
		setTipImage( "keyboard" ) ;
		if ( getNumPlayers( ) == 1 ) then
			if ( getTimeSinceUsingKeyboard( ) < 7.0 ) then
				-- keyboard
				setTipText( getString( "keyboardjumptip" ) ) ;
				activateTipWindow( ) ;
			end
		end
	end
end

function hoopJumpTip( )
	clearTipVars( ) ;
	setTipTitle( getString( "hoopjumptitle" ) ) ;
	setTipText( getString( "hoopjumptip" ) ) ;
	setTipImage( "hooptip" ) ;
	activateTipWindow( ) ;
end

function hoopCourseTip( )
	clearTipVars( ) ;
	setTipTitle( getString( "hoopcoursetitle" ) ) ;
	setTipText( getString( "hoopcoursetip" ) ) ;
	activateTipWindow( ) ;
end

function skullHoopJumpTip( )
	clearTipVars( ) ;
	setTipTitle( getString( "skullhoopjumptitle" ) ) ;
	setTipText( getString( "skullhoopjumptip" ) ) ;
	--setTipImage( "hooptip" ) ;
	activateTipWindow( ) ;
end

function helperArrowTip( )
	clearTipVars( ) ;
	setTipTitle( getString( "helperarrowtiptitle" ) ) ;
	setTipText( getString( "helperarrowtip" ) ) ;
	setTipImage( "helperarrowtip" ) ;
	activateTipWindow( ) ;
end

function largerHurtTip( )
	clearTipVars( ) ;
	if ( not isLevelDeadly( ) ) then
		setTipTitle( getString( "largerhurttiptitle" ) ) ;
		setTipText( getString( "largerhurttip" ) ) ;
		setTipImage( "largerentity" ) ;
		activateTipWindow( ) ;
	end
end

function threeTouchTip( )
	clearTipVars( ) ;
	if ( isIOS( ) and isThreeFingerTapPauseOnlyMode( ) ) then
		setTipTitle( "" ) ;
		setTipText( getString( "tipthreetouch" ) ) ;
		setTipImage( "tipthreetouch" ) ;
		activateTipWindow( ) ;
	end
end
