--/* Start File Header -------------------------------------------------------
--Copyright (C) 2010 DigiPen Institute of Technology.
--Reproduction or disclosure of this file or its contents without the prior written consent of DigiPen Institute of Technology is prohibited.
--File Name: levelLogic.lua
--Purpose: Lots and lots of functions used for various tasks related to levels and menus.
--Authors: Robert Francis - 60%
--         Bryan Bishop   - 40%
--- End File Header --------------------------------------------------------*/

dofile "Resources\\lua\\defines.lua";

-- Main Menu

function PlayClick (x, y)
	SetNextLevel("goldstory1.xml"); -- Set first level
	EndLevel();
end

function OnOver (go)
  s = GetSpriteComp(go);
  PlaySound("MenuClick");
  SpriteComp_Color(s, Vec4(255, 0, 255, 255));
end

function OnExit (go)
  s = GetSpriteComp(go);
  SpriteComp_Color(s, Vec4(255, 255, 255, 255));
end

function MMOnOver(go)
  PlaySound("MenuClick");
  x, y, z, w = GameObject_Pos4(go);
  Sx, Sy, Sz = GameObject_GetScale(go);
  s = GetSpriteComp(go);
  SpriteComp_SetVars(s, Vec2(0,0), Vec2(.757, .103));
  GameObject_SetScale(go, Vec3(800, 108, 1));
  GameObject_SetPos3(go, Vec3(x+115, y, z));
  SpriteComp_TextColor(s, Vec4(0,0,0,255));
end

function MMOnExit(go)
  x, y, z, w = GameObject_Pos4(go);
  Sx, Sy, Sz = GameObject_GetScale(go);
  s = GetSpriteComp(go);
  SpriteComp_SetVars(s, Vec2(0,0.124), Vec2(.5, .115));
  GameObject_SetScale(go, Vec3(550, 108, 1));
  GameObject_SetPos3(go, Vec3(x-115, y, z));
  SpriteComp_TextColor(s, Vec4(255, 255, 255, 255));
end

function HTPOnOver(go)
  PlaySound("MenuClick");
  s = GetSpriteComp(go);
  SpriteComp_SetVars(s, Vec2(.51,0), Vec2(.49, .375));
  SpriteComp_TextColor(s, Vec4(0,0,0,255));
end

function HTPOnExit(go)
  s = GetSpriteComp(go);
  SpriteComp_SetVars(s, Vec2(0,0), Vec2(.49, .375));
  SpriteComp_TextColor(s, Vec4(255, 255, 255, 255));
end

function YNOnOver(go)
  PlaySound("MenuClick");
  s = GetSpriteComp(go);
  SpriteComp_SetVars(s, Vec2(.5,.125), Vec2(.25, .081));
  SpriteComp_TextColor(s, Vec4(0,0,0,255));
end

function YNOnExit(go)
  s = GetSpriteComp(go);
  SpriteComp_SetVars(s, Vec2(.75,.125), Vec2(.25, .081));
  SpriteComp_TextColor(s, Vec4(255, 255, 255, 255));
end

function BaOnOver(go)
  PlaySound("MenuClick");
  s = GetSpriteComp(go);
  SpriteComp_SetVars(s, Vec2(.625,.25), Vec2(.375, .375));
  SpriteComp_TextColor(s, Vec4(0,0,0,255));
end

function BaOnExit(go)
  s = GetSpriteComp(go);
  SpriteComp_SetVars(s, Vec2(.625,.625), Vec2(.375, .375));
  SpriteComp_TextColor(s, Vec4(255, 255, 255, 255));
end

function PlayButton(name, inst)
	x, y, z = GOGetPos(name, inst);
  go = GetGOPointer(name, inst);
  s = GetSpriteComp(go);
  r, g, b, a = SpriteComp_GetTextColor(s);
  SetFontColor("ethnocentric", r, g, b, a);
	ScreenText("ethnocentric", x, y+15, "PLAY", .5);
	SetPause(false);
end

function OptionsClick(x, y)
	LoadLevel("Options.xml");
end

function OptionsButton(name, inst)
	x, y, z = GOGetPos(name, inst);
  go = GetGOPointer(name, inst);
  s = GetSpriteComp(go);
  r, g, b, a = SpriteComp_GetTextColor(s);
	SetFontColor("ethnocentric", r, g, b, a);
	ScreenText("ethnocentric", x, y+15, "OPTIONS", .5);
end

function CreditsClick(x, y)
	LoadLevel("Credits.xml");
end

function CreditsButton(name, inst)
	x, y, z = GOGetPos(name, inst);
  go = GetGOPointer(name, inst);
  s = GetSpriteComp(go);
  r, g, b, a = SpriteComp_GetTextColor(s);
	SetFontColor("ethnocentric", r, g, b, a);
	ScreenText("ethnocentric", x, y+15, "CREDITS", .5);
end

function ExitClick(x, y)
	MMtoggleQuitConfirm();
end

function ExitButton(name, inst)
	x, y, z = GOGetPos(name, inst);
  go = GetGOPointer(name, inst);
  s = GetSpriteComp(go);
  r, g, b, a = SpriteComp_GetTextColor(s);
	SetFontColor("ethnocentric", r, g, b, a);
	ScreenText("ethnocentric", x, y+15, "EXIT", .5);
end

function HowToPlayClick(x, y)
	LoadLevel("HowToPlay.xml");
end

function HowToPlayButton(name, inst)
	x, y, z = GOGetPos(name, inst);
  go = GetGOPointer(name, inst);
  s = GetSpriteComp(go);
  r, g, b, a = SpriteComp_GetTextColor(s);
	SetFontColor("ethnocentric", r, g, b, a);
	ScreenText("ethnocentric", x-35, y-20, "How To\nPlay", .5);
end

function MMquitConfirm(name, inst)
	x, y, z = GOGetPos(name, inst);
	SetFontColor("ethnocentric", 255, 255, 255, 255);
	ScreenText("ethnocentric", x, y, "Are you sure you\n want to quit?", .5);
end

function MMtoggleQuitConfirmp(x, y)
	MMtoggleQuitConfirm();
end

function MMtoggleQuitConfirm()
  LoadCursor();
  VisibleCursor(true);
	a = GOGetActive("MMQuit", 0);
	GOActive("MMQuit", 0, not a);
	GOActive("MMQuitYes", 0, not a);
	GOActive("MMQuitNo", 0, not a);
end

function TextYes(name, inst)
	x, y, z = GOGetPos(name, inst);
  go = GetGOPointer(name, inst);
  s = GetSpriteComp(go);
  r, g, b, a = SpriteComp_GetTextColor(s);
	SetFontColor("ethnocentric", r, g, b, a);
	ScreenText("ethnocentric", x, y+10, "Yes", .5);
end

function TextNo(name, inst)
	x, y, z = GOGetPos(name, inst);
  go = GetGOPointer(name, inst);
  s = GetSpriteComp(go);
  r, g, b, a = SpriteComp_GetTextColor(s);
	SetFontColor("ethnocentric", r, g, b, a);
	ScreenText("ethnocentric", x, y+10, "No", .5);
end

--Story1
function Story1Enter()
	SendDelayedLuaMessage("EndLevel();", 36.0);
	RegisterForInput("SkipMenu", "StoryEnder", ACTION_TRIGGER);
	story1Count = 0;
	PlayLayerRange(0, 0);
end

function Story1Exit()
	UnregisterForInput("SkipMenu", ACTION_TRIGGER);
end

function StoryEnder()
	SetNextLevel("goldIntro.xml");
	EndLevel();
end

