MCPcopy Create free account
hub / github.com/Vishal-raj-1/Awesome-JavaScript-Projects / direction

Function direction

assets/js/snake.js:64–78  ·  view source on GitHub ↗
(event)

Source from the content-addressed store, hash-verified

62document.addEventListener("keydown",direction);
63
64function direction(event){
65 if(event.keyCode==37&&d!="RIGHT"){
66 left.play();
67 d="LEFT";
68 }else if(event.keyCode==38&&d!="DOWN"){
69 up.play();
70 d="UP";
71 }else if(event.keyCode==39&&d!="LEFT"){
72 right.play();
73 d="RIGHT";
74 }else if(event.keyCode==40&&d!="UP"){
75 down.play();
76 d="DOWN";
77 }
78}
79
80//check collision function
81function collision(head,array){

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected