// Text of project C:\Documents and Settings\Administrator\My Documents\My Downloads\Newton\Programming\Newton Projects\Shuffle\Shuffle.NTK written on: 07/30/03 18:18:42 // Beginning of file winBox.lyt _view000 := {viewBounds: {left: 2, top: 100, right: 146, bottom: 174}, _proto: @180}; _view001 := /* child of _view000 */ {text: "You Win!", viewBounds: {left: 12, top: 12, right: 132, bottom: 62}, _proto: @218 }; constant |layout_winBox.lyt| := _view000; // End of file winBox.lyt // Beginning of file main.lyt Main := {value11: "11", emptyValue: func(movingSquare,newValue) begin if movingSquare = button1 then value1:=newValue; if movingSquare = button2 then value2:=newValue; if movingSquare = button3 then value3:=newValue; if movingSquare = button4 then value4:=newValue; if movingSquare = button5 then value5:=newValue; if movingSquare = button6 then value6:=newValue; if movingSquare = button7 then value7:=newValue; if movingSquare = button8 then value8:=newValue; if movingSquare = button9 then value9:=newValue; if movingSquare = button10 then value10:=newValue; if movingSquare = button11 then value11:=newValue; if movingSquare = button12 then value12:=newValue; if movingSquare = button13 then value13:=newValue; if movingSquare = button14 then value14:=newValue; if movingSquare = button15 then value15:=newValue; if movingSquare = button16 then value16:=newValue; end;, ViewSetupDoneScript: func() begin emptyButton:=button16; value1:="1"; value2:="2"; value3:="3"; value4:="4"; value5:="5"; value6:="6"; value7:="7"; value8:="8"; value9:="9"; value10:="10"; value11:="11"; value12:="12"; value13:="13"; value14:="14"; value15:="15"; value16:=nil; end, value8: "8", viewFormat: 83951953, value16: " ", value5: "5", value13: "13", viewBounds: {left: 0, top: 10, bottom: 301, right: 250}, value2: "2", _proto: @157, checkWin: func() begin if StrEqual(value1,"1") then if StrEqual(value2,"2") then if StrEqual(value3,"3") then if StrEqual(value4,"4") then if StrEqual(value5,"5") then if StrEqual(value6,"6") then if StrEqual(value7,"7") then if StrEqual(value8,"8") then if StrEqual(value9,"9") then if StrEqual(value10,"10") then if StrEqual(value11,"11") then if StrEqual(value12,"12") then if StrEqual(value13,"13") then if StrEqual(value14,"14") then if StrEqual(value15,"15") then winBox:Open(); end;, value10: "10", value7: "7", value15: "15", title: "Shuffle", value4: "4", value12: "12", value9: "9", value1: "1", emptyButton: nil, changingValue: func(changedValue,random) begin If random = 1 then begin value1:=changedValue; SetValue(button1,'text,value1); end; If random = 2 then begin value2:=changedValue; SetValue(button2,'text,value2); end; If random = 3 then begin value3:=changedValue; SetValue(button3,'text,value3); end; If random = 4 then begin value4:=changedValue; SetValue(button4,'text,value4); end; If random = 5 then begin value5:=changedValue; SetValue(button5,'text,value5); end; If random = 6 then begin value6:=changedValue; SetValue(button6,'text,value6); end; If random = 7 then begin value7:=changedValue; SetValue(button7,'text,value7); end; If random = 8 then begin value8:=changedValue; SetValue(button8,'text,value8); end; If random = 9 then begin value9:=changedValue; SetValue(button9,'text,value9); end; If random = 10 then begin value10:=changedValue; SetValue(button10,'text,value10); end; If random = 11 then begin value1:=changedValue; SetValue(button11,'text,value11); end; If random = 12 then begin value12:=changedValue; SetValue(button12,'text,value12); end; If random = 13 then begin value13:=changedValue; SetValue(button13,'text,value13); end; If random = 14 then begin value14:=changedValue; SetValue(button14,'text,value14); end; If random = 15 then begin value15:=changedValue; SetValue(button15,'text,value15); end; If random = 16 then begin value1:=changedValue; SetValue(button16,'text,value16); end; end;, value6: "6", debug: "Main", value14: "14", randomValue: func(randomNumber) begin if randomNumber=1 then return value1; if randomNumber=2 then return value2; if randomNumber=3 then return value3; if randomNumber=4 then return value4; if randomNumber=5 then return value5; if randomNumber=6 then return value6; if randomNumber=7 then return value7; if randomNumber=8 then return value8; if randomNumber=9 then return value9; if randomNumber=10 then return value10; if randomNumber=11 then return value11; if randomNumber=12 then return value12; if randomNumber=13 then return value13; if randomNumber=14 then return value14; if randomNumber=15 then return value15; if randomNumber=16 then return value16; end;, value3: "3", checkSquares: func(adjSquare1,adjSquare2,adjSquare3,adjSquare4) begin If adjSquare1=emptyButton then return adjSquare1; If adjSquare2=emptyButton then return adjSquare2; If adjSquare3=emptyButton then return adjSquare3; If adjSquare4=emptyButton then return adjSquare4; end }; _view002 := /* child of Main */ {viewBounds: {left: 5, top: 17, right: 243, bottom: 255}, _proto: @160}; button1 := /* child of _view002 */ { buttonClickScript: func() begin emptySquare:=:checkSquares(button2,button5,nil,nil); if emptySquare then begin :emptyValue(emptySquare,value1); SetValue(emptySquare,'text,value1); value1:=""; SetValue(button1,'text,value1); emptyButton:=button1; end; :checkWin(); end;, text: "1", viewBounds: {left: 3, top: 3, right: 58, bottom: 58}, viewJustify: 8388614, viewFormat: 33554513, viewFont: simpleFont18, debug: "button1", _proto: @226 }; // View button1 is declared to Main button2 := /* child of _view002 */ { buttonClickScript: func() begin emptySquare:=:checkSquares(button1,button3,button6,nil); if emptySquare then begin :emptyValue(emptySquare,value2); SetValue(emptySquare,'text,value2); value2:=""; SetValue(button2,'text,value2); emptyButton:=button2; end; :checkWin(); end;, text: "2", viewBounds: {left: 62, top: 3, right: 117, bottom: 58}, viewJustify: 8388614, viewFormat: 33554513, viewFont: simpleFont18, debug: "button2", _proto: @226 }; // View button2 is declared to Main button3 := /* child of _view002 */ { buttonClickScript: func() begin emptySquare:=:checkSquares(button2,button4,button7,nil); if emptySquare then begin :emptyValue(emptySquare,value3); SetValue(emptySquare,'text,value3); value3:=""; SetValue(button3,'text,value3); emptyButton:=button3; end; :checkWin(); end;, text: "3", viewBounds: {left: 121, top: 3, right: 176, bottom: 58}, viewFormat: 33554513, viewFont: simpleFont18, debug: "button3", _proto: @226 }; // View button3 is declared to Main button4 := /* child of _view002 */ { buttonClickScript: func() begin emptySquare:=:checkSquares(button3,button8,nil,nil); if emptySquare then begin :emptyValue(emptySquare,value4); SetValue(emptySquare,'text,value4); value4:=""; SetValue(button4,'text,value4); emptyButton:=button4; end; :checkWin(); end;, text: "4", viewBounds: {left: 180, top: 3, right: 235, bottom: 58}, viewFormat: 33554513, viewFont: simpleFont18, debug: "button4", _proto: @226 }; // View button4 is declared to Main button5 := /* child of _view002 */ { buttonClickScript: func() begin emptySquare:=:checkSquares(button1,button6,button9,nil); if emptySquare then begin :emptyValue(emptySquare,value5); SetValue(emptySquare,'text,value5); value5:=""; SetValue(button5,'text,value5); emptyButton:=button5; end; :checkWin(); end;, text: "5", viewBounds: {left: 3, top: 62, right: 58, bottom: 117}, viewFormat: 33554513, viewFont: simpleFont18, debug: "button5", _proto: @226 }; // View button5 is declared to Main button6 := /* child of _view002 */ { buttonClickScript: func() begin emptySquare:=:checkSquares(button5,button7,button2,button10); if emptySquare then begin :emptyValue(emptySquare,value6); SetValue(emptySquare,'text,value6); value6:=""; SetValue(button6,'text,value6); emptyButton:=button6; end; :checkWin(); end;, text: "6", viewBounds: {left: 62, top: 62, right: 117, bottom: 117} , viewFormat: 33554513, viewFont: simpleFont18, debug: "button6", _proto: @226 }; // View button6 is declared to Main button7 := /* child of _view002 */ { buttonClickScript: func() begin emptySquare:=:checkSquares(button6,button8,button3,button11); if emptySquare then begin :emptyValue(emptySquare,value7); SetValue(emptySquare,'text,value7); value7:=""; SetValue(button7,'text,value7); emptyButton:=button7; end; :checkWin(); end;, text: "7", viewBounds: {left: 121, top: 62, right: 176, bottom: 117}, viewFormat: 33554513, viewFont: simpleFont18, debug: "button7", _proto: @226 }; // View button7 is declared to Main button8 := /* child of _view002 */ { buttonClickScript: func() begin emptySquare:=:checkSquares(button4,button7,button12,nil); if emptySquare then begin :emptyValue(emptySquare,value8); SetValue(emptySquare,'text,value8); value8:=""; SetValue(button8,'text,value8); emptyButton:=button8; end; :checkWin(); end;, text: "8", viewBounds: {left: 180, top: 62, right: 235, bottom: 117}, viewFormat: 33554513, viewFont: simpleFont18, debug: "button8", _proto: @226 }; // View button8 is declared to Main button9 := /* child of _view002 */ { buttonClickScript: func() begin emptySquare:=:checkSquares(button5,button13,button10,nil); if emptySquare then begin :emptyValue(emptySquare,value9); SetValue(emptySquare,'text,value9); value9:=""; SetValue(button9,'text,value9); emptyButton:=button9; end; :checkWin(); end;, text: "9", viewBounds: {left: 3, top: 121, right: 58, bottom: 176}, viewFormat: 33554513, viewFont: simpleFont18, debug: "button9", _proto: @226 }; // View button9 is declared to Main button10 := /* child of _view002 */ { buttonClickScript: func() begin emptySquare:=:checkSquares(button6,button9,button11,button14); if emptySquare then begin :emptyValue(emptySquare,value10); SetValue(emptySquare,'text,value10); value10:=""; SetValue(button10,'text,value10); emptyButton:=button10; end; :checkWin(); end;, text: "10", viewBounds: {left: 62, top: 121, right: 117, bottom: 176}, viewFormat: 33554513, viewFont: simpleFont18, debug: "button10", _proto: @226 }; // View button10 is declared to Main button11 := /* child of _view002 */ { buttonClickScript: func() begin emptySquare:=:checkSquares(button7,button15,button10,button12); if emptySquare then begin :emptyValue(emptySquare,value11); SetValue(emptySquare,'text,value11); value11:=""; SetValue(button11,'text,value11); emptyButton:=button11; end; :checkWin(); end;, text: "11", viewBounds: {left: 121, top: 121, right: 176, bottom: 176}, viewFormat: 33554513, viewFont: simpleFont18, debug: "button11", _proto: @226 }; // View button11 is declared to Main button12 := /* child of _view002 */ { buttonClickScript: func() begin emptySquare:=:checkSquares(button8,button11,button16,nil); if emptySquare then begin :emptyValue(emptySquare,value12); SetValue(emptySquare,'text,value12); value12:=""; SetValue(button12,'text,value12); emptyButton:=button12; end; :checkWin(); end;, text: "12", viewBounds: {left: 180, top: 121, right: 235, bottom: 176}, viewFormat: 33554513, viewFont: simpleFont18, debug: "button12", _proto: @226 }; // View button12 is declared to Main button13 := /* child of _view002 */ { buttonClickScript: func() begin emptySquare:=:checkSquares(button9,button14,nil,nil); if emptySquare then begin :emptyValue(emptySquare,value13); SetValue(emptySquare,'text,value13); value13:=""; SetValue(button13,'text,value13); emptyButton:=button13; end; :checkWin(); end;, text: "13", viewBounds: {left: 3, top: 180, right: 58, bottom: 235} , viewFormat: 33554513, viewFont: simpleFont18, debug: "button13", _proto: @226 }; // View button13 is declared to Main button14 := /* child of _view002 */ { buttonClickScript: func() begin emptySquare:=:checkSquares(button13,button15,button10,nil); if emptySquare then begin :emptyValue(emptySquare,value14); SetValue(emptySquare,'text,value14); value14:=""; SetValue(button14,'text,value14); emptyButton:=button14; end; :checkWin(); end;, text: "14", viewBounds: {left: 62, top: 180, right: 117, bottom: 235}, viewFormat: 33554513, viewFont: simpleFont18, debug: "button14", _proto: @226 }; // View button14 is declared to Main button15 := /* child of _view002 */ { buttonClickScript: func() begin emptySquare:=:checkSquares(button14,button16,button11,nil); if emptySquare then begin :emptyValue(emptySquare,value15); SetValue(emptySquare,'text,value15); value15:=""; SetValue(button15,'text,value15); emptyButton:=button15; end; :checkWin(); end;, text: "15", viewBounds: {left: 121, top: 180, right: 176, bottom: 235}, viewFormat: 33554513, viewFont: simpleFont18, debug: "button15", _proto: @226 }; // View button15 is declared to Main button16 := /* child of _view002 */ { buttonClickScript: func() begin emptySquare:=:checkSquares(button15,button12,nil,nil); if emptySquare then begin :emptyValue(emptySquare,value16); SetValue(emptySquare,'text,value16); value16:=""; SetValue(button16,'text,value16); emptyButton:=button16; end; :checkWin(); end;, text: "", viewBounds: {left: 180, top: 180, right: 235, bottom: 235}, viewFormat: 33554513, viewFont: simpleFont18, debug: "button16", _proto: @226 }; // View button16 is declared to Main _view003 := /* child of Main */ { buttonClickScript: func() begin local otherBox; local valueChange; for i:= 1 to 40 do begin randomNumber:=random(1,16); changedValue:=value1; value1:=:randomValue(randomNumber); :changingValue(changedValue,randomNumber); SetValue(button1,'text,value1); end; end;, text: "Game", viewBounds: {left: 89, top: 258, bottom: 274, right: 155}, _proto: @226 }; winBox := /* child of Main */ LinkedSubview(_view000, {viewBounds: {left: 207, top: 2, right: 217, bottom: 12}, debug: "winBox"}) // View winBox is declared to Main constant |layout_main.lyt| := Main; // End of file main.lyt