一个简单的游戏,每次迭代运行其逻辑,并以命令式语言每秒抽取60次屏幕可能如下所示:
function main() {
player = new Player()
lastUpdateTime, lastDrawTime = getTime()
while (!quit) {
deltaTime = getTime() - lastUpdateTime
player.update(deltaTime)
if (getTime() - lastDrawTime > 1/60) {
player.draw()
lastDrawTime = getTime()
}
lastUpdateTime = getTime()
}
delete player
}
我只是不确定这是如何转化为反应性香蕉的。