DestroyAll();


--setBlank
setBlank(2,1);

--setBlackEdge
setBlackEdge(1,1);

--setWrap
setWrap(3,1);

--setLPointer
setLPointer(0,0,3,0,0);
setLPointer(1,-12,43,0,0);

--setLayerProperty
setLayerProperty(0,0,1);
setLayerProperty(1,1,1);
setLayerProperty(2,1,1);
setLayerProperty(3,1,1);

--setLayerPic
setLayerPic(0,2013);

--setTileMap
--setTilemap(0,1);
setTilemap(1,2);
setTilemap(2,3);
setTilemap(3,3);

--placeSprite
zoelspritenum = placeSprite(1,2,3,10,0,0);

newPicWin(255,120,150,2017);
playSong(0,-1);

addTimedEvent(252, 1, 1, 1250, "playSound(0,-1,0);\n");
addTimedEvent(253,1,1,12000,"DrawOpening();\n");



--Function Definitions
function DrawOpening()

  delWin(255);

  --toggleLayer
  toggleLayer(0);
  toggleLayer(1);

  --toggleSLayer
  toggleSLayer(1);
  toggleSLayer(2);

  newTxtWin(16,0,384,640,96,0);

  setTxtString(16,"In the year 20xx...");
  setTxtBD(16,0);
  setWinFlags(16,16);
  newPicWin(0,48,0,2003);
  winToggleHid(0);
  setWinFlags(0,UIGF_IMAGE_TRANSPARENT);
  addTimedEvent(16,1,1,2000,"openText1();\n");
  --addTimedEvent(7,0,1,17,"openEndLoop();\n");
end

function openText1()
  addTimedEvent(2,1,1,5000,"openText2();\n");
  setTxtString(16,"An evil game development \ntool was unleashed upon the world.");
end

function openText2()
addTimedEvent(3,1,1,5000,"openText3();\n");
setTxtString(16,"Many Universities have \nalready fallen under its \nevil sway.");
end

function openText3()
addTimedEvent(4,1,1,5000,"openText4();\n");
setTxtString(16,"But one university remains \nuntainted.");
end

function openText4()
addTimedEvent(5,1,1,4000,"openText5();\n");
setTxtString(16,"One that is willing...");
end

function openText5()
addTimedEvent(6,1,1,5000,"openText6();\n");
setTxtString(16, "To cash in.");
end

function openText6()
addTimedEvent(7,0,1,17,"openEndLoop();\n");
setTxtString(16, "");
end

function openEndLoop()
if (getLayerY(1) <= -2) then 
    delTimedEvent(7);
    winToggleHid(0);
    newTxtWin(32,240,300,160,96,1);

    setWinFlags(32,TEXT_TRANS);
    newClickH(258,316,383,334,255,"teleportSprite();\n");
    return
end
    MoveLPointer(0,0,0,0,2);
    MoveLPointer(1,0,0,0,6);
    MoveLPointer(2,0,0,16,16);
    MoveLPointer(3,0,0,32,-32);
    moveWinBy(16,0,2);
end

function teleportSprite()
    delClickH(258); 
    delSprite(zoelspritenum,2);
    teleportspritenum = placeSprite(2,2,3,10,0,0);
    addTimedEvent(8,1,1,100,"teleportAnimSprite1();\n");
end

function teleportAnimSprite1() 
    stopMusic();
    playSound(1,-1,0);
    addTimedEvent(9,0,1,8,"teleportAnimSprite2();\n");
end

function teleportAnimSprite2()
--errorMsg("Event 9 start.");
if (getSpriteY(teleportspritenum,2) <= -10) then
   delTimedEvent(9); 
   dofile("scripts/newgame.lua");
   return
end

   moveSprite(teleportspritenum,2,0,0,0,-8);
   --errorMsg("Event 9 Move sprite");
end
