Recall that commands for the robot arm are as follows:
N move in a straight line one unit toward the top of the paper ("North")
S move one unit toward the bottom ("South")
E move one unit to the right ("East")
W move one unit to the left ("West")
U lift pen from paper ("Up", stop writing)
D lower pen to paper ("Down", start writing with next move)
H lift pen and move to top left corner ("Home")
The code below, with the missing sections filled in correctly, has been tested using Google Chrome and Internet Explorer 10.x. It will work in Chrome, but not in IE 10, because IE 10 does not support the HTML canvas tag. The code has not been checked in IE 11, the most recent version.
After downloading this file from Moodle, you should first change the extension from .txt to .html so it will open as a web page in your web browser. Each of the missing sections of code you must fill in to get the robot arm simulation to work are signified by the placeholder "@@@". Note, the length of the missing sectins varies, and bears no relation to the length of the placeholder.
The extension for this file has already been changed to htm and the correct code for each of the placeholders inserted in accordance with the instructions above. To view the original lines with the placeholders, now commented out, and additional comments on how to input instructions and use the other interactive features, look at the source for this page.
Input robot drawing arm instructions:
Input delta x:
Input delta y: