|
Robot
Move a little robot.
|
Script for interacting with the robot grid. More...
Functions | |
| function async | onKeyDown (event) |
| Handle keydown events for moving robot. More... | |
| document | addEventListener ("keydown", onKeyDown) |
| function async | onClick (event) |
| Handle click events (on grid or buttons). More... | |
| function | readCookies () |
| Reads cookies of document. More... | |
| function | generateGrid (x_coord, y_coord, x_max=5, y_max=5) |
| Generate grid given robot's coordinate and size of grid. More... | |
| function | updateCoords (x_coord, y_coord) |
| Updates coordinates written on top of page. More... | |
| function | replaceGrid () |
| Replace grid by newly generated one (with new robot's coordinates). More... | |
Variables | |
| const | robot_grid = document.getElementById("robot-grid") |
| const | up_button = document.getElementById("up") |
| const | down_button = document.getElementById("down") |
| const | right_button = document.getElementById("right") |
| const | left_button = document.getElementById("left") |
| const | reset_button = document.getElementById("reset") |
Script for interacting with the robot grid.
| reset_button addEventListener | ( | "keydown" | , |
| onKeyDown | |||
| ) |
| function generateGrid | ( | x_coord, | |
| y_coord, | |||
x_max = 5, |
|||
y_max = 5 |
|||
| ) |
Generate grid given robot's coordinate and size of grid.
| {int} | x_coord Robot's x coordinate. |
| {int} | y_coord Robot's y coordinate. |
| {int} | x_max Value max for x (so number of lines in the grid - 1). |
| {int} | y_max Value max for y (so number of columns in the grid - 1). |
| function async onClick | ( | event | ) |
Handle click events (on grid or buttons).
| {MouseEvent} | event - The click event. |
| function async onKeyDown | ( | event | ) |
Handle keydown events for moving robot.
| {KeyboardEvent} | event - The keydown event. |
| function readCookies | ( | ) |
Reads cookies of document.
| function replaceGrid | ( | ) |
Replace grid by newly generated one (with new robot's coordinates).
| function updateCoords | ( | x_coord, | |
| y_coord | |||
| ) |
Updates coordinates written on top of page.
| {int} | x_coord Robot's x coordinate. |
| {int} | y_coord Robot's y coordinate. |
| const down_button = document.getElementById("down") |
| const left_button = document.getElementById("left") |
| const reset_button = document.getElementById("reset") |
| const right_button = document.getElementById("right") |
| const robot_grid = document.getElementById("robot-grid") |
| const up_button = document.getElementById("up") |