July 15, 2020, 04:50:51 am

The shoutbox is currently out of service. Join us on Discord instead.
You can help CodeWalrus stay online by donating here.

WARNING: DO NOT UPGRADE your TI-83 Premium CE or TI-84 Plus CE to OS 5.5.1 and higher. It removes all compatibility with most games and removes ASM/C programming! DOWNGRADING IS IMPOSSIBLE. BE WARNED! Likewise, do NOT update your TI-Nspire CX past OS 4.5.0, else using Ndless and ASM/C programs will be impossible.

prgmMOVE and prgmARR: Teaching Myself to Move

Started by Woodrow, January 22, 2018, 05:25:11 pm

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.


Here, I used the location of the numbers of the calculator as arrows.


Input "", M
If M=4: Y-1->Y
If M=6: Y+1->Y
If M=8: X-1->X
If M=2: X+1->X
If M=5: Stop


While 5=5:prgmARR:End:DelVar M


Condense the code into one prgm

Use arrow keys instead of numbers if possible

Find a way to use the ClrHome command at the start of prgmMOVE

Add a boundary system
.emaG ehT esol won lliw uoy ,siht gnidaer rof tnemhsinup sA


I think what would help you here is the command getKey. It returns the last key pressed as a number based roughly on what row and column it's on on the keyboard (and 0 if nothing). For instance, the sin( key is in the 5th row and 2nd column, so you would check in this instance if getKey = 52. (In practice, you're almost always gonna want to store this to a variable and instead check that.)

The arrow keys are a bit more complicated. Up, left, and right are considered in the second row, and down is considered in the third row. So left is 24, up is 25, right is 26, and down is 34.

Also, any particular reason you have a While 5=5 loop?


Thanks! I'll keep that in mind and make a new program with the GetKey command.

While 5=5 is the way I usually write an infinite loop (5 is a visually satisfying number imo). Since the loop contains prgmARR, which has its own way of breaking out of the loop (If M=5:Stop), it's not really an infinite loop. It's just easier for me because error messages make me a bit nervous due to bad experience, so, even though I can break out with the On key either way, I prefer to just have my own ending function.

This is why I never try to justify my weird logic.
.emaG ehT esol won lliw uoy ,siht gnidaer rof tnemhsinup sA


Not that it makes a difference, but you can write "While 5=5" as just "While 5".
You'll save yourself a whole two bytes!


Powered by EzPortal