InitialObjectDescriptor { objectDescriptorID 1 audioProfileLevelIndication 1 visualProfileLevelIndication 1 sceneProfileLevelIndication 1 graphicsProfileLevelIndication 1 ODProfileLevelIndication 1 esDescr [ ES_Descriptor { ES_ID 1 decConfigDescr DecoderConfigDescriptor { streamType 3 decSpecificInfo BIFSConfig { isCommandStream true pixelMetric true pixelWidth 400 pixelHeight 400 } } } ] } OrderedGroup { children [ Background2D { backColor 1 1 1 } Transform2D { translation 0 150 children [ DEF StartTS TouchSensor {} Shape { appearance Appearance { material Material2D { emissiveColor 0.5 0.5 0.5 filled TRUE } } geometry Rectangle { size 100 30 } } Shape { appearance Appearance { material Material2D { emissiveColor 1 0 0 filled TRUE } } geometry Text { string ["Start Game"] fontStyle FontStyle { justify ["MIDDLE" "MIDDLE"] size 20 } } } ] } DEF TimeSensorTick TimeSensor { enabled FALSE loop TRUE } Transform2D { translation 0 75 children [ Shape { appearance DEF TA Appearance { material Material2D { emissiveColor 1 0 0 filled TRUE } } geometry DEF TextField Text { fontStyle DEF FS FontStyle { justify ["MIDDLE" "MIDDLE"] size 22 } } } ] } Switch { choice [ DEF Hole Shape { appearance Appearance { material Material2D { emissiveColor 1 1 1 filled TRUE } } geometry DEF R Rectangle { size 50 50 } } ] } Transform2D { translation 0 -50 children [ DEF Table Form { size 150 150 groups [1 -1 2 -1 3 -1 4 -1 5 -1 6 -1 7 -1 8 -1 9 -1 1 2 3 -1 4 5 6 -1 7 8 9 -1] constraints ["SHin" "SHin" "SHin" "SVin"] groupsIndex [1 2 3 -1 4 5 6 -1 7 8 9 -1 10 11 12 -1] children [ DEF a_1_1 Switch { whichChoice 0 choice [ Transform2D { children [ DEF TS_1_1 TouchSensor {} Shape { appearance DEF RA Appearance { material Material2D { emissiveColor 0 0 0 filled TRUE } } geometry USE R } Shape { appearance USE TA geometry Text { string ["1"] fontStyle USE FS } } ] } USE Hole ] } DEF a_1_2 Switch { whichChoice 0 choice [ Transform2D { children [ DEF TS_1_2 TouchSensor {} Shape { appearance USE RA geometry USE R } Shape { appearance USE TA geometry Text { string ["2"] fontStyle USE FS } } ] } USE Hole ] } DEF a_1_3 Switch { whichChoice 0 choice [ Transform2D { children [ DEF TS_1_3 TouchSensor {} Shape { appearance USE RA geometry USE R } Shape { appearance USE TA geometry Text { string ["3"] fontStyle USE FS } } ] } USE Hole ] } DEF a_2_1 Switch { whichChoice 0 choice [ Transform2D { children [ DEF TS_2_1 TouchSensor {} Shape { appearance USE RA geometry USE R } Shape { appearance USE TA geometry Text { string ["4"] fontStyle USE FS } } ] } USE Hole ] } DEF a_2_2 Switch { whichChoice 0 choice [ Transform2D { children [ DEF TS_2_2 TouchSensor {} Shape { appearance USE RA geometry USE R } Shape { appearance USE TA geometry Text { string ["5"] fontStyle USE FS } } ] } USE Hole ] } DEF a_2_3 Switch { whichChoice 0 choice [ Transform2D { children [ DEF TS_2_3 TouchSensor {} Shape { appearance USE RA geometry USE R } Shape { appearance USE TA geometry Text { string ["6"] fontStyle USE FS } } ] } USE Hole ] } DEF a_3_1 Switch { whichChoice 0 choice [ Transform2D { children [ DEF TS_3_1 TouchSensor {} Shape { appearance USE RA geometry USE R } Shape { appearance USE TA geometry Text { string ["7"] fontStyle USE FS } } ] } USE Hole ] } DEF a_3_2 Switch { whichChoice 0 choice [ Transform2D { children [ DEF TS_3_2 TouchSensor {} Shape { appearance USE RA geometry USE R } Shape { appearance USE TA geometry Text { string ["8"] fontStyle USE FS } } ] } USE Hole ] } DEF a_3_3 Switch { whichChoice 1 choice [ Transform2D { children [ DEF TS_3_3 TouchSensor {} Shape { appearance USE RA geometry USE R } Shape { appearance USE TA geometry Text { string ["9"] fontStyle USE FS } } ] } USE Hole ] } ] } ] } DEF SC Script { eventIn SFVec2f move eventIn SFBool startGame eventIn SFTime tickTime field SFNode txtField USE TextField field SFNode table USE Table field SFInt32 gsize 3 field SFInt32 ghrow 2 field SFInt32 ghcol 2 field SFInt32 gtime 0 field SFInt32 gmoves 0 field SFInt32 gshuffling 0 field SFInt32 size 3 field SFBool isStarted FALSE eventOut SFBool hasWin url ["javascript: function r(low,hi) {return Math.floor((hi-low)*Math.random()+low); } function r1(hi) {return Math.floor((hi-1)*Math.random()+1); } function r0(hi) {return Math.floor((hi)*Math.random()); } function startGame(value) {if (value) {shuffle();gtime = 0;gmoves = 0;isStarted = !isStarted; hasWin = false;}} function stopGame(){isStarted = !isStarted;} function tickTime(value){showStatus();gtime++;} function checkWin(){if (!isStarted) return; if (!isHole(gsize-1,gsize-1)) return;for (i=0;idest;i--) {setValue(row,i,getValue(row,i-1));setHole(row,i-1);}}} function shiftHoleCol(src,dest,col) {src = parseInt(src);dest = parseInt(dest);if (src < dest) {for (i=src;idest;i--){ setValue(i,col,getValue(i-1,col));setHole(i-1,col);}}} function moveRowCol(r,c) { if (!isStarted && !gshuffling) { return; }if (isHole(r,c)) {return; }hc = getHoleInRow(r);if (hc != -1) {shiftHoleRow(hc,c,r);gmoves++;checkWin();return;} hr = getHoleInCol(c);if (hr != -1){shiftHoleCol(hr,r,c);gmoves++;checkWin();return;} } function move(value) {moveRowCol(value.x-1,value.y-1);} function shuffle() {gshuffling = true;for (i=0;i