gpt4 book ai didi

mit-scratch - Scratch游戏计分错误

转载 作者:行者123 更新时间:2023-12-01 15:32:15 26 4
gpt4 key购买 nike

我正在 Scratch 上制作一个桨球游戏(只是为了好玩),但我的计分遇到了问题。如果你想看我已经写的代码,游戏链接是https://scratch.mit.edu/projects/66541388/ .出于某种原因,在玩游戏时,score 变量实际上并不总是改变 1。每次我测试它都会改变不同的数字。关于问题是什么或如何解决它的任何想法?

这是代码的核心:

when green flag clicked
set [Score v] to [0]
set x to (0)
set y to (0)
point in direction (pick random (-90) to (90))
forever
if <(y position) < [-146]> then
broadcast [gameOver v]
stop [all v]
end
if <touching [Paddle v]?> then
change [color v] effect by (pick random (1) to (1000))
change [Score v] by (1)
point in direction (pick random (-90) to (90))
end
move (10) steps
if on edge, bounce
end

最佳答案

虽然两个答案都是正确的,但您可以简单地将评分放在不同的代码块中,使用 wait until <not<touching [Paddle v]>> ,像这样:

when green flag clicked
forever
if <touching [Paddle v]> {
change [color v] effect by (pick random (1) to (1000))
change [Score v] by (1)
wait until <not<touching [Paddle v]>>

关于mit-scratch - Scratch游戏计分错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30873574/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com