[Thread Prev] [Thread Next]
<J wrote
<I'll post David's solution in a few days.
<(This will give Members of MicroWorld Forum a chance to write their own
<solutions, if they care to.)
<
<Regards
<J (also known as GP)
David's procedures are listed below for digest members.
His program seems to be running without error.
He did not complete the "person versus computer" part of the project.
His use of freeze and unfreeze is incorrect. What he wanted to do, was to
prevent a player from changing "who goes 1st" in the middle of a game.
He seriously lacks comments in his coding. I'll have to talk to him about
that.
Regards
J.
<<<<<<<<<< david's pickup >>>>>>>>>
(see attachment for complete project)
to who.1st
ifelse Turn = p1
[setTurn p2]
[setTurn p1]
end
to new
unfreeze "button4
settext1 #.of.sticks
setSticks #.of.sticks
cc
setPlayer1 0
setPlayer2 0
settext3 p1
settext4 p2
end
to m1
freeze "button4
if text1 < 1
[oops]
settext1 text1 - 1
setSticks Sticks - 1
if Turn = p1
[setPlayer1 Player1 + 1]
if Turn = p2
[setPlayer2 Player2 + 1]
who.1st
if text1 = 0
[winner]
end
to m2
freeze "button4
if text1 < 2
[oops]
settext1 text1 - 2
setSticks Sticks - 2
if Turn = p1
[setPlayer1 Player1 + 2]
if Turn = p2
[setPlayer2 Player2 + 2]
who.1st
if text1 = 0
[winner]
end
to m3
freeze "button4
if text1 < 3
[oops]
settext1 text1 - 3
setSticks Sticks - 3
if Turn = p1
[setPlayer1 Player1 + 3]
if Turn = p2
[setPlayer2 Player2 + 3]
who.1st
if text1 = 0
[winner]
end
to winner
if Turn = p1
[player1.win]
if Turn = p2
[player2.win]
end
to player1.win
announce [Player1 is the winner!]
settext7 text7 + 1
setGames text7 + text8
end
to player2.win
announce [Player2 is the winner!]
settext8 text8 + 1
setGames text7 + text8
end
to oops
announce [There are not enough sticks!]
stopall
end
to reset
settext7 0
settext8 0
setGames 0
end
to Vs.Person
David.Vs.Person
end
to Vs.Computer
Computer
end
to Smart
David.vs.S.Computer
end
to Dumb
David.vs.D.Computer
end
to Main
Start
end
to Instructions
Instruction
freeze "Rules
end
to Players
question [Player1, enter your name.]
setp1 answer
question [Player2, enter your name.]
setp2 answer
end
to startup
set "project "presentationmode? "true
launch [blink]
end
to blink
Start
text1, forever [showtext wait 5 hidetext wait 5]
wait 10
text2, forever [showtext wait 10 hidetext wait 10]
end
<<<<<<< end >>>>>>>>>>>
Attachment:
Davids-Pickup.mw2
Description: Binary data
Previous by thread:
text error in Bobbing Buttons
Next by thread:
to advance the turtle
To save an attachment to your computer, PC users should right-click (Mac users, click and hold the mouse button) on the link and then choose 'save target as' from the pop-up menu. A window will then pop up in which you can choose a location for the file.
|