Home
Project Folders
Teacher Resources
Student Resources
How Do I?
Literacy
MWForum
Site Map
Search
Our Team
How do I keep score in a game?
Method 1:   Use a textbox.

to reset
setscore 0
everyone [st]
end

to go
resett
everyone [st forever [fd 1 / 3]]
when [score = 20] [announce (se [You clicked all 20 balls in] timer / 10 "seconds!) stopall]
end

to touch
ht
setscore score + 1
end
Click go to set the balls in motion. How fast can you click all 20 turtles to make them vanish? The instruction for each turtle is touch.

Method 2:   Create a variable with make.

to reset
make "score 0
everyone [st]
end

to go
reset
resett
everyone [st forever [fd 1 / 3]]
when [:score = 20] [announce (se [You clicked all 20 balls in] timer / 10 "seconds!) stopall]
end

to touch
ht
make "score :score + 1
end
The variable score increases in value with each click of a ball.

Note:  These projects also demonstrate the use of a timer in a game. See How do I set up a timer in a game? for more information.

« Previous
Menu
Next »


© copyright 2001 - 2008  OpenWorld Learning.   All rights reserved.