Create a program that can read the keys you press on the keyboard. It will be useful for moving the Knight through the dungeon.
Thanks to the keyboard assignment block your program can read the keys you press. Place the blocks as follows:
Start the program at the BEGIN block and drag the 'k' variable into the keyboard assignment block.
As an example, press the 'right arrow' key. This key has the number '6', so the value '6' is assigned to the 'k' variable:"Assigning the value '6' to the variable 'k' "
Drag the 'k' variable into the condition block:
-If 'k' is different from '27' continue in the loop as indicated by the direction arrows ,
-Otherwise 'k' equals '27' and the program ends.
Once in the code block, call the 'print' function, passing the 'k' variable as an argument such as print( k ). Write the value of the 'k' variable on your whiteboard.
"Calling the print function".
Once the value of 'k' has been "printed" thanks to the 'print' function, follow the direction arrows until entering the keyboard assignment block again. There, wait until the player presses a key to reassign a new value to the 'k' variable.
The loop breaks when the player presses the ESC ("Escape") key (k=27), at which point the condition 'k != 27' is no longer met and the program exits.