Car*_*ado 6 optimization input memory-efficient ti-basic
对于一个实验,我决定使用内置的程序编辑器将一个小游戏编程到我的TI-89中,但是我无法找到一种在没有明显延迟的情况下获得击键的最佳方法.目前我有:
Prgm
70?xpos
70?ypos
Loop
If getKey()=340 Then
xpos+3?xpos
PxlCrcl ypos,xpos,5,1
EndIf
If getKey()=337 Then
xpos-3?xpos
PxlCrcl ypos,xpos,5,1
EndIf
If getKey()=257 Then
Goto end
EndIf
EndLoop
Lbl end
EndPrgm
Run Code Online (Sandbox Code Playgroud)
这会创建一个无限的游戏循环,检查是否按下了左,右或删除按钮并相应地向左或向右绘制一个圆圈或完全结束程序.然而,这种方法似乎运行得非常缓慢,我在其他演示中看到了更平稳的运动.我的方法有问题吗?如果有,我怎样才能改进它?
抱歉,我使用的是 TI-84,但这个方法应该仍然有效。
getKey() 函数是创建延迟的函数。如果将输出放入变量中,则只需运行 getKey() 函数一次。在 TI-84 中,你可以这样做
getKey->K
Run Code Online (Sandbox Code Playgroud)
您应该能够使用 TI-89 执行完全相同的操作。
希望这可以帮助!