Hi
you can use a medium variable to manage input...
1.take the input: es. Keyboard =_keyhit....
2.store input coded in a variable: es. IF keyboard = 3 then Move = "Fly"
3. evaluate if input is changed es. IF OldMove = Move then...
4. take a memory of coded input: es. OldMove = Move
5. execute command IF Move = "Fly" then....
6. if you plan to make one move for one Keyboard's input here you must reset the variable of movement: es. Move = ""
as alternate movement feature you can leave the Move value until you get a new input from keyboard
here a my mod of your code
(I have left the label and the GOTO in the inner engine because I don't know if those options are exaustive or not, I prefer not to use GOTO and GOSUB if possible:-) )
Move$ = "" ' an extra layer between I/O function and Engine making moves
Move$ = "UP"
Move$ = "DOWN"
Move$ = "LEFTSHIFT"
' GOTO NEXTM <---- you don't need this and the correlate label
Move$ = "LEFT"
Move$ = "RIGHTSHIFT"
' GOTO NEXTM <---- you don't need this and the correlate label
Move$ = "RIGHT"
'engine of movement
Z% = SCREENMEM%(MJ% - 1, MI%)
IF Z%
= DIRT
THEN SCREENMEM%
(MJ%
, MI%
) = SPACE: SCREENMEM%
(MJ%
- 1, MI%
) = MAN: MJ%
= MJ%
- 1 IF Z%
= SPACE
THEN SCREENMEM%
(MJ%
, MI%
) = SPACE: SCREENMEM%
(MJ%
- 1, MI%
) = MAN: MJ%
= MJ%
- 1 IF Z%
= DIAMOND
THEN SCREENMEM%
(MJ%
, MI%
) = SPACE: SCREENMEM%
(MJ%
- 1, MI%
) = MAN: MJ%
= MJ%
- 1 'UP
Z% = SCREENMEM%(MJ% + 1, MI%)
IF Z%
= DIRT
THEN SCREENMEM%
(MJ%
, MI%
) = SPACE: SCREENMEM%
(MJ%
+ 1, MI%
) = MAN: MJ%
= MJ%
+ 1 IF Z%
= SPACE
THEN SCREENMEM%
(MJ%
, MI%
) = SPACE: SCREENMEM%
(MJ%
+ 1, MI%
) = MAN: MJ%
= MJ%
+ 1 IF Z%
= DIAMOND
THEN SCREENMEM%
(MJ%
, MI%
) = SPACE: SCREENMEM%
(MJ%
+ 1, MI%
) = MAN: MJ%
= MJ%
+ 1 'DOWN
Z1% = SCREENMEM%(MJ%, MI% - 1)
Z2% = SCREENMEM%(MJ%, MI% + 1)
IF Z1%
= DIRT
AND Z2%
= BOULDER
THEN SCREENMEM%
(MJ%
, MI%
- 1) = MAN: SCREENMEM%
(MJ%
, MI%
) = BOULDER: SCREENMEM%
(MJ%
, MI%
+ 1) = SPACE: MI%
= MI%
- 1:
GOTO NEXTM
IF Z1%
= SPACE
AND Z2%
= BOULDER
THEN SCREENMEM%
(MJ%
, MI%
- 1) = MAN: SCREENMEM%
(MJ%
, MI%
) = BOULDER: SCREENMEM%
(MJ%
, MI%
+ 1) = SPACE: MI%
= MI%
- 1:
GOTO NEXTM
IF Z1%
= SPACE
AND Z2%
= DIAMOND
THEN SCREENMEM%
(MJ%
, MI%
- 1) = MAN: SCREENMEM%
(MJ%
, MI%
) = DIAMOND: SCREENMEM%
(MJ%
, MI%
+ 1) = SPACE: MI%
= MI%
- 1:
GOTO NEXTM
'LEFT SHIFT
Z% = SCREENMEM%(MJ%, MI% - 1)
IF Z%
= DIRT
THEN SCREENMEM%
(MJ%
, MI%
) = SPACE: SCREENMEM%
(MJ%
, MI%
- 1) = MAN: MI%
= MI%
- 1 IF Z%
= SPACE
THEN SCREENMEM%
(MJ%
, MI%
) = SPACE: SCREENMEM%
(MJ%
, MI%
- 1) = MAN: MI%
= MI%
- 1: SCY1%
= SCY1%
- 1 IF Z%
= DIAMOND
THEN SCREENMEM%
(MJ%
, MI%
) = SPACE: SCREENMEM%
(MJ%
, MI%
- 1) = MAN: MI%
= MI%
- 1 IF Z%
= BOULDER
AND SCREENMEM%
(MJ%
, MI%
- 2) = SPACE
THEN SCREENMEM%
(MJ%
, MI%
- 2) = BOULDER: SCREENMEM%
(MJ%
, MI%
- 1) = MAN: SCREENMEM%
(MJ%
, MI%
) = SPACE: MI%
= MI%
- 1 'LEFT
Z1% = SCREENMEM%(MJ%, MI% + 1)
Z2% = SCREENMEM%(MJ%, MI% - 1)
IF Z1%
= DIRT
AND Z2%
= BOULDER
THEN SCREENMEM%
(MJ%
, MI%
+ 1) = MAN: SCREENMEM%
(MJ%
, MI%
) = BOULDER: SCREENMEM%
(MJ%
, MI%
- 1) = SPACE: MI%
= MI%
+ 1:
GOTO NEXTM
IF Z1%
= SPACE
AND Z2%
= BOULDER
THEN SCREENMEM%
(MJ%
, MI%
+ 1) = MAN: SCREENMEM%
(MJ%
, MI%
) = BOULDER: SCREENMEM%
(MJ%
, MI%
- 1) = SPACE: MI%
= MI%
+ 1:
GOTO NEXTM
IF Z1%
= SPACE
AND Z2%
= DIAMOND
THEN SCREENMEM%
(MJ%
, MI%
+ 1) = MAN: SCREENMEM%
(MJ%
, MI%
) = DIAMOND: SCREENMEM%
(MJ%
, MI%
- 1) = SPACE: MI%
= MI%
+ 1:
GOTO NEXTM
'RIGHT SHIFT
Z% = SCREENMEM%(MJ%, MI% + 1)
IF Z%
= DIRT
THEN SCREENMEM%
(MJ%
, MI%
) = SPACE: SCREENMEM%
(MJ%
, MI%
+ 1) = MAN: MI%
= MI%
+ 1 IF Z%
= SPACE
THEN SCREENMEM%
(MJ%
, MI%
) = SPACE: SCREENMEM%
(MJ%
, MI%
+ 1) = MAN: MI%
= MI%
+ 1 IF Z%
= DIAMOND
THEN SCREENMEM%
(MJ%
, MI%
) = SPACE: SCREENMEM%
(MJ%
, MI%
+ 1) = MAN: MI%
= MI%
+ 1 IF Z%
= BOULDER
AND SCREENMEM%
(MJ%
, MI%
+ 2) = SPACE
THEN SCREENMEM%
(MJ%
, MI%
+ 2) = BOULDER: SCREENMEM%
(MJ%
, MI%
+ 1) = MAN: SCREENMEM%
(MJ%
, MI%
) = SPACE: MI%
= MI%
+ 1 'RIGHT
NEXTM: ' This label is used also in RightShift and LeftShift commands...
'but if the three conditions are the only to manage
'you can nest also this 3 IF THEN in the chain of IF THEN
'and avoid the label
Thanks to read