Move the ship (Space Shooter)
A space shooter is a loop: every tick, read a key and update the world. SIZE <width <height (default 9 × 8) sets the field; KEYS lines hold the keys, one per tick, separated by spaces: L (left), R (right), F (fire, nothing yet), . (wait). The ship starts in the middle column (width ÷ 2, rounded down) of the bottom row and cannot leave the field. After the last key print the field (. empty, A the ship), then player at <x.
Input: SIZE and KEYS lines.
Output: The field and the position.
Difficulty: Easy. Write your answer in the browser editor, run the examples, then submit it against hidden tests. Python and JavaScript are free; other languages are part of licode Club.
Hint
- Clamp x between 0 and width − 1.