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?
getKey()
to a variable then testing the variable? I don't have my calculator on me to test this, but it seems like maybe runninggetKey()
multiple times (one for everyIf
statement) might slow it down more than simply testing a variable. – Gormless