How to Keep Score in a Game

Материал из Поле цифровой дидактики
Версия от 11:22, 11 апреля 2022; scratch>Jammum (Undo revision 303480 by Sihan666666 (talk) Unexplained removal, this page is still a bit small)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)

Шаблон:NotUsefulШаблон:StubThis tutorial shows how to keep score in a game. First, make a variable named "score". How the game works defines which find of script should be used.

Color Sensing

If it is needed to detect when a sprite touching a particular color, use

when gf clicked
forever
if <touching color [#FFFFFF]?> then
change [score v] by (1)
end
end

If it is wanted to decrease the score when touching a color, change change [score v] by (1) to change [score v] by (-1).

Sprite Sensing

To sense when a sprite touching another sprite, replace <touching color [#FFFFFF]?> with <touching (sprite v)?>.

Click Sensing

To sense if a sprite is clicked, use:

when this sprite clicked
change [points v] by (...::grey)

or

when gf clicked
forever
if <<touching (Sprite v)?> and <mouse down?>> then
change [points v] by (...::grey)

Broadcasts

To use broadcasts, use

when I receive [increase score v]
change [score v] by (1)
when I receive [decrease score v]
change [score v] by (-1)

nl:Scoreteller maken