function Story1Func(name, inst)
  go = GetGOPointer(name, inst);
  s = GetSpriteComp(go);
  u, v = SpriteComp_GetUVoffset(s);
  uS, vS = SpriteComp_GetUVscale(s);
  VisibleCursor(false);
  
  UVspeed = 1 / (65 * 30);		-- 65 * X, where X is the seconds the transition lasts
  if story1Count > 65 * 6 then	-- 65 * X, where X is the delay in seconds
	  u = u - (0.405 * UVspeed);
	  v = v - (0.084 * UVspeed);
	  uS = uS + ((1 - .1875) * UVspeed);
	  vS = vS + ((1 - .2083) * UVspeed);
  end
  
  SetCurTextVars("ethnocentric", .45, 255, 255, 255);
  
  if story1Count == 65 * 3 then
    AddTextNow(0, -500, "MEET AUDIA.                                    ", 6);
  end
  
  if story1Count == 65 * 5 then
    AddTextNow(0, -500, "                              THIS IS HER HOME.", 4);
  end
  
  if story1Count == 65 * 10 then
    AddTextNow(0, -500, "ALL HER LIFE SHE HAS ONLY KNOWN THE INSIDE OF THIS LAB.", 6);
  end
  
  if story1Count == 65 * 17 then
    AddTextNow(0, -500, "SHE HAS ONLY KNOWN HER CREATORS AND THEIR                            ", 6);
  end
  
  if story1Count == 65 * 19 then
    AddTextNow(0, -500, "                                                                                                EXPERIMENTS.", 4);
  end
  
  if story1Count == 65 * 24 then
    AddTextNow(0, -500, "EXPERIMENTS THAT ALLOWED HER TO ALTER\n SPANS OF TIME,   AND THE SOUNDS IN BETWEEN.", 7);
  end
  
  if story1Count == 65 * 32 then
    AddTextNow(0, -500, "THESE GIFTS ENSURED THAT SHE COULD NEVER LEAVE...", 6);
  end
  
  if u < 0 then
    u = 0;
  end
  if v < 0 then
    v = 0;
  end
  if uS > 1 then
    uS = 1;
  end
  if vS > 1 then
    vS = 1;
  end
  SpriteComp_SetVars(s, Vec2(u,v), Vec2(uS, vS));
  
  story1Count = story1Count + 1;
end

function Story2Enter()
	SendDelayedLuaMessage("EndLevel();", 28.0);
	VisibleCursor(false);
	RegisterForInput("SkipMenu", "StoryEnder", ACTION_TRIGGER);
	story1Count = 0;
end

function Story2Exit()
	UnregisterForInput("SkipMenu", ACTION_TRIGGER);
end

function Story2Func(name, inst)
  go = GetGOPointer(name, inst);
  s = GetSpriteComp(go);
  u, v = SpriteComp_GetUVoffset(s);
  uS, vS = SpriteComp_GetUVscale(s);
  VisibleCursor(false);
  
  UVspeed = 1 / (65 * 19);  -- 65 * X, where X is the seconds the transition lasts
  if story1Count > 65 * 3 then -- 65 * X, where X is the delay in seconds
	  u = u - (0.2987 * UVspeed);
	  v = v - (0.3842 * UVspeed);
	  uS = uS + ((1 - 0.4072) * UVspeed);
	  vS = vS + ((1 - 0.4072) * UVspeed);
  end

  SetCurTextVars("ethnocentric", .45, 255, 255, 255);
  
  if story1Count == 65 * 3 then
    AddTextNow(0, -500, "THEN CAME A DAY WHEN THE EXPERIMENTS STOPPED.", 6);
  end
  
  if story1Count == 65 * 10 then
    AddTextNow(0, -500, "AUDIA FOUND HERSELF ALONE.  THE LAB EMPTY.", 6);
  end
  
  if story1Count == 65 * 17 then
    AddTextNow(0, -490, "THIS WAS HER CHANCE.   SHE WANTED A NEW LIFE.\n SHE WANTED OUT.", 7);
  end

  if story1Count == 65 * 25 then
	AddTextNow(0, -500, "THIS IS HER JOURNEY.", 5);
	PlaySound("Checkpoint");
    SetCompString(name, inst, "Sprite", "SpriteName", "story3");
  end

  if u < 0 then
    u = 0;
  end
  if v < 0 then
    v = 0;
  end
  if uS > 1 then
    uS = 1;
  end
  if vS > 1 then
    vS = 1;
  end
  SpriteComp_SetVars(s, Vec2(u,v), Vec2(uS, vS));

  story1Count = story1Count + 1;
end

--Splash Screen
function SplashHandler ()
	SetNextLevel("MainMenu.xml");
	EndLevel();
end

function DigiSplash ()
	CreateKeyboardAction(VK_SPACE, "SkipMenu");
	CreateMouseAction(MOUSE_LEFT, "SkipMenu");
	CreateMouseAction(MOUSE_RIGHT, "SkipMenu");
	CreateKeyboardAction(VK_ESCAPE, "SkipMenu");
	CreateKeyboardAction(VK_RETURN, "SkipMenu");
	RegisterForInput("SkipMenu", "SplashHandler", ACTION_TRIGGER);
	SendDelayedLuaMessage("EndLevel();", 4.0);
  DeleteCheckPoint();
end

function DigiSplashExit()
		UnregisterForInput("SkipMenu", ACTION_TRIGGER);
end

--Credits

function CreditsOnEnter ()
	StopSound("Wind_Low");
	StopSound("StringLine");
	CreateKeyboardAction(VK_SPACE, "SkipMenu");
	RegisterForInput("SkipMenu", "EndLevel", ACTION_TRIGGER);
	SendDelayedLuaMessage("EndLevel();", 70.0);
end

function CreditsOnExit()
		UnregisterForInput("SkipMenu", ACTION_TRIGGER);
end

dofile "Resources\\lua\\creditsList.lua";

function LetterBoxPos(name, inst)
	w, h = GetCurrentResolution();
	Lw, Lh = GetLetterBoxedResolution();
	if w ~= Lw then
		GOPosition(name, inst, 960 + (w - Lw) / (Lw * 2) * 960, 0, -0.09);
		GOScale(name, inst, (w - Lw) / Lw * 960, 1200, 1);
	elseif h ~= Lh then
		GOPosition(name, inst, 0, 600 + (h - Lh) / (Lh * 2) * 600, -0.09);
		GOScale(name, inst, 1920, (h - Lh) / Lh * 600, 1);
	else
		GOActive(name, inst, false);
	end
end

function LetterBoxNeg(name, inst)
	w, h = GetCurrentResolution();
	Lw, Lh = GetLetterBoxedResolution();
	if w ~= Lw then
		GOPosition(name, inst, -(960 + (w - Lw) / (Lw * 2) * 960), 0, -0.09);
		GOScale(name, inst, (w - Lw) / Lw * 960, 1200, 1);
	elseif h ~= Lh then
		GOPosition(name, inst, 0, -(600 + (h - Lh) / (Lh * 2) * 600), -0.09);
		GOScale(name, inst, 1920, (h - Lh) / Lh * 600, 1);
	else
		GOActive(name, inst, false);
	end
end

--Options Menu

function OptFullScreen(name, inst)
	x, y, z = GOGetPos(name, inst);
	SetFontColor("ethnocentric", 255, 255, 255, 255);
	ScreenText("ethnocentric", x+40, y + 50, "Full Screen", .5);
end

function BGM(name, inst)
	x, y, z = GOGetPos(name, inst);
	SetFontColor("ethnocentric", 255, 255, 255, 255);
	ScreenText("ethnocentric", x, y + 50, "Music", .5);
end

function SoundFX(name, inst)
	x, y, z = GOGetPos(name, inst);
	SetFontColor("ethnocentric", 255, 255, 255, 255);
	ScreenText("ethnocentric", x, y + 50, "Sounds", .5);
end

function ScreenSize(name, inst)
	x, y, z = GOGetPos(name, inst);
	SetFontColor("ethnocentric", 255, 255, 255, 255);
	ScreenText("ethnocentric", x+50, y + 50, "Screen Size", .5);
end

function BackButton(name, inst)
	x, y, z = GOGetPos(name, inst);
  go = GetGOPointer(name, inst);
  s = GetSpriteComp(go);
  r, g, b, a = SpriteComp_GetTextColor(s);
	SetFontColor("ethnocentric", r, g, b, a);
	ScreenText("ethnocentric", x, y + 50, "Back", .7);
end

function BackClick(x, y)
	SetNextLevel("");
	EndLevel();
