Search code examples
optimizationinputmemory-efficientti-basic

Optimal Method of Checking Keypresses on TI-89


for an experiment I decided to program a little game into my TI-89 using the built in program editor, however I cannot figure out an optimal method of getting keystrokes without significant delay. Currently I 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 if the left, right, or delete buttons are being pressed and draw a circle left or right accordingly or end the program entirely. However, this method seems to run extremely slowly and I have seen much smoother movement in other demonstrations. Is there something wrong with my method and if so how can I improve it?


Solution

  • Sorry, I use a TI-84, but this method should still work.

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

    getKey->K
    

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

    Hope this helps!