May 24, 2019, 05:56:10 pm

## News:

Juju thinks he's so clever by putting funny stuff here

### Recent Topics

 [Superstar Hero (PC)] Superstar Hero - a Ys-like JRPG set in the Quebec future of 9108 by DJ Omnimaga Today at 05:42:52 pm [PC, Mac & Vintage Computers] Another Pi Language by Juju Today at 03:38:55 am [Site Discussion & Bug Reports] Temporary shoutbox installed by DJ Omnimaga May 20, 2019, 05:46:27 pm [Site Discussion & Bug Reports] General site updates, TODO list and discussion by DJ Omnimaga May 19, 2019, 05:24:30 pm [Calculator News, Coding, Help & Talk] Sudoku Random Level Generator by semiprocoder May 09, 2019, 05:49:57 pm [Web] Worldwide Combos by noelnadal May 03, 2019, 08:46:38 am [MTVMG/Music 2000 series talk & showcase] Superstar Hero - The Original Soundtrack is now released by DJ Omnimaga May 02, 2019, 07:49:59 pm [Tech, Science, IT discussion & News] Old Android devices by DJ Omnimaga May 01, 2019, 07:51:40 pm [Gaming] My predictions about the Nintendo Switch 2 years after... by DJ Omnimaga April 29, 2019, 05:51:29 pm [Other] (politics) WikiLeak's current situation by gameblabla April 28, 2019, 11:50:10 pm

## prgmMOVE and prgmARR: Teaching Myself to Move

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

0 Members and 1 Guest are viewing this topic.

#### Woodrow

##### January 22, 2018, 05:25:11 pm
Here, I used the location of the numbers of the calculator as arrows.

prgmARR:

7->M
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
ClrHome
Output(X,Y,"O

prgmMOVE:

1->X
1->Y
Output(X,Y,"O
While 5=5:prgmARR:End:DelVar M

Goals:

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

#### JWinslow23

##### January 22, 2018, 06:39:07 pm #1
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?

#### Woodrow

##### January 22, 2018, 09:38:39 pm #2
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

#### mazhat

##### January 22, 2018, 09:51:37 pm #3
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!

Sketti

#### JWinslow23

##### January 23, 2018, 02:46:10 pm #4
Quote from: mazhat on January 22, 2018, 09:51:37 pm
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!

While 1, even!