weixin_33735077 2017-02-17 08:22 采纳率: 0%
浏览 26

jQuery循环(PHP + SQL)

I've built a very basic game around an 50ms gameloop (setinterval) and I've been considering how to fetch player positions. So far I've had the idea to use ajax to post the player position to a php script which will update a sql database, then select all player positions and pass them back in the return. However i'm concerned that this may hit a race condition or that the entire action will simply take to long >5ms, it also feels wasteful to repeatedly poll the sql database for the same data (player positions). Is there a more effective way to achieve this? I've started looking at caching and sharing objects between php instances but not found much info

  • 写回答

1条回答 默认 最新

  • elliott.david 2017-02-19 09:40
    关注

    It probably is not needed to write this to your database all the time. Use an extension like APCu. You could still write the player's positions to the database at regular intervals with a background process.

    It probably is also not needed to return all user positions, but only those that are nearby. From your comment I understood that your game has different worlds, so you would only need to return the user positions that relate to the world the player is in. And even then you could limit it further based on distance, if the player's view on that world only covers a part of it at any time.

    评论

报告相同问题?

悬赏问题

  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)