Last active
February 24, 2019 02:07
-
-
Save colinjfw/e9be8be25ca5f30095a4cd02efeae3c4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function moveAsCoord(move, head) { | |
switch (move) { | |
case 'up': | |
return {x: head.x, y: head.y-1}; | |
case 'down': | |
return {x: head.x, y: head.y+1}; | |
case 'left': | |
return {x: head.x-1, y: head.y}; | |
case 'right': | |
return {x: head.x+1, y: head.y}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment