搜尋此網誌

Glossary script

keyboard controller

keyboard controller for games that every keystroke is critical.

長話短說:
  • 不要做polling / 不要每frame檢查一個鍵是否被按下
  • 用event driven model
  • 一個frame之內其實可以有多於一個鍵, 如果你的遊戲不可以漏鍵的話, 用一個緩衝器儲住按鍵
  • 定時定刻地 從緩衝器擷取按鍵
  • 小心處理程式並行性的問題 / 不要給其他pseudo-thread堵塞了流程
  • 如果不明所以, 就用F.core提供的鍵盤控制程式吧
{"polling":"唔識譯","frame":"幀","event driven model":"事件驅動的模式","pseudo-thread":"偽執行緒"}

in short:
  • never do polling / never check whether a key is down every frame
  • listen to key events / use an event driven model
  • if it is critical that every key must be captured / no keys can be dropped, buffer the key inputs
  • fetch the buffer at a defined point in the game loop
  • watch out for concurrency issues / do not get your event listener blocked by other pseudo-threads
  • use the carefully built keyboard controller provided by F.core

F.core/controller.js

0 comments:

Post a Comment