end

function OptFSoffButton(name, inst)
	x, y, z = GOGetPos(name, inst);
  go = GetGOPointer(name, inst);
  s = GetSpriteComp(go);
  r, g, b, a = SpriteComp_GetTextColor(s);
	SetFontColor("ethnocentric", r, g, b, a);
	ScreenText("ethnocentric", x, y+10, "Off", .5);
end

function OptFSoffClick(x, y)
	FullScreen(false);
end

function OptFSonButton(name, inst)
	x, y, z = GOGetPos(name, inst);
  go = GetGOPointer(name, inst);
  s = GetSpriteComp(go);
  r, g, b, a = SpriteComp_GetTextColor(s);
	SetFontColor("ethnocentric", r, g, b, a);
	ScreenText("ethnocentric", x, y+10, "On", .5);
end

function OptFSonClick(x, y)
	FullScreen(true);
end

function SSboxClick(x, y)
	--Ypos = -37;   --hard coded from xml
	--size = 535 / 10;
	--num = GetNumResolutions();
	--index = (Ypos - y) / size;
	--if index < size and index >= 0 then
	--	GoToResolutionAtIndex(index);
	--end
end

function FillSSbox(name, inst)
	--x, y, z = GOGetPos(name, inst);
	--size = 535 / 10
	--num = GetNumResolutions();
	--for i = 0, num-1 do
	--	w, h = GetResolutionAtIndex(i);
	--	w = string.format("%i X %i", w, h);
	--  SetFontColor("ethnocentric", 255, 255, 255, 255);
	--	ScreenText("ethnocentric", x, y + 267.5 - i * size, w, .35);
	--end
end

function ResClick(index)
  num = GetNumResolutions();
	if index < num and index >= 0 then
		GoToResolutionAtIndex(index);
	end
end

function ResDisplay(name, inst, index)
  num = GetNumResolutions();
  if index < num and index >= 0 then
	  w, h = GetResolutionAtIndex(index);
	  w = string.format("%i X %i", w, h);
	  x, y, z = GOGetPos(name, inst);
    go = GetGOPointer(name, inst);
    s = GetSpriteComp(go);
    r, g, b, a = SpriteComp_GetColor(s);
	  SetFontColor("ethnocentric", r, g, b, a);
		ScreenText("ethnocentric", x, y, w, .45);
	end
end

function CurResDisplay(name, inst)
	w, h = GetCurrentResolution();
  w = string.format("%i X %i", w, h);
	x, y, z = GOGetPos(name, inst);
	SetFontColor("ethnocentric", 0, 0, 0, 255);
	ScreenText("ethnocentric", x, y, w, .6);
  VisibleCursor(true);
end

function Res0Click(x, y)
  ResClick(0);
end

function Res0Display(name, inst)
  ResDisplay(name, inst, 0);
end

function Res1Click(x, y)
  ResClick(1);
end

function Res1Display(name, inst)
  ResDisplay(name, inst, 1);
end

function Res2Click(x, y)
  ResClick(2);
end

function Res2Display(name, inst)
  ResDisplay(name, inst, 2);
end

function Res3Click(x, y)
  ResClick(3);
end

function Res3Display(name, inst)
  ResDisplay(name, inst, 3);
end

function Res4Click(x, y)
  ResClick(4);
end

function Res4Display(name, inst)
  ResDisplay(name, inst, 4);
end

function Res5Click(x, y)
  ResClick(5);
end

function Res5Display(name, inst)
  ResDisplay(name, inst, 5);
end

function Res6Click(x, y)
  ResClick(6);
end

function Res6Display(name, inst)
  ResDisplay(name, inst, 6);
end

function Res7Click(x, y)
  ResClick(7);
end

function Res7Display(name, inst)
  ResDisplay(name, inst, 7);
end

function Res8Click(x, y)
  ResClick(8);
end

function Res8Display(name, inst)
  ResDisplay(name, inst, 8);
end

function Res9Click(x, y)
  ResClick(9);
end

function Res9Display(name, inst)
  ResDisplay(name, inst, 9);
end

function BGMvolume10(x, y)
	SetBGMVolume(1.0);
end

function BGMvolume0(x, y)
	SetBGMVolume(0.0);
end

function BGMvolume1(x, y)
	SetBGMVolume(0.1);
end

function BGMvolume2(x, y)
	SetBGMVolume(0.2);
end

function BGMvolume3(x, y)
	SetBGMVolume(0.3);
end

function BGMvolume4(x, y)
	SetBGMVolume(0.4);
end

function BGMvolume5(x, y)
	SetBGMVolume(0.5);
end

function BGMvolume6(x, y)
	SetBGMVolume(0.6);
end

function BGMvolume7(x, y)
	SetBGMVolume(0.7);
end

function BGMvolume8(x, y)
	SetBGMVolume(0.8);
end

function BGMvolume9(x, y)
	SetBGMVolume(0.9);
end

function SFXvolume10(x, y)
	SetSFXVolume(1.0);
end

function SFXvolume0(x, y)
	SetSFXVolume(0.0);
end

function SFXvolume1(x, y)
	SetSFXVolume(0.1);
end

function SFXvolume2(x, y)
	SetSFXVolume(0.2);
end

function SFXvolume3(x, y)
	SetSFXVolume(0.3);
end

function SFXvolume4(x, y)
	SetSFXVolume(0.4);
end

function SFXvolume5(x, y)
	SetSFXVolume(0.5);
end

function SFXvolume6(x, y)
	SetSFXVolume(0.6);
end

function SFXvolume7(x, y)
	SetSFXVolume(0.7);
end

function SFXvolume8(x, y)
	SetSFXVolume(0.8);
end

function SFXvolume9(x, y)
	SetSFXVolume(0.9);
end

function SFXselect(name, inst)
	x, y, z = GOGetPos(name, inst);
	level = GetSFXVolume() * 10;
	GOPosition(name, inst, 380 + level * 40, y, z);
end

function BGMselect(name, inst)
	x, y, z = GOGetPos(name, inst);
	level = GetBGMVolume() * 10;
	GOPosition(name, inst, 380 + level * 40, y, z);
end

function BGMvolumeUp(name, inst)
	PlaySound("MenuClick");
	cur = GetBGMVolume();
	SetBGMVolume(cur + 0.1);
end

function BGMvolumeDown(name, inst)
	PlaySound("MenuClick");
	cur = GetBGMVolume();
	SetBGMVolume(cur - 0.1);
end

function SFXvolumeUp(name, inst)
	PlaySound("MenuClick");
	cur = GetSFXVolume();
	SetSFXVolume(cur + 0.1);
end

function SFXvolumeDown(name, inst)
	PlaySound("MenuClick");
	cur = GetSFXVolume();
	SetSFXVolume(cur - 0.1);
end

function SoundPlus(name, inst)
	x, y, z = GOGetPos(name, inst);
  go = GetGOPointer(name, inst);
  s = GetSpriteComp(go);
  r, g, b, a = SpriteComp_GetColor(s);
	SetFontColor("umopmed", r, g, b, a);
	ScreenText("umopmed", x + 20, y + 15, "+", .75);
end

function SoundMinus(name, inst)
	x, y, z = GOGetPos(name, inst);
  go = GetGOPointer(name, inst);
  s = GetSpriteComp(go);
  r, g, b, a = SpriteComp_GetColor(s);
	SetFontColor("umopmed", r, g, b, a);
	ScreenText("umopmed", x + 20, y + 15, "-", .75);
end

function UpdateScore(name, inst)
	currScore = GetCurrScore();
	totalScore = GetTotalScore();
	text = string.format("Score: %d / %d", currScore, totalScore );
	SetFontColor("umopmed", 255, 255, 255, 255);
	ScreenText("umopmed", -600, 550, text, .5);
end

function LoadCursor()
  CreateMouseAction(MOUSE_MOVE, "CursorMoved");
  RegisterForInput("CursorMoved", "UpdateCursor", ACTION_TRIGGER);
  LoadProto("cursor");
  if IsGameObject("cursor", 0) == false then
    GOFromProto("cursor", 0, 0, 0);
    GOScale("cursor", 0, 64, 64, 1);
    GOExportable("cursor", 0, false);
  end
  VisibleCursor(false);
