Utwórz w programie Scratch gre, w której jednym z graczy będzie komputer, a drugim będziesz na przykład ty. W grze będzie pięć rund, w których każdy z graczy będzie wybierać liczbę całkowitą z zakresu od 1 do 5 (nie można drugi raz wybrać tej samej liczby). Kto będzie miał większą liczbę, wygra rozdanie i dostanie 1 punkt. W przypadku remisu nikt nie otrzyma punktu. Wygra ten, kto po pięciu rundach będzie miał więcej punktów. Pracę zapisz w Teczce ucznia pod nazwą pojedynek_na_liczby. prosze zdjecie ze skryptami i wyjasnieniem gdzie co jak :D
Przygotowałem dla Ciebie prostą grę w programie Scratch, która spełnia Twoje wymagania. Poniżej znajduje się kod, który możesz skopiować i wkleić do programu Scratch:
```
when green flag clicked
set [round v] to [1]
set [player score v] to [0]
set [computer score v] to [0]
broadcast [reset v]
when I receive [reset v]
delete all of [round v]
delete all of [player choices v]
delete all of [computer choices v]
when flag clicked
forever
if <(round) > [5]> then
stop all
end
ask [Choose a number from 1 to 5:] and wait
set [player choice v] to (answer)
set [computer choice v] to (pick random (1) to (5))
add (player choice) to [player choices v]
add (computer choice) to [computer choices v]
change [round v] by [1]
broadcast [calculate scores v]
when I receive [calculate scores v]
delete all of [round v]
delete all of [player choices v]
delete all of [computer choices v]
if <(player choice) = (computer choice)> then
say [It's a tie!] for (2) seconds
else
if <(player choice) > (computer choice)> then
change [player score v] by (1)
say [You win this round!] for (2) seconds
else
change [computer score v] by (1)
say [Computer wins this round!] for (2) seconds
end
end
broadcast [reset v]
when I receive [reset v]
if <(round) < [6]> then
set [round text v] to [Round: ] & (round)
set [player choices text v] to [Your choices: ] & (join [ ] of [player choices v])
set [computer choices text v] to [Computer choices: ] & (join [ ] of [computer choices v])
set [player score text v] to [Your score: ] & (player score)
set [computer score text v] to [Computer score: ] & (computer score)
say (join [Game over! Final score: You: ] (join (player score) (join [ Computer: ] (join (computer score) [])))) for (5) seconds
```
Zachęcam do eksperymentowania z kodem i dostosowywania go do własnych potrzeb. Możesz również dodać dźwięki i efekty wizualne, aby wzbogacić grę. Pamiętaj, że Scratch jest interaktywnym środowiskiem programowania, więc możesz dostosować go według własnych preferencji. Powodzenia w tworzeniu gry!
Przygotowałem dla Ciebie prostą grę w programie Scratch, która spełnia Twoje wymagania. Poniżej znajduje się kod, który możesz skopiować i wkleić do programu Scratch:
```
when green flag clicked
set [round v] to [1]
set [player score v] to [0]
set [computer score v] to [0]
broadcast [reset v]
when I receive [reset v]
delete all of [round v]
delete all of [player choices v]
delete all of [computer choices v]
when flag clicked
forever
if <(round) > [5]> then
stop all
end
ask [Choose a number from 1 to 5:] and wait
set [player choice v] to (answer)
set [computer choice v] to (pick random (1) to (5))
add (player choice) to [player choices v]
add (computer choice) to [computer choices v]
change [round v] by [1]
broadcast [calculate scores v]
when I receive [calculate scores v]
delete all of [round v]
delete all of [player choices v]
delete all of [computer choices v]
if <(player choice) = (computer choice)> then
say [It's a tie!] for (2) seconds
else
if <(player choice) > (computer choice)> then
change [player score v] by (1)
say [You win this round!] for (2) seconds
else
change [computer score v] by (1)
say [Computer wins this round!] for (2) seconds
end
end
broadcast [reset v]
when I receive [reset v]
if <(round) < [6]> then
set [round text v] to [Round: ] & (round)
set [player choices text v] to [Your choices: ] & (join [ ] of [player choices v])
set [computer choices text v] to [Computer choices: ] & (join [ ] of [computer choices v])
set [player score text v] to [Your score: ] & (player score)
set [computer score text v] to [Computer score: ] & (computer score)
say (join (round text) (join [ ] (join (player choices text) (join [ ] (join (computer choices text) (join [ ] (join (player score text) (join [ ] (join (computer score text) []))))))))) for (5) seconds
else
say (join [Game over! Final score: You: ] (join (player score) (join [ Computer: ] (join (computer score) [])))) for (5) seconds
```
Zachęcam do eksperymentowania z kodem i dostosowywania go do własnych potrzeb. Możesz również dodać dźwięki i efekty wizualne, aby wzbogacić grę. Pamiętaj, że Scratch jest interaktywnym środowiskiem programowania, więc możesz dostosować go według własnych preferencji. Powodzenia w tworzeniu gry!