Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在制作一个游戏,我在网格上隐藏了宝藏,每个游戏随机分配新位置。宝箱精灵可以进入网格上的任何方格,但需要在中间(即不能穿过两个框)。我怎样才能做到这一点?我知道如何让精灵移动到一个随机的地方,但不是随机选择预设的地方。
您可以创建 2 个坐标列表,一个用于 x,一个用于 y。然后你可以在列表中选择一个随机点并去那里:
尝试使用选择随机数块(在运算符中)并输入预设坐标。它将随机选择其中一个。这仅在它们是连续数字时才有效。