end

function VisibleCursor(b)
  if IsGameObject("cursor", 0) then
    go = GetGOPointer("cursor", 0);
    GameObject_SetActive(go, b);
  end
end

function UpdateCursor()
  if IsGameObject("cursor", 0) then
    go = GetGOPointer("cursor", 0);
    x, y = GetMousePos();
    GameObject_SetPos3(go, Vec3(x+16, y-25, -.05));
    if IsPaused() == true then
      VisibleCursor(true);
    end
  end
end

function OutsideEnder(name, inst)
	x, y, z = GOGetPos(name, inst);
	if IsGameObject("Player", 0) then
		px, py, pz = GOGetPos("Player", 0);
		if math.abs(px - x) < 1 then
			GOActive("BlackQuad", 0, true);
			UnregisterForInput("PlayerJump", ACTION_TRIGGER);
			UnregisterForInput("PlayerLeft", ACTION_PRESS);
			UnregisterForInput("PlayerRight", ACTION_PRESS);
			UnregisterForInput("PlayerLeft", ACTION_RELEASE);
			UnregisterForInput("PlayerRight", ACTION_RELEASE);
			UnregisterForInput("RestartToCheckPoint", ACTION_TRIGGER);
			UnregisterForInput("ToggleTime", ACTION_TRIGGER);
		end
	end
	if GOGetActive("BlackQuad", 0) then
		go = GetGOPointer("BlackQuad", 0);
		s = GetSpriteComp(go);
		r,g,b,a = SpriteComp_GetColor(s);
		a = a + 1.5;
		if a > 255 then
		  a = 255;
		end
		SpriteComp_Color(s, Vec4(255, 255, 255, a));
	end
end

-------------------------------------------------------------
--Level Start/Stop Scripts--
-------------------------------------------------------------

function LevelStart()
	LoadCursor();
	LoadPauseMenu();
	DeleteCheckPoint();
  timestop = false;
  canstop = false;
	SetPrevPause(false);
	
	c = GetCamera();
	Camera_SetCamSpeed(c, 9.0);
	CameraFollow("Player", 0);
	GORotUp("Player", 0, -90);
  SetTimeStopAmbient(Vec4(0, .16, .32, 1.0));
	SetGlobalAmbient(Vec4(0,0,0,1));
	
	RegisterForInput("PlayerJump", "PlayerJump", ACTION_TRIGGER);
	RegisterForInput("PlayerLeft", "PlayerLeft", ACTION_PRESS);
	RegisterForInput("PlayerRight", "PlayerRight", ACTION_PRESS);
	RegisterForInput("PlayerLeft", "PlayerStopLeft", ACTION_RELEASE);
	RegisterForInput("PlayerRight", "PlayerStopRight", ACTION_RELEASE);
	RegisterForInput("PlayerLeft", "StartTime", ACTION_TRIGGER);
	RegisterForInput("PlayerRight", "StartTime", ACTION_TRIGGER);	
	RegisterForInput("StartTime", "StartTime", ACTION_TRIGGER);
	RegisterForInput("RestartToCheckPoint", "RestartToCheckPoint", ACTION_TRIGGER);
	RegisterForInput("ToggleTime", "ToggleTime", ACTION_TRIGGER);
	
	T = GetTileModule();
	TileModule_SetJumpStrength(T, 1, 7.6);	-- Set BounceBlock velocities (T, X velocity, Y velocity);
	VisibleCursor(false);
end

function LevelEnd()
	CameraUnfollow();
	UnloadPauseMenu();
	UnregisterForInput("PlayerJump", ACTION_TRIGGER);
	UnregisterForInput("PlayerLeft", ACTION_PRESS);
	UnregisterForInput("PlayerRight", ACTION_PRESS);
	UnregisterForInput("PlayerLeft", ACTION_RELEASE);
	UnregisterForInput("PlayerRight", ACTION_RELEASE);
	UnregisterForInput("RestartToCheckPoint", ACTION_TRIGGER);
	UnregisterForInput("ToggleTime", ACTION_TRIGGER);
	StopLayerRange(0, 11);
  StopSound("Outro");
	StopBGM();
	StopSound("PauseMusic");
end

-------------------------------------------------------------
--Level Specific Scripts--
-------------------------------------------------------------

function LevelScript_goldIntro()
	LevelStart();
	c = GetCamera();
	Camera_SetMaxZDistance(c, 12);
	Camera_SetMinZDistance(c, 7);
	
	SetCurTextVars("umopmed", 1.7, 255, 255, 255);
	AddTextOnPlayerPos(-10, 0, 50, 530, "AWAKENING", 8); -- (player x, player y, screen x, screen y, "text", duration)
	SetCurTextVars("ethnocentric", .45, 255, 255, 255);
	AddTextOnPlayerPos(-10, 0, 0, -550, "USE A AND D TO EXPLORE", 10);
	AddTextOnPlayerPos(-12, 1, 0, -450, "PRESS W OR SPACE TO JUMP", 10);
	AddTextOnPlayerPos(-4, 1, 0, -450, "PRESS W OR SPACE TO JUMP", 10);
	AddTextOnPlayerPos(-4, -1, 0, -450, "PRESS W OR SPACE TO JUMP", 10);
	AddTextOnPlayerPos(-4, 0, 0, -450, "PRESS W OR SPACE TO JUMP", 10);
	AddTextOnPlayerPos(6, -1, 0, -400, "FIND A WAY OUT...", 10);
	
	  -- Move_Tile3 - instance 0
	go = GetGOPointer("Move_Tile3", 0);  
	p = GetPhysicsComp(go);
	PhysicsComp_AddDestination(p, 8, 3, 1);

	PlayLayerRange(1, 1);
end

function LevelScript_beta01()  -- Also used for gold01
	LevelStart();
	SetCurTextVars("umopmed", 1.1, 255, 255, 255);
	AddTextOnPlayerPos(0, 0, 0, 530, "  LEARNING TO LIVE", 8); -- (player x, player y, screen x, screen y, "text", duration)
	SetCurTextVars("ethnocentric", .45, 255, 255, 255);
	AddTextOnPlayerPos(2, 0, 0, -450, "PRESS S WHILE INSIDE TIME FIELDS TO ACTIVATE THEM", 12);
	AddTextOnPlayerPos(6.4, 0, 0, -550, "WHEN TIME IS STOPPED USE THE CURSOR TO MOVE BLOCKS", 12);
	AddTextOnPlayerPos(44, 2, 0, -500, "CROSS THE CHECKPOINTS TO SAVE", 10);
	AddTextOnPlayerPos(60, 2, 0, -550, "bounce PLATFORMS  WILL GIVE YOU A BOOST", 12);
	
	PlayLayerRange(1, 2);
	MuteLayerRange(2, 2, true);
end

function LevelScript_exp()
	LevelStart();
	AddPlayerLight();
	SetTimeStopAmbient(Vec4(.4, .4, .4, 1));
	SetGlobalAmbient(Vec4(.7,.7,.7,1));
	PlayLayerRange(2, 4);
	MuteLayerRange(3, 4, true);
end

function LevelScript_exp_04()
	LevelStart();
	AddPlayerLight();
	SetTimeStopAmbient(Vec4(.4, .4, .4, 1));
	SetGlobalAmbient(Vec4(.7,.7,.7,1));
	
	
	-- Move_Tile3 - instance 0
	go = GetGOPointer("Move_Tile3", 0);  
	p = GetPhysicsComp(go);
	PhysicsComp_AddDestination(p, 7, 6, 1);
	
	PlayLayerRange(2, 4);
	MuteLayerRange(3, 4, true);
end

