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