// Text of project C:\Documents and Settings\Administrator\My Documents\My Downloads\Newton\Programming\Newton Projects\Backyard\Backyard.NTK written on: 05/01/04 14:28:34 // Beginning of file winner.lyt main := {viewBounds: {left: -3, top: 80, bottom: 154, right: 191}, ViewSetupFormScript: // be sure to call inherited:?ViewSetupFormScript() func() begin Print("create local winningScore"); local winningScore:="You Win!!!"; Print("Get countHoles.text"); winningTotal:=StringToNumber(countHoles.text); Print("Testing for countHoles number"); if winningTotal <= 2 then winningScore:=winningScore & "\nBackyard Master"; if winningTotal > 2 and winningTotal <= 4 then winningScore:=winningScore & "\nOne Great Digger"; if winningTotal > 4 and winningTotal <= 7 then winningScore:=winningScore & "\nGood job with the Shovel"; if winningTotal > 7 and winningTotal <=10 then winningScore:=winningScore & "\nYou could use a few more lessons"; if winningTotal > 10 and winningTotal <= 17 then winningScore:=winningScore & "\nOkay, keep trying"; if winningTotal > 17 then winningScore:="You didn't really win as much as you finished"; Print("Found winningTotal is " & winningTotal); SetValue(winText,'text,winningScore); Print("Have SetValue"); inherited:?ViewSetupFormScript(); end, winningTotal: nil, ViewQuitScript: // must return the value of inherited:?ViewQuitScript() func() begin gamePlaying:=nil; inherited:?ViewQuitScript(); end, debug: "main", _proto: @180 }; winText := /* child of main */ {text: "Winner!!!!", viewBounds: {left: 2, top: 12, right: 192, bottom: 62}, viewJustify: 6, viewFont: ROM_fontSystem14Bold, debug: "winText", _proto: @218 }; // View winText is declared to main constant |layout_winner.lyt| := main; // End of file winner.lyt // Beginning of file memory.lyt main := { ViewSetupDoneScript: func() begin gamePlaying:=nil; bone:={}; //Set allSquares to all squares allSquares:=[square1,square2,square3,square4,square5,square6, square7,square8,square9,square10,square11,square12, square13,square14,square15,square16,square17,square18, square19,square20,square21,square22,square23,square24, square25,square26,square27,square28,square29,square30, square31,square32,square33,square34,square35,square36]; //Set Icon of Each Square and set bottom to nil foreach newSquare in allSquares do begin newSquare.clicked:=nil; newSquare.bottom:=nil; SetValue(newSquare,'icon,icon1); end; end, icon3: BuildPictureViewSlot({ imageFile4: "bones.bmp", maskOption: 0}), gamePlaying: nil, viewFormat: 336, icon11: BuildPictureViewSlot({ imageFile4: "lefttop.bmp", maskOption: 0}), icon8: BuildPictureViewSlot({ imageFile4: "vertical.bmp", maskOption: 0}), flipSquare: func(flipSquare) begin if gamePlaying then begin local totalClicked:=0; flipSquare.clicked:=1; //Check for bone being finished If SetContains(bone.b1.adjacent,flipSquare) then begin SetValue(flipSquare,'icon,icon3); foreach square in bone.b1.adjacent do begin if square.clicked then totalClicked:=totalClicked + 1; end; if totalClicked = bone.b1.totalClicked then begin bone1icon:Hide(); bone.total:=bone.total + 1; SetValue(countBone,'text,NumberStr(bone.total)); foreach square in bone.b1.adjacent do begin SetValue(square,'icon,square.bottom); end; end; end; else if SetContains(bone.b2.adjacent,flipSquare) then begin SetValue(flipSquare,'icon,icon3); foreach square in bone.b2.adjacent do begin if square.clicked then totalClicked:=totalClicked + 1; end; if totalClicked = bone.b2.totalClicked then begin bone.total:=bone.total + 1; SetValue(countBone,'text,NumberStr(bone.total)); bone2icon:Hide(); foreach square in bone.b2.adjacent do begin SetValue(square,'icon,square.bottom); end; end; end; else if SetContains(bone.b3.adjacent,flipSquare) then begin SetValue(flipSquare,'icon,icon3); foreach square in bone.b3.adjacent do begin if square.clicked then totalClicked:=totalClicked + 1; end; if totalClicked = bone.b3.totalClicked then begin bone.total:=bone.total + 1; SetValue(countBone,'text,NumberStr(bone.total)); bone3icon:Hide(); foreach square in bone.b3.adjacent do begin SetValue(square,'icon,square.bottom); end; end; end; else if SetContains(bone.b4.adjacent,flipSquare) then begin SetValue(flipSquare,'icon,icon3); foreach square in bone.b4.adjacent do begin if square.clicked then totalClicked:=totalClicked + 1; end; if totalClicked = bone.b4.totalClicked then begin bone.total:=bone.total + 1; SetValue(countBone,'text,NumberStr(bone.total)); bone4icon:Hide(); foreach square in bone.b4.adjacent do begin SetValue(square,'icon,square.bottom); end; end; end; else begin bone.hole:=bone.hole + 1; SetValue(countHoles,'text,NumberStr(bone.hole)); SetValue(flipSquare,'icon,icon2); end; if bone.total = 4 then begin Print("bone.total equals 4"); winner:Toggle(); end; end; end;, viewFlags: 1, icon5: BuildPictureViewSlot({ imageFile4: "downbone.bmp", maskOption: 0}), viewBounds: {left: 0, top: 0, right: 0, bottom: 0}, icon13: BuildPictureViewSlot({ imageFile4: "leftdown.bmp", maskOption: 0}), icon2: BuildPictureViewSlot({ imageFile4: "empty.bmp", maskOption: 0}), bone: nil, icon10: BuildPictureViewSlot({ imageFile4: "rightdown.bmp", maskOption: 0}), viewJustify: 240, icon7: BuildPictureViewSlot({ imageFile4: "rightbone.bmp", maskOption: 0}), icon4: BuildPictureViewSlot({ imageFile4: "upbone.bmp", maskOption: 0}), declareSelf: 'base, totalClicked: nil, icon12: BuildPictureViewSlot({ imageFile4: "upright.bmp", maskOption: 0}), icon9: BuildPictureViewSlot({ imageFile4: "horizontal.bmp", maskOption: 0}), allSquares: nil, viewClass: 74, icon1: BuildPictureViewSlot({ imageFile4: "blank.bmp", maskOption: 0}), debug: "main", icon6: BuildPictureViewSlot({ imageFile4: "leftbone.bmp", maskOption: 0}) }; _view000 := /* child of main */ {_proto: @163}; square7 := /* child of main */ {viewBounds: {left: 4, top: 82, right: 54, bottom: 132}, buttonClickScript: func() begin :flipSquare(self); end, bottom: nil, viewFormat: 337, clicked: nil, debug: "square7", _proto: @198 }; // View square7 is declared to main square8 := /* child of main */ {viewBounds: {left: 56, top: 82, right: 106, bottom: 132}, buttonClickScript: func() begin :flipSquare(self); end, bottom: nil, viewFormat: 337, clicked: nil, debug: "square8", _proto: @198 }; // View square8 is declared to main square9 := /* child of main */ {viewBounds: {left: 108, top: 82, right: 158, bottom: 132}, buttonClickScript: func() begin :flipSquare(self); end, bottom: nil, viewFormat: 337, clicked: nil, debug: "square9", _proto: @198 }; // View square9 is declared to main square10 := /* child of main */ {viewBounds: {left: 160, top: 82, right: 210, bottom: 132}, buttonClickScript: func() begin :flipSquare(self); end, bottom: nil, viewFormat: 337, clicked: nil, debug: "square10", _proto: @198 }; // View square10 is declared to main square11 := /* child of main */ {viewBounds: {left: 212, top: 82, bottom: 132, right: 262}, buttonClickScript: func() begin :flipSquare(self); end, bottom: nil, viewFormat: 337, clicked: nil, debug: "square11", _proto: @198 }; // View square11 is declared to main square13 := /* child of main */ {viewBounds: {left: 4, top: 134, right: 54, bottom: 184}, buttonClickScript: func() begin :flipSquare(self); end, bottom: nil, viewFormat: 337, clicked: nil, debug: "square13", _proto: @198 }; // View square13 is declared to main square14 := /* child of main */ {viewBounds: {left: 56, top: 134, right: 106, bottom: 184}, buttonClickScript: func() begin :flipSquare(self); end, bottom: nil, viewFormat: 337, clicked: nil, debug: "square14", _proto: @198 }; // View square14 is declared to main square15 := /* child of main */ {viewBounds: {left: 108, top: 134, right: 158, bottom: 184}, buttonClickScript: func() begin :flipSquare(self); end, bottom: nil, viewFormat: 337, clicked: nil, debug: "square15", _proto: @198 }; // View square15 is declared to main square16 := /* child of main */ {viewBounds: {left: 160, top: 134, right: 210, bottom: 184}, buttonClickScript: func() begin :flipSquare(self); end, bottom: nil, viewFormat: 337, clicked: nil, debug: "square16", _proto: @198 }; // View square16 is declared to main square17 := /* child of main */ {viewBounds: {left: 212, top: 134, bottom: 184, right: 262}, buttonClickScript: func() begin :flipSquare(self); end, bottom: nil, viewFormat: 337, clicked: nil, debug: "square17", _proto: @198 }; // View square17 is declared to main square19 := /* child of main */ {viewBounds: {left: 4, top: 186, right: 54, bottom: 236}, buttonClickScript: func() begin :flipSquare(self); end, bottom: nil, viewFormat: 337, clicked: nil, debug: "square19", _proto: @198 }; // View square19 is declared to main square20 := /* child of main */ {viewBounds: {left: 56, top: 186, right: 106, bottom: 236}, buttonClickScript: func() begin :flipSquare(self); end, bottom: nil, viewFormat: 337, clicked: nil, debug: "square20", _proto: @198 }; // View square20 is declared to main square21 := /* child of main */ {viewBounds: {left: 108, top: 186, right: 158, bottom: 236}, buttonClickScript: func() begin :flipSquare(self); end, bottom: nil, viewFormat: 337, clicked: nil, debug: "square21", _proto: @198 }; // View square21 is declared to main square22 := /* child of main */ {viewBounds: {left: 160, top: 186, right: 210, bottom: 236}, buttonClickScript: func() begin :flipSquare(self); end, bottom: nil, viewFormat: 337, clicked: nil, debug: "square22", _proto: @198 }; // View square22 is declared to main square23 := /* child of main */ {viewBounds: {left: 212, top: 186, bottom: 236, right: 262}, buttonClickScript: func() begin :flipSquare(self); end, bottom: nil, viewFormat: 337, clicked: nil, debug: "square23", _proto: @198 }; // View square23 is declared to main square25 := /* child of main */ {viewBounds: {left: 4, top: 238, bottom: 288, right: 54}, buttonClickScript: func() begin :flipSquare(self); end, bottom: nil, viewFormat: 337, clicked: nil, debug: "square25", _proto: @198 }; // View square25 is declared to main square26 := /* child of main */ {viewBounds: {left: 56, top: 238, bottom: 288, right: 106}, buttonClickScript: func() begin :flipSquare(self); end, bottom: nil, viewFormat: 337, clicked: nil, debug: "square26", _proto: @198 }; // View square26 is declared to main square27 := /* child of main */ {viewBounds: {left: 108, top: 238, bottom: 288, right: 158}, buttonClickScript: func() begin :flipSquare(self); end, bottom: nil, viewFormat: 337, clicked: nil, debug: "square27", _proto: @198 }; // View square27 is declared to main square28 := /* child of main */ {viewBounds: {left: 160, top: 238, bottom: 288, right: 210}, buttonClickScript: func() begin :flipSquare(self); end, bottom: nil, viewFormat: 337, clicked: nil, debug: "square28", _proto: @198 }; // View square28 is declared to main square29 := /* child of main */ {viewBounds: {left: 212, top: 238, bottom: 288, right: 262}, buttonClickScript: func() begin :flipSquare(self); end, bottom: nil, viewFormat: 337, clicked: nil, debug: "square29", _proto: @198 }; // View square29 is declared to main square31 := /* child of main */ {viewBounds: {left: 4, top: 290, bottom: 340, right: 54}, buttonClickScript: func() begin :flipSquare(self); end, bottom: nil, viewFormat: 337, clicked: nil, debug: "square31", _proto: @198 }; // View square31 is declared to main square32 := /* child of main */ {viewBounds: {left: 56, top: 290, bottom: 340, right: 106}, buttonClickScript: func() begin :flipSquare(self); end, bottom: nil, viewFormat: 337, clicked: nil, debug: "square32", _proto: @198 }; // View square32 is declared to main square33 := /* child of main */ {viewBounds: {left: 108, top: 290, bottom: 340, right: 158}, buttonClickScript: func() begin :flipSquare(self); end, bottom: nil, viewFormat: 337, clicked: nil, debug: "square33", _proto: @198 }; // View square33 is declared to main square34 := /* child of main */ {viewBounds: {left: 160, top: 290, bottom: 340, right: 210}, buttonClickScript: func() begin :flipSquare(self); end, bottom: nil, viewFormat: 337, clicked: nil, debug: "square34", _proto: @198 }; // View square34 is declared to main square35 := /* child of main */ {viewBounds: {left: 212, top: 290, bottom: 340, right: 262}, buttonClickScript: func() begin :flipSquare(self); end, bottom: nil, viewFormat: 337, clicked: nil, debug: "square35", _proto: @198 }; // View square35 is declared to main square1 := /* child of main */ {viewBounds: {left: 4, top: 30, right: 54, bottom: 80}, buttonClickScript: func() begin :flipSquare(self); end, bottom: nil, viewFormat: 337, clicked: nil, debug: "square1", _proto: @198 }; // View square1 is declared to main square2 := /* child of main */ {viewBounds: {left: 56, top: 30, right: 106, bottom: 80}, buttonClickScript: func() begin :flipSquare(self); end, bottom: nil, viewFormat: 337, clicked: nil, debug: "square2", _proto: @198 }; // View square2 is declared to main square3 := /* child of main */ {viewBounds: {left: 108, top: 30, right: 158, bottom: 80}, buttonClickScript: func() begin :flipSquare(self); end, bottom: nil, viewFormat: 337, clicked: nil, debug: "square3", _proto: @198 }; // View square3 is declared to main square4 := /* child of main */ {viewBounds: {left: 160, top: 30, right: 210, bottom: 80}, buttonClickScript: func() begin :flipSquare(self); end, bottom: nil, viewFormat: 337, clicked: nil, debug: "square4", _proto: @198 }; // View square4 is declared to main square5 := /* child of main */ {viewBounds: {left: 212, top: 30, bottom: 80, right: 262}, buttonClickScript: func() begin :flipSquare(self); end, bottom: nil, viewFormat: 337, clicked: nil, debug: "square5", _proto: @198 }; // View square5 is declared to main _view001 := /* child of main */ {text: "Backyard", viewBounds: {left: 0, top: 4, right: 150, bottom: 27}, viewFont: ROM_fontSystem18Bold, viewJustify: 8388630, viewFormat: 80, _proto: @218 }; _view002 := /* child of main */ { buttonClickScript: func() begin Print("Set bone.total to 0"); bone.total:=0; Print("Set gamePlaying to 0"); gamePlaying:=1; Print("Set bone.count to 0"); bone.count:=0; Print("Set bone.hole to 0"); bone.hole:=0; //Set each icon to blank icon foreach square in allSquares do begin SetValue(square,'icon,icon1); square.bottom:=icon2; square.clicked:=nil; end; Print("Make sure each bone icon is open"); foreach square in [bone1icon,bone2icon,bone3icon,bone4icon] do begin square:Show(); end; //Setup where bones are hidden Print("Setting adjacents"); bone.b1.adjacent:=[square1,square2,square3,square4]; bone.b2.adjacent:=[square14,square20,square26]; bone.b3.adjacent:=[square19,square25,square31,square32,square33]; bone.b4.adjacent:=[square6,square12,square11,square10,square16]; //Setting up bone icons Print("Setting bone icons"); bone.b1.adjacent[0].bottom:=icon7; bone.b1.adjacent[1].bottom:=icon9; bone.b1.adjacent[2].bottom:=icon9; bone.b1.adjacent[3].bottom:=icon6; bone.b1.totalClicked:=4; bone.b2.adjacent[0].bottom:=icon5; bone.b2.adjacent[1].bottom:=icon8; bone.b2.adjacent[2].bottom:=icon4; bone.b2.totalClicked:=3; bone.b3.adjacent[0].bottom:=icon5; bone.b3.adjacent[1].bottom:=icon8; bone.b3.adjacent[2].bottom:=icon12; bone.b3.adjacent[3].bottom:=icon9; bone.b3.adjacent[4].bottom:=icon6; bone.b3.totalClicked:=5; bone.b4.adjacent[0].bottom:=icon5; bone.b4.adjacent[1].bottom:=icon11; bone.b4.adjacent[2].bottom:=icon9; bone.b4.adjacent[3].bottom:=icon10; bone.b4.adjacent[4].bottom:=icon4; bone.b4.totalClicked:=5; Print("Set bone counter to zero"); SetValue(countBone,'text,NumberStr(bone.count)); Print("Set hole counter to zero"); SetValue(countHoles,'text,NumberStr(bone.hole)); end;, text: "Start A New Game", viewBounds: {left: 56, top: 402, bottom: 420, right: 262}, _proto: @226 }; square12 := /* child of main */ {viewBounds: {left: 264, top: 82, bottom: 132, right: 314}, buttonClickScript: func() begin :flipSquare(self); end, bottom: nil, viewFormat: 337, clicked: nil, debug: "square12", _proto: @198 }; // View square12 is declared to main square18 := /* child of main */ {viewBounds: {left: 264, top: 134, bottom: 184, right: 314}, buttonClickScript: func() begin :flipSquare(self); end, bottom: nil, viewFormat: 337, clicked: nil, debug: "square18", _proto: @198 }; // View square18 is declared to main square24 := /* child of main */ {viewBounds: {left: 264, top: 186, bottom: 236, right: 314}, buttonClickScript: func() begin :flipSquare(self); end, bottom: nil, viewFormat: 337, clicked: nil, debug: "square24", _proto: @198 }; // View square24 is declared to main square30 := /* child of main */ {viewBounds: {left: 264, top: 238, bottom: 288, right: 314}, buttonClickScript: func() begin :flipSquare(self); end, bottom: nil, viewFormat: 337, clicked: nil, debug: "square30", _proto: @198 }; // View square30 is declared to main square36 := /* child of main */ {viewBounds: {left: 264, top: 290, bottom: 340, right: 314}, buttonClickScript: func() begin :flipSquare(self); end, bottom: nil, viewFormat: 337, clicked: nil, debug: "square36", _proto: @198 }; // View square36 is declared to main square6 := /* child of main */ {viewBounds: {left: 264, top: 30, bottom: 80, right: 314}, buttonClickScript: func() begin :flipSquare(self); end, bottom: nil, viewFormat: 337, clicked: nil, debug: "square6", _proto: @198 }; // View square6 is declared to main bone3icon := /* child of main */ { icon: BuildPictureViewSlot({ imageFile4: "total1.bmp", maskOption: 0}), viewBounds: {left: 113, top: 344, bottom: 394, right: 163}, viewFlags: 1, debug: "bone3icon", viewClass: 76 }; // View bone3icon is declared to main bone1icon := /* child of main */ { icon: BuildPictureViewSlot({ imageFile4: "total2.bmp", maskOption: 0}), viewBounds: {left: 163, top: 344, bottom: 394, right: 213}, viewFlags: 1, debug: "bone1icon", viewClass: 76 }; // View bone1icon is declared to main bone2icon := /* child of main */ { icon: BuildPictureViewSlot({ imageFile4: "total3.bmp", maskOption: 0}), viewBounds: {left: 213, top: 344, bottom: 394, right: 263}, viewFlags: 1, debug: "bone2icon", viewClass: 76 }; // View bone2icon is declared to main bone4icon := /* child of main */ { icon: BuildPictureViewSlot({ imageFile4: "total4.bmp", maskOption: 0}), viewBounds: {left: 263, top: 344, bottom: 394, right: 313}, viewFlags: 1, debug: "bone4icon", viewClass: 76 }; // View bone4icon is declared to main winner := /* child of main */ LinkedSubview(main, {viewBounds: {left: 12, top: 2, right: 32, bottom: 22}, debug: "winner"}) // View winner is declared to main _view003 := /* child of main */ {text: "Bones:", viewBounds: {left: 5, top: 344, bottom: 364, right: 75}, viewJustify: 8388613, _proto: @218 }; _view004 := /* child of main */ {text: "Holes:", viewBounds: {left: 5, top: 374, bottom: 394, right: 75}, viewJustify: 8388613, _proto: @218 }; countBone := /* child of main */ {text: "0", viewBounds: {left: 75, top: 344, bottom: 364, right: 105}, viewJustify: 8388612, debug: "countBone", _proto: @218 }; // View countBone is declared to main countHoles := /* child of main */ {text: "0", viewBounds: {left: 75, top: 374, bottom: 394, right: 105}, viewJustify: 8388612, debug: "countHoles", _proto: @218 }; // View countHoles is declared to main constant |layout_memory.lyt| := main; // End of file memory.lyt