function LevelScript_gold02()
	LevelStart();
	AddPlayerLight();
	SetTimeStopAmbient(Vec4(.4, .4, .4, 1));
	SetGlobalAmbient(Vec4(.7,.7,.7,1));
	c = GetCamera();
	Camera_SetMaxZDistance(c, 16);
	Camera_SetMinZDistance(c, 12);

	SetCurTextVars("umopmed", 1, 255, 255, 255);
	AddTextOnPlayerPos(2, 2, 50, 530, "FINDING THE RHYTHM", 8);
	SetCurTextVars("ethnocentric", .45, 255, 255, 255);
	AddTextOnPlayerPos(5, 2, 0, -550, "YOU CAN PRESS  M TO ZOOM OUT", 12);
	AddTextOnPlayerPos(38, 3, 0, -500, "AUDIA CAN MOVE BOUNCE PLATFORMS WHEN SHE STOPS TIME", 12);
	AddTextOnPlayerPos(38, 17, 0, -450, "RIGHT CLICK TO ROTATE BOUNCE PLATFORMS", 12);
	AddTextOnPlayerPos(79, 25, 0, -500, "AUDIA CAN USE BOUNCE PLATORMS", 12);
	AddTextOnPlayerPos(79, 25, 0, -550, "EVEN WHEN THEY ARE ROTATED", 12);
	
	go = GetGOPointer("Move_Tile3", 0);  -- Move_Tile3 - instance 0
	p = GetPhysicsComp(go);
	PhysicsComp_AddDestination(p, 124, 28, 2);
	PhysicsComp_AddDestination(p, 124, 32, 2);
	
	PlayLayerRange(2, 4);
	MuteLayerRange(3, 4, true);
end

function LevelScript_gold03()
	LevelStart();
	AddPlayerLight();
	SetTimeStopAmbient(Vec4(.5, .5, .5, 1));
	SetGlobalAmbient(Vec4(.7,.7,.7,1));
	c = GetCamera();
	Camera_SetMaxZDistance(c, 15);
	Camera_SetMinZDistance(c, 10);
	
	SetCurTextVars("umopmed", 1.2, 255, 255, 255);
	AddTextOnPlayerPos(0, 0, 50, 530, "MAKING THE RISE", 6);
	SetCurTextVars("ethnocentric", .45, 255, 255, 255);
	AddTextOnPlayerPos(8, 63, 0, -500, "AUDIA CAN USE ACCELERATION SPHERES", 12);
	AddTextOnPlayerPos(8, 63, 0, -550, "TO LAUNCH HER THROUGH THE AIR", 12);
	
	go = GetGOPointer("Move_Tile3", 0);  -- Move_Tile3 - instance 0
	p = GetPhysicsComp(go);
	PhysicsComp_AddDestination(p, 0, 13, 5);
		-- puzzle 1
	go = GetGOPointer("Move_Tile", 0);  -- Move_Tile - instance 0
	p = GetPhysicsComp(go);
	PhysicsComp_AddDestination(p, 8, 14, 2);
	PhysicsComp_AddDestination(p, 8, 12, 2);
	go = GetGOPointer("Move_Tile", 1);  -- Move_Tile - instance 1
	p = GetPhysicsComp(go);
	PhysicsComp_AddDestination(p, 9, 14, 1);
	PhysicsComp_AddDestination(p, 9, 12, 2);
	PhysicsComp_AddDestination(p, 9, 13, 1);
	go = GetGOPointer("Move_Tile", 2);  -- Move_Tile - instance 2
	p = GetPhysicsComp(go);
	PhysicsComp_AddDestination(p, 10, 12, 2);
	PhysicsComp_AddDestination(p, 10, 14, 2);
	go = GetGOPointer("Move_Tile", 3);  -- Move_Tile - instance 3
	p = GetPhysicsComp(go);
	PhysicsComp_AddDestination(p, 11, 14, 1);
	PhysicsComp_AddDestination(p, 11, 12, 2);
	PhysicsComp_AddDestination(p, 11, 13, 1);
	go = GetGOPointer("Move_Tile", 4);  -- Move_Tile - instance 4
	p = GetPhysicsComp(go);
	PhysicsComp_AddDestination(p, 12, 14, 2);
	PhysicsComp_AddDestination(p, 12, 12, 2);
	go = GetGOPointer("Move_Tile", 5);  -- Move_Tile - instance 5
	p = GetPhysicsComp(go);
	PhysicsComp_AddDestination(p, 13, 14, 1);
	PhysicsComp_AddDestination(p, 13, 12, 2);
	PhysicsComp_AddDestination(p, 13, 13, 1);
	go = GetGOPointer("Move_Tile", 6);  -- Move_Tile - instance 6
	p = GetPhysicsComp(go);
	PhysicsComp_AddDestination(p, 14, 12, 2);
	PhysicsComp_AddDestination(p, 14, 14, 2);
	go = GetGOPointer("Move_Tile", 7);  -- Move_Tile - instance 7
	p = GetPhysicsComp(go);
	PhysicsComp_AddDestination(p, 15, 14, 1);
	PhysicsComp_AddDestination(p, 15, 12, 2);
	PhysicsComp_AddDestination(p, 15, 13, 1);	
	go = GetGOPointer("Move_Tile", 8);  -- Move_Tile - instance 8
	p = GetPhysicsComp(go);
	PhysicsComp_AddDestination(p, 16, 14, 2);
	PhysicsComp_AddDestination(p, 16, 12, 2);
		-- puzzle 2
	go = GetGOPointer("Move_Tile2", 0);  -- Move_Tile2 - instance 0
	p = GetPhysicsComp(go);
	PhysicsComp_AddDestination(p, 28, 13, 4);
	PhysicsComp_AddDestination(p, 28, 13, 1);
	PhysicsComp_AddDestination(p, 23.5, 13, 4);
		-- puzzle 3
	go = GetGOPointer("Move_Tile3", 1);  -- Move_Tile3 - instance 1
	p = GetPhysicsComp(go);
	PhysicsComp_AddDestination(p, 39, 13, 1);
	PhysicsComp_AddDestination(p, 39, 21, 3);
	PhysicsComp_AddDestination(p, 39, 21, 1);
	PhysicsComp_AddDestination(p, 39, 13, 1);
		-- puzzle 4
	go = GetGOPointer("Move_Tile", 9);  -- Move_Tile - instance 9
	p = GetPhysicsComp(go);
	PhysicsComp_AddDestination(p, 29, 25, 1);
	PhysicsComp_AddDestination(p, 29, 28, 3);
	PhysicsComp_AddDestination(p, 29, 28, 1);
	PhysicsComp_AddDestination(p, 29, 25, 2);
		-- puzzle 5
	go = GetGOPointer("Move_Tile", 10);  -- Move_Tile - instance 10
	p = GetPhysicsComp(go);
	PhysicsComp_AddDestination(p, 19, 40, 2);
	PhysicsComp_AddDestination(p, 19, 37, 2);
	go = GetGOPointer("Move_Tile", 11);  -- Move_Tile - instance 11
	p = GetPhysicsComp(go);
	PhysicsComp_AddDestination(p, 19, 46, 2);
	PhysicsComp_AddDestination(p, 19, 43, 2);
	go = GetGOPointer("Move_Tile", 12);  -- Move_Tile - instance 12
	p = GetPhysicsComp(go);
	PhysicsComp_AddDestination(p, 19, 52, 2);
	PhysicsComp_AddDestination(p, 19, 49, 2);
		-- puzzle 6
	go = GetGOPointer("Move_Tile", 13);  -- Move_Tile - instance 13
	p = GetPhysicsComp(go);
	PhysicsComp_AddDestination(p, 5, 55, 2);
	PhysicsComp_AddDestination(p, 11, 55, 2);
	PhysicsComp_AddDestination(p, 11, 60, 2);
	PhysicsComp_AddDestination(p, 5, 60, 2);
	go = GetGOPointer("Move_Tile", 14);  -- Move_Tile - instance 14
	p = GetPhysicsComp(go);
	PhysicsComp_AddDestination(p, 11, 55, 2);
	PhysicsComp_AddDestination(p, 11, 60, 2);
	PhysicsComp_AddDestination(p, 5, 60, 2);
	PhysicsComp_AddDestination(p, 5, 55, 2);
	go = GetGOPointer("Move_Tile", 15);  -- Move_Tile - instance 15
	p = GetPhysicsComp(go);
	PhysicsComp_AddDestination(p, 11, 60, 2);
	PhysicsComp_AddDestination(p, 5, 60, 2);
	PhysicsComp_AddDestination(p, 5, 55, 2);
	PhysicsComp_AddDestination(p, 11, 55, 2);
	go = GetGOPointer("Move_Tile", 16);  -- Move_Tile - instance 16
	p = GetPhysicsComp(go);
	PhysicsComp_AddDestination(p, 5, 60, 2);
	PhysicsComp_AddDestination(p, 5, 55, 2);
	PhysicsComp_AddDestination(p, 11, 55, 2);
	PhysicsComp_AddDestination(p, 11, 60, 2);
	
	go = GetGOPointer("Accelerator", 0);	-- Accelerator0
	a = GetAcceleratorComp(go);
	AcceleratorComp_SetParam(a, Vec2(0, 0), 1, Vec2(0, 4), Vec2(0, 20));

	PlayLayerRange(4, 6);
	MuteLayerRange(5, 6, true);
