如何编写能量补充游戏的计时器算法

发布于 2024-12-13 07:15:13 字数 150 浏览 5 评论 0原文

与 Facebook 上的俄罗斯方块类似,如果你的能量为 100,那么在使用(玩游戏)后,它会减少 5 个单位,并且每 10 分钟充电 1 个单位。我很好奇如何处理轮询,并可能将其设置为服务器端,这样就不会出现“时间操纵”(例如将未来的时钟向前设置)来规避提前接收能量的措施。提前致谢!

Similar to Tetris on Facebook, where if you're at 100 Energy, after usage (playing a game), it goes down 5 units, and the recharges 1 unit every 10 minutes. I'm curious how to handle polling, and possibly making it server-side so that there's no "time manipulation" (e.g setting the clock forward in the future) to circumvent measures for receiving energy early. Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

影子是时光的心 2024-12-20 07:15:14

您将需要某种持久性基础设施,理想情况下您希望从客户端对服务器运行检查,只需让它在加载时返回一个带有值的 JSON 字符串即可。另外,不要使用客户端时钟,因为这可能会在机器等之间发生变化,这不会产生理想的结果。

You will need some kind of persistent infrastructure, and ideally you want to run a check against the server from the client side, just have it return a JSON string with the value whenever it loads. Also, don't use the client clock, because that could change across machines etc. which would not yield the ideal results.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文