The best way to test keystrokes on the TI-89

for the experiment, I decided to program a small game in my TI-89 using the built-in program editor, but I can’t find the best way to get keystrokes without significant delay. I currently have:

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 

This creates an endless game loop that checks whether the left, right, or delete buttons are pressed, and draw a circle left or right, respectively, or complete the program. However, this method works very slowly, and I saw much smoother movement in other demos. Something is wrong with my method, and if so, how can I improve it?

+6
source share
2 answers

Sorry, I'm using TI-84, but this method should still work.

The getKey () function is a function that creates a delay. You only need to run the getKey () function once if you put the output in a variable. In TI-84 you can just do

 getKey->K 

You should be able to do the same with the TI-89.

Hope this helps!

+3
source

I usually use the While not () statement, and then check the response.

for instance

 loop 0 -> X while not(X) do something every iteration getKey() if Ans: Ans -> X Check values of X with If statements End loop 

Thus, you simply execute some code (perhaps some basic addition and subtraction or the For loop slows down) and one If statement in each cycle of the While statement instead of checking many If statements on each cycle.

This serves you well and allows you to do something on each iteration of the While loop, while still checking for a key press.

Please note that I usually program on TI-84, but the idea should work a lot on TI-89 with a small amount of settings.

0
source

Source: https://habr.com/ru/post/985301/


All Articles