end

function LevelScript_gold04()
	LevelStart();
	AddPlayerLight();
	SetTimeStopAmbient(Vec4(.5, .5, .5, 1));
	SetGlobalAmbient(Vec4(.7,.7,.7,1));
	c = GetCamera();
	Camera_SetMaxZDistance(c, 19);
	Camera_SetMinZDistance(c, 11.5);
	
	SetCurTextVars("umopmed", 1.2, 255, 255, 255);
	AddTextOnPlayerPos(0, 0, 50, 530, "LEARNING TO FLY", 6);
	
		-- Accelerator0
	go = GetGOPointer("Accelerator", 0);	
	a = GetAcceleratorComp(go);
	AcceleratorComp_SetParam(a, Vec2(0, 0), 2, Vec2(0, 5), Vec2(1, 15));
		-- Accelerator1
	go = GetGOPointer("Accelerator45", 0);	
	a = GetAcceleratorComp(go);
	AcceleratorComp_SetParam(a, Vec2(0, 0), 1, Vec2(1, 1), Vec2(7, 7));
		-- Accelerator2
	go = GetGOPointer("Accelerator90", 0);	
	a = GetAcceleratorComp(go);
	AcceleratorComp_SetParam(a, Vec2(0, 0), 1, Vec2(5, 0), Vec2(8, 1));
		-- Accelerator3
	go = GetGOPointer("Accelerator", 1);	
	a = GetAcceleratorComp(go);
	AcceleratorComp_SetParam(a, Vec2(0, 0), 1, Vec2(0, 5), Vec2(0, 8));
		-- Accelerator4
	go = GetGOPointer("Accelerator270", 0);	
	a = GetAcceleratorComp(go);
	AcceleratorComp_SetParam(a, Vec2(0, 0), 1, Vec2(-3, 1), Vec2(-5, 1));
		-- Accelerator5
	go = GetGOPointer("Accelerator90", 1);	
	a = GetAcceleratorComp(go);
	AcceleratorComp_SetParam(a, Vec2(0, 0), 2, Vec2(3, 0), Vec2(5, 0));
		-- Accelerator6
	go = GetGOPointer("Accelerator", 2);	
	a = GetAcceleratorComp(go);
	AcceleratorComp_SetParam(a, Vec2(0, 0), 1, Vec2(0, 5), Vec2(0, 6));
		-- Accelerator7
	go = GetGOPointer("Accelerator", 3);	
	a = GetAcceleratorComp(go);
	AcceleratorComp_SetParam(a, Vec2(0, 0), 2, Vec2(0, 3), Vec2(0, 8));
	
	PlayLayerRange(6, 8);
	MuteLayerRange(7, 8, true);
end

function LevelScript_gold05()
	LevelStart();
	AddPlayerLight();
	SetTimeStopAmbient(Vec4(.5, .5, .5, 1));
	SetGlobalAmbient(Vec4(.7,.7,.7,1));
	c = GetCamera();
	Camera_SetMaxZDistance(c, 15);
	Camera_SetMinZDistance(c, 13);
	
	SetCurTextVars("umopmed", 1, 255, 255, 255);
	AddTextOnPlayerPos(0, 0, 50, 550, " LEARNING TO SING", 6);
	SetCurTextVars("ethnocentric", .45, 255, 255, 255);
	AddTextOnPlayerPos(4, 11, 0, -550, "REMEMBER TO PRESS M WHEN YOU NEED TO ZOOM OUT", 8);
	
		-- Accelerator0
	go = GetGOPointer("Accelerator", 0);	
	a = GetAcceleratorComp(go);
	AcceleratorComp_SetParam(a, Vec2(0, 0), 1, Vec2(0, 1), Vec2(0, 8));
		-- Accelerator1
	go = GetGOPointer("Accelerator", 1);	
	a = GetAcceleratorComp(go);
	AcceleratorComp_SetParam(a, Vec2(0, 0), 1, Vec2(0, 1), Vec2(0, 8));
		-- Move_Tile3 - instance 0
	go = GetGOPointer("Move_Tile3", 0);  
	p = GetPhysicsComp(go);
	PhysicsComp_AddDestination(p, 13, 21, 3);
	PhysicsComp_AddDestination(p, 19, 21, 3);	
		-- Accelerator2
	go = GetGOPointer("Accelerator", 2);	
	a = GetAcceleratorComp(go);
	AcceleratorComp_SetParam(a, Vec2(0, 0), 1, Vec2(0, 1), Vec2(0, 12));
		-- Accelerator3
	go = GetGOPointer("Accelerator", 3);	
	a = GetAcceleratorComp(go);
	AcceleratorComp_SetParam(a, Vec2(0, 0), 1, Vec2(0, 1), Vec2(0, 15));
		-- Accelerator4
	go = GetGOPointer("Accelerator", 4);	
	a = GetAcceleratorComp(go);
	AcceleratorComp_SetParam(a, Vec2(0, 0), 8, Vec2(0, 9), Vec2(0, 11));
		-- Move_Tile - instance 0
	go = GetGOPointer("Move_Tile", 0);  
	p = GetPhysicsComp(go);
	PhysicsComp_AddDestination(p, 30, 89, 2);
	PhysicsComp_AddDestination(p, 20, 89, 2);
		-- Move_Tile - instance 2
	go = GetGOPointer("Move_Tile", 1);  
	p = GetPhysicsComp(go);
	PhysicsComp_AddDestination(p, 20, 92, 2);
	PhysicsComp_AddDestination(p, 30, 92, 2);
		-- Move_Tile - instance 3
	go = GetGOPointer("Move_Tile", 2);  
	p = GetPhysicsComp(go);
	PhysicsComp_AddDestination(p, 30, 95, 2);
	PhysicsComp_AddDestination(p, 20, 95, 2);
	
	PlayLayerRange(8, 11);
	MuteLayerRange(9, 11, true);
end

function LevelScript_Outside()
	--AddPlayerLight(); --temporary until level has lights
	LevelStart();
	SetCurTextVars("umopmed", 1.25, 255, 255, 255);
	AddTextOnPlayerPos(4, 0, 0, 500, "A NEW WORLD", 8); -- (player x, player y, screen x, screen y, text, duration);
	SetCurTextVars("umopmed", .8, 255, 255, 255);
	AddTextOnPlayerPos(8, 0, 0, 400, "A NEW LIFE", 8);
	PlayCredits = false;
	if IsGameObject("BlackQuad", 0) then
		GOActive("BlackQuad", 0, false);
		go = GetGOPointer("BlackQuad", 0);
		s = GetSpriteComp(go);
		SpriteComp_Color(s, Vec4(255, 255, 255, 0));
	end		
end

function LevelScript_Pipes()
	AddPlayerLight(); --temporary until level has lights
	LevelStart();
	SetCurTextVars("umopmed", 1.25, 255, 255, 255);
	AddTextOnPlayerPos(0, 0, 0, 500, "Pipes", 5.0); -- (player x, player y, screen x, screen y, text, duration);
end

function LevelScript_Pipes2()
	AddPlayerLight(); --temporary until level has lights
	LevelStart();
	SetCurTextVars("umopmed", 1.25, 255, 255, 255);
	AddTextOnPlayerPos(0, 0, 0, 500, "Pipes", 5.0); -- (player x, player y, screen x, screen y, text, duration);
	-----------------accel blocks------------------------------
	go = GetGOPointer("Accelerator", 0);	-- Accelerator0
	a = GetAcceleratorComp(go);
	AcceleratorComp_SetParam(a, Vec2(0, 0), 2, Vec2(0, 10), Vec2(0, 2));
	go = GetGOPointer("Accelerator", 1);	-- Accelerator1
	a = GetAcceleratorComp(go);
	AcceleratorComp_SetParam(a, Vec2(0, 0), 2, Vec2(2, 0), Vec2(2, 0));
end

function LevelScript_Pipes3()
	AddPlayerLight(); --temporary until level has lights
	LevelStart();
	SetCurTextVars("umopmed", 1.25, 255, 255, 255);
	AddTextOnPlayerPos(0, 0, 0, 500, "Pipes", 5.0); -- (player x, player y, screen x, screen y, text, duration);
	-------------------accel blocks---------------
	go = GetGOPointer("Accelerator", 0);	-- Accelerator0
	a = GetAcceleratorComp(go);
	AcceleratorComp_SetParam(a, Vec2(0, 0), 2, Vec2(0, 4), Vec2(0, 2));
	go = GetGOPointer("Accelerator", 1);	-- Accelerator1
	a = GetAcceleratorComp(go);
	AcceleratorComp_SetParam(a, Vec2(0, 0), 2, Vec2(6, 0), Vec2(2, 0));
	go = GetGOPointer("Accelerator", 2);	-- Accelerator2
	a = GetAcceleratorComp(go);
	AcceleratorComp_SetParam(a, Vec2(0, 0), 2, Vec2(0, -4), Vec2(0, -4));
	go = GetGOPointer("Accelerator", 3);	-- Accelerator2
	a = GetAcceleratorComp(go);
	AcceleratorComp_SetParam(a, Vec2(0, 0), 2, Vec2(-6, 0), Vec2(-2, 0));
end

function LevelScript_beta02()
  AddPlayerLight(); --temporary until level has lights
	LevelStart();
	ParticleSystem("Particle_LevelEnderDown", 0,15,0);
	SetCurTextVars("umopmed", 1.25, 255, 255, 255);
	AddTextOnPlayerPos(0, 15, 0, 500, "THE LAB", 5.0); -- (player x, player y, screen x, screen y, text, duration)
	SetCurTextVars("ethnocentric", .45, 255, 255, 255);
	AddTextOnPlayerPos(4, 2, 0, -300, "PRESS M TO ZOOM OUT", 10.0); -- (player x, player y, screen x, screen y, text, duration)
	
	go = GetGOPointer("Accelerator", 0);	-- Accelerator0
	a = GetAcceleratorComp(go);
	AcceleratorComp_SetParam(a, Vec2(0, -1), 2, Vec2(0, 4), Vec2(1, 11));
	
	go = GetGOPointer("Accelerator", 1);	-- Accelerator1
	a = GetAcceleratorComp(go);
	AcceleratorComp_SetParam(a, Vec2(0, 0), 2, Vec2(2, 0), Vec2(10, 1));
	
	  -- 4-Way Accelerator block
	go = GetGOPointer("Accelerator", 2);	-- Accelerator2
	a = GetAcceleratorComp(go);
	AcceleratorComp_SetParam(a, Vec2(-1, 0), .5, Vec2(2, 0), Vec2(3, 0));
	go = GetGOPointer("Accelerator", 3);	-- Accelerator3
	a = GetAcceleratorComp(go);
	AcceleratorComp_SetParam(a, Vec2(1, 0), .5, Vec2(-2, 0), Vec2(-3, 0));
	go = GetGOPointer("Accelerator", 4);	-- Accelerator4
	a = GetAcceleratorComp(go);
	AcceleratorComp_SetParam(a, Vec2(0, 1), .5, Vec2(0, -2), Vec2(0, -3));
	go = GetGOPointer("Accelerator", 5);	-- Accelerator5
	a = GetAcceleratorComp(go);
	AcceleratorComp_SetParam(a, Vec2(0, -1), .5, Vec2(0, 2), Vec2(0, 5));
	
	go = GetGOPointer("Accelerator", 6);	-- Accelerator6
	a = GetAcceleratorComp(go);
	AcceleratorComp_SetParam(a, Vec2(0, 0), 1, Vec2(0, 3), Vec2(0, 10));
	
	go = GetGOPointer("Accelerator", 7);	-- Accelerator7
	a = GetAcceleratorComp(go);
	AcceleratorComp_SetParam(a, Vec2(0, 0), 1, Vec2(3, 0), Vec2(10, 0));
	
	go = GetGOPointer("Accelerator", 8);	-- Accelerator8
	a = GetAcceleratorComp(go);
	AcceleratorComp_SetParam(a, Vec2(0, 0), 1, Vec2(3, -3), Vec2(7, -7));
	
	go = GetGOPointer("Accelerator", 9);	-- Accelerator9
	a = GetAcceleratorComp(go);
	AcceleratorComp_SetParam(a, Vec2(0, 0), 1, Vec2(-3, -2), Vec2(-14, -10));
	
	go = GetGOPointer("Accelerator", 10);	-- Accelerator10
	a = GetAcceleratorComp(go);
	AcceleratorComp_SetParam(a, Vec2(0, 0), 1, Vec2(3, 1), Vec2(11, 6));
	
	go = GetGOPointer("Accelerator", 11);	-- Accelerator11
	a = GetAcceleratorComp(go);
	AcceleratorComp_SetParam(a, Vec2(0, 0), 1, Vec2(-3, -3), Vec2(-7, -9));
	
	go = GetGOPointer("Accelerator", 12);	-- Accelerator12
	a = GetAcceleratorComp(go);
	AcceleratorComp_SetParam(a, Vec2(0, 0), 1, Vec2(0, 4), Vec2(0.19, 35));
	
	go = GetGOPointer("Move_Tile", 0);
	p = GetPhysicsComp(go);
	PhysicsComp_AddDestination(p, 39, -2, 2);
	PhysicsComp_AddDestination(p, 39, -2, 0.5);
	PhysicsComp_AddDestination(p, 39, 4, 2);
	PhysicsComp_AddDestination(p, 39, 4, 0.5);
	PhysicsComp_AddDestination(p, 39, 10, 2);
	PhysicsComp_AddDestination(p, 39, 10, 0.5);
	PhysicsComp_AddDestination(p, 45, 10, 2);
	PhysicsComp_AddDestination(p, 45, 10, 0.5);
	PhysicsComp_AddDestination(p, 45, 4, 2);
	PhysicsComp_AddDestination(p, 45, 4, 0.5);
	PhysicsComp_AddDestination(p, 45, -2, 2);
	PhysicsComp_AddDestination(p, 45, -2, 0.5);
	PhysicsComp_AddDestination(p, 45, -8, 2);
	PhysicsComp_AddDestination(p, 45, -8, 0.5);
	PhysicsComp_AddDestination(p, 39, -8, 2);
	PhysicsComp_AddDestination(p, 39, -8, 0.5);	-- Move_Tile0
	
	go = GetGOPointer("Move_Tile", 1);
	p = GetPhysicsComp(go);
	PhysicsComp_AddDestination(p, 39, -8, 2);
	PhysicsComp_AddDestination(p, 39, -8, 0.5);
	PhysicsComp_AddDestination(p, 39, -2, 2);
	PhysicsComp_AddDestination(p, 39, -2, 0.5);
	PhysicsComp_AddDestination(p, 39, 4, 2);
	PhysicsComp_AddDestination(p, 39, 4, 0.5);
	PhysicsComp_AddDestination(p, 39, 10, 2);
	PhysicsComp_AddDestination(p, 39, 10, 0.5);
	PhysicsComp_AddDestination(p, 45, 10, 2);
	PhysicsComp_AddDestination(p, 45, 10, 0.5);
	PhysicsComp_AddDestination(p, 45, 4, 2);
	PhysicsComp_AddDestination(p, 45, 4, 0.5);
	PhysicsComp_AddDestination(p, 45, -2, 2);
	PhysicsComp_AddDestination(p, 45, -2, 0.5);
	PhysicsComp_AddDestination(p, 45, -8, 2);
	PhysicsComp_AddDestination(p, 45, -8, 0.5);	-- Move_Tile1
	
	go = GetGOPointer("Move_Tile", 2);
	p = GetPhysicsComp(go);
	PhysicsComp_AddDestination(p, 45, -8, 2);
	PhysicsComp_AddDestination(p, 45, -8, 0.5);
	PhysicsComp_AddDestination(p, 39, -8, 2);
	PhysicsComp_AddDestination(p, 39, -8, 0.5);
	PhysicsComp_AddDestination(p, 39, -2, 2);
	PhysicsComp_AddDestination(p, 39, -2, 0.5);
	PhysicsComp_AddDestination(p, 39, 4, 2);
	PhysicsComp_AddDestination(p, 39, 4, 0.5);
	PhysicsComp_AddDestination(p, 39, 10, 2);
	PhysicsComp_AddDestination(p, 39, 10, 0.5);
	PhysicsComp_AddDestination(p, 45, 10, 2);
	PhysicsComp_AddDestination(p, 45, 10, 0.5);
	PhysicsComp_AddDestination(p, 45, 4, 2);
	PhysicsComp_AddDestination(p, 45, 4, 0.5);
	PhysicsComp_AddDestination(p, 45, -2, 2);
	PhysicsComp_AddDestination(p, 45, -2, 0.5);	-- Move_Tile2
	
	go = GetGOPointer("Move_Tile", 3);
	p = GetPhysicsComp(go);
	PhysicsComp_AddDestination(p, 39, 4, 2);
	PhysicsComp_AddDestination(p, 39, 4, 0.5);
	PhysicsComp_AddDestination(p, 39, 10, 2);
	PhysicsComp_AddDestination(p, 39, 10, 0.5);
	PhysicsComp_AddDestination(p, 45, 10, 2);
	PhysicsComp_AddDestination(p, 45, 10, 0.5);
	PhysicsComp_AddDestination(p, 45, 4, 2);
	PhysicsComp_AddDestination(p, 45, 4, 0.5);
	PhysicsComp_AddDestination(p, 45, -2, 2);
	PhysicsComp_AddDestination(p, 45, -2, 0.5);
	PhysicsComp_AddDestination(p, 45, -8, 2);
	PhysicsComp_AddDestination(p, 45, -8, 0.5);
	PhysicsComp_AddDestination(p, 39, -8, 2);
	PhysicsComp_AddDestination(p, 39, -8, 0.5);
	PhysicsComp_AddDestination(p, 39, -2, 2);
	PhysicsComp_AddDestination(p, 39, -2, 0.5);	-- Move_Tile3
	
	go = GetGOPointer("Move_Tile", 4);
	p = GetPhysicsComp(go);
	PhysicsComp_AddDestination(p, 39, 10, 2);
	PhysicsComp_AddDestination(p, 39, 10, 0.5);
	PhysicsComp_AddDestination(p, 45, 10, 2);
	PhysicsComp_AddDestination(p, 45, 10, 0.5);
	PhysicsComp_AddDestination(p, 45, 4, 2);
	PhysicsComp_AddDestination(p, 45, 4, 0.5);
	PhysicsComp_AddDestination(p, 45, -2, 2);
	PhysicsComp_AddDestination(p, 45, -2, 0.5);
	PhysicsComp_AddDestination(p, 45, -8, 2);
	PhysicsComp_AddDestination(p, 45, -8, 0.5);
	PhysicsComp_AddDestination(p, 39, -8, 2);
	PhysicsComp_AddDestination(p, 39, -8, 0.5);
	PhysicsComp_AddDestination(p, 39, -2, 2);
	PhysicsComp_AddDestination(p, 39, -2, 0.5);
	PhysicsComp_AddDestination(p, 39, 4, 2);
	PhysicsComp_AddDestination(p, 39, 4, 0.5);	-- Move_Tile4
	
	go = GetGOPointer("Move_Tile", 5);
	p = GetPhysicsComp(go);
	PhysicsComp_AddDestination(p, 45, -2, 2);
	PhysicsComp_AddDestination(p, 45, -2, 0.5);
	PhysicsComp_AddDestination(p, 45, -8, 2);
	PhysicsComp_AddDestination(p, 45, -8, 0.5);
	PhysicsComp_AddDestination(p, 39, -8, 2);
	PhysicsComp_AddDestination(p, 39, -8, 0.5);
	PhysicsComp_AddDestination(p, 39, -2, 2);
	PhysicsComp_AddDestination(p, 39, -2, 0.5);
	PhysicsComp_AddDestination(p, 39, 4, 2);
	PhysicsComp_AddDestination(p, 39, 4, 0.5);
	PhysicsComp_AddDestination(p, 39, 10, 2);
	PhysicsComp_AddDestination(p, 39, 10, 0.5);
	PhysicsComp_AddDestination(p, 45, 10, 2);
	PhysicsComp_AddDestination(p, 45, 10, 0.5);
	PhysicsComp_AddDestination(p, 45, 4, 2);
	PhysicsComp_AddDestination(p, 45, 4, 0.5);	-- Move_Tile5
	
	go = GetGOPointer("Move_Tile", 6);
	p = GetPhysicsComp(go);
	PhysicsComp_AddDestination(p, 45, 10, 2);
	PhysicsComp_AddDestination(p, 45, 10, 0.5);
	PhysicsComp_AddDestination(p, 45, 4, 2);
	PhysicsComp_AddDestination(p, 45, 4, 0.5);
	PhysicsComp_AddDestination(p, 45, -2, 2);
	PhysicsComp_AddDestination(p, 45, -2, 0.5);
	PhysicsComp_AddDestination(p, 45, -8, 2);
	PhysicsComp_AddDestination(p, 45, -8, 0.5);
	PhysicsComp_AddDestination(p, 39, -8, 2);
	PhysicsComp_AddDestination(p, 39, -8, 0.5);
	PhysicsComp_AddDestination(p, 39, -2, 2);
	PhysicsComp_AddDestination(p, 39, -2, 0.5);
	PhysicsComp_AddDestination(p, 39, 4, 2);
	PhysicsComp_AddDestination(p, 39, 4, 0.5);
	PhysicsComp_AddDestination(p, 39, 10, 2);
	PhysicsComp_AddDestination(p, 39, 10, 0.5);	-- Move_Tile6
	
	go = GetGOPointer("Move_Tile", 7);
	p = GetPhysicsComp(go);
	PhysicsComp_AddDestination(p, 45, 4, 2);
	PhysicsComp_AddDestination(p, 45, 4, 0.5);
	PhysicsComp_AddDestination(p, 45, -2, 2);
	PhysicsComp_AddDestination(p, 45, -2, 0.5);
	PhysicsComp_AddDestination(p, 45, -8, 2);
	PhysicsComp_AddDestination(p, 45, -8, 0.5);
	PhysicsComp_AddDestination(p, 39, -8, 2);
	PhysicsComp_AddDestination(p, 39, -8, 0.5);
	PhysicsComp_AddDestination(p, 39, -2, 2);
	PhysicsComp_AddDestination(p, 39, -2, 0.5);
	PhysicsComp_AddDestination(p, 39, 4, 2);
	PhysicsComp_AddDestination(p, 39, 4, 0.5);
	PhysicsComp_AddDestination(p, 39, 10, 2);
	PhysicsComp_AddDestination(p, 39, 10, 0.5);
	PhysicsComp_AddDestination(p, 45, 10, 2);
	PhysicsComp_AddDestination(p, 45, 10, 0.5);	-- Move_Tile7
end

