{"id":874,"date":"2019-03-28T18:45:25","date_gmt":"2019-03-28T18:45:25","guid":{"rendered":"https:\/\/webdevtrick.com\/?p=874"},"modified":"2019-03-28T18:47:48","modified_gmt":"2019-03-28T18:47:48","slug":"javascript-snake-game-source-code","status":"publish","type":"post","link":"https:\/\/webdevtrick.com\/javascript-snake-game-source-code\/","title":{"rendered":"JavaScript Snake Game | Simple JavaScript Game Source Code"},"content":{"rendered":"<p><strong>Simple JavaScript Game with Source Code:<\/strong>\u00a0<span lang=\"en\" tabindex=\"0\">You have no idea what you can do with javascript. JavaScript is one of the most demanding programming languages right now, there are so many <span><a href=\"https:\/\/en.wikipedia.org\/wiki\/List_of_JavaScript_libraries\" target=\"_blank\" rel=\"noopener noreferrer\">libraries<\/a><\/span> of JavaScript. So, There is a snake game <span><a href=\"https:\/\/webdevtrick.com\/create-javascript-quiz-program\/\" target=\"_blank\" rel=\"noopener noreferrer\">built with JavaScript<\/a><\/span>, HTML &amp; CSS little bit. This is a very basic program. This snake game is like the legend game came with a Nokia Keypad phones.\u00a0<\/span><\/p>\n<p>You can call this a coding game or game with coding. In other words, this is javascript coding game. When I was learning <span><a href=\"https:\/\/webdevtrick.com\/web-development\/\" target=\"_blank\" rel=\"noopener noreferrer\">web development<\/a><\/span>, always I asked my instructor how can I create games in javascript. Now I am able to create very small programs in javascript. I am still learning, &amp; And as much as I know, I share with you all. Because I believe sharing knowledge is the best way to increase knowledge.<\/p>\n<p>Let&#8217;s come to our topic, How to make a basic snake game in javascript? The answer is in the form of source code. First, you must have good knowledge of HTML canvas, <span><a href=\"https:\/\/webdevtrick.com\/css-animated-login-from\/\" target=\"_blank\" rel=\"noopener noreferrer\">CSS<\/a><\/span> &amp; Javascript. Then you can understand this program easily.<\/p>\n<p><span style=\"font-size: 14pt;\">You May Also Like:<\/span><\/p>\n<p><span><a title=\"Registration Form with Validation Example and Source Code\" href=\"https:\/\/webdevtrick.com\/registration-form-with-validation\/\" rel=\"bookmark\">Registration Form with Validation Example and Source Code<\/a><\/span><\/p>\n<p class=\"entry-title td-module-title\"><span><a title=\"Basic JavaScript Calculator Source Code | HTML, CSS\" href=\"https:\/\/webdevtrick.com\/basic-javascript-calculator-source-code\/\" rel=\"bookmark\">Basic JavaScript Calculator Source Code | HTML, CSS<\/a><\/span><\/p>\n<h2>Requirement For Create Snake Game<\/h2>\n<ul>\n<li>Knowledge of HTML.<\/li>\n<li>Basic Knowledge Of CSS.<\/li>\n<li>Good knowledge of JavaScript.<\/li>\n<li>An IDE or notepad++<\/li>\n<\/ul>\n<p><em>Note:<\/em> If you don&#8217;t have knowledge in javascript, Then first learn.\u00a0 If you are learning javascript or want to learn, this demo also will be useful for you for the understanding the whole program.<\/p>\n<h4>Preview:<\/h4>\n<p>Let&#8217;s see a review of this game in GIF format.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-876\" src=\"https:\/\/webdevtrick.com\/wp-content\/uploads\/javascript-snakegame-code.gif\" alt=\"javascript snake game code\" width=\"543\" height=\"554\" \/><\/p>\n<h3>JavaScript Snake Game Source Code<\/h3>\n<p>I have created just one file for this program because this program is small in length and size. I used little bit CSS, that&#8217;s why I put CSS in between <em>&lt;head&gt;<\/em> tag. Create an HTML file named &#8220;snakegame.html&#8221; or any name you want. Copy codes form here below and paste on HTML file.<\/p>\n<pre class=\"lang:xhtml decode:true \" title=\"snakegame.html\">&lt;!doctype html&gt;\r\n&lt;!--Code By WebDevTrick (https:\/\/webdevtrick.com)--&gt;\r\n&lt;html lang=\"en\"&gt;\r\n&lt;head&gt;\r\n\t&lt;meta charset=\"UTF-8\"&gt;\r\n\t&lt;title&gt;Simple JavaScript Snake Game| Webdevtrick.com&lt;\/title&gt;\r\n\t\r\n\t&lt;style&gt;\r\n\tcanvas {\r\n\t\tdisplay: block;\r\n\t\tposition: absolute;\r\n\t\tborder: 5px solid  #009BFF;\r\n\t\tmargin: auto;\r\n\t\ttop: 0;\r\n\t\tbottom: 0;\r\n\t\tright: 0;\r\n\t\tleft: 0;\r\n\t}\r\n\t&lt;\/style&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n&lt;script&gt;\r\nvar\r\nCOLS = 26,\r\nROWS = 26,\r\nEMPTY = 0,\r\nSNAKE = 1,\r\nFRUIT = 2,\r\nLEFT  = 0,\r\nUP    = 1,\r\nRIGHT = 2,\r\nDOWN  = 3,\r\nKEY_LEFT  = 37,\r\nKEY_UP    = 38,\r\nKEY_RIGHT = 39,\r\nKEY_DOWN  = 40,\r\ncanvas,\t  \r\nctx,\t  \r\nkeystate, \r\nframes,   \r\nscore;\t  \r\n\r\ngrid = {\r\n\r\n\twidth: null,  \r\n\theight: null, \r\n\t_grid: null,  \r\n\r\n\t\r\n\tinit: function(d, c, r) {\r\n\t\tthis.width = c;\r\n\t\tthis.height = r;\r\n\r\n\t\tthis._grid = [];\r\n\t\tfor (var x=0; x &lt; c; x++) {\r\n\t\t\tthis._grid.push([]);\r\n\t\t\tfor (var y=0; y &lt; r; y++) {\r\n\t\t\t\tthis._grid[x].push(d);\r\n\t\t\t}\r\n\t\t}\r\n\t},\r\n\r\n\t\r\n\tset: function(val, x, y) {\r\n\t\tthis._grid[x][y] = val;\r\n\t},\r\n\r\n\t\r\n\tget: function(x, y) {\r\n\t\treturn this._grid[x][y];\r\n\t}\r\n}\r\n\r\n\r\nsnake = {\r\n\r\n\tdirection: null, \r\n\tlast: null,\t\t \r\n\t_queue: null,\t\r\n\r\n\t\r\n\tinit: function(d, x, y) {\r\n\t\tthis.direction = d;\r\n\r\n\t\tthis._queue = [];\r\n\t\tthis.insert(x, y);\r\n\t},\r\n\r\n\t\r\n\tinsert: function(x, y) {\r\n\t\t\r\n\t\tthis._queue.unshift({x:x, y:y});\r\n\t\tthis.last = this._queue[0];\r\n\t},\r\n\r\n\t\r\n\tremove: function() {\r\n\t\t\r\n\t\treturn this._queue.pop();\r\n\t}\r\n};\r\n\r\n\r\nfunction setFood() {\r\n\tvar empty = [];\r\n\t\r\n\tfor (var x=0; x &lt; grid.width; x++) {\r\n\t\tfor (var y=0; y &lt; grid.height; y++) {\r\n\t\t\tif (grid.get(x, y) === EMPTY) {\r\n\t\t\t\tempty.push({x:x, y:y});\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\t\r\n\tvar randpos = empty[Math.round(Math.random()*(empty.length - 1))];\r\n\tgrid.set(FRUIT, randpos.x, randpos.y);\r\n}\r\n\r\n\r\nfunction main() {\r\n\t\r\n\tcanvas = document.createElement(\"canvas\");\r\n\tcanvas.width = COLS*20;\r\n\tcanvas.height = ROWS*20;\r\n\tctx = canvas.getContext(\"2d\");\r\n\t\r\n\tdocument.body.appendChild(canvas);\r\n\r\n\t\r\n\tctx.font = \"12px Helvetica\";\r\n\r\n\tframes = 0;\r\n\tkeystate = {};\r\n\t\r\n\tdocument.addEventListener(\"keydown\", function(evt) {\r\n\t\tkeystate[evt.keyCode] = true;\r\n\t});\r\n\tdocument.addEventListener(\"keyup\", function(evt) {\r\n\t\tdelete keystate[evt.keyCode];\r\n\t});\r\n\r\n\t\r\n\tinit();\r\n\tloop();\r\n}\r\n\r\n\r\nfunction init() {\r\n\tscore = 0;\r\n\r\n\tgrid.init(EMPTY, COLS, ROWS);\r\n\r\n\tvar sp = {x:Math.floor(COLS\/2), y:ROWS-1};\r\n\tsnake.init(UP, sp.x, sp.y);\r\n\tgrid.set(SNAKE, sp.x, sp.y);\r\n\r\n\tsetFood();\r\n}\r\n\r\n\r\nfunction loop() {\r\n\tupdate();\r\n\tdraw();\r\n\t\r\n\twindow.requestAnimationFrame(loop, canvas);\r\n}\r\n\r\n\r\nfunction update() {\r\n\tframes++;\r\n\r\n\t\r\n\tif (keystate[KEY_LEFT] &amp;&amp; snake.direction !== RIGHT) {\r\n\t\tsnake.direction = LEFT;\r\n\t}\r\n\tif (keystate[KEY_UP] &amp;&amp; snake.direction !== DOWN) {\r\n\t\tsnake.direction = UP;\r\n\t}\r\n\tif (keystate[KEY_RIGHT] &amp;&amp; snake.direction !== LEFT) {\r\n\t\tsnake.direction = RIGHT;\r\n\t}\r\n\tif (keystate[KEY_DOWN] &amp;&amp; snake.direction !== UP) {\r\n\t\tsnake.direction = DOWN;\r\n\t}\r\n\r\n\t\r\n\tif (frames%7 === 0) {\r\n\t\t\r\n\t\tvar nx = snake.last.x;\r\n\t\tvar ny = snake.last.y;\r\n\r\n\t\t\r\n\t\tswitch (snake.direction) {\r\n\t\t\tcase LEFT:\r\n\t\t\t\tnx--;\r\n\t\t\t\tbreak;\r\n\t\t\tcase UP:\r\n\t\t\t\tny--;\r\n\t\t\t\tbreak;\r\n\t\t\tcase RIGHT:\r\n\t\t\t\tnx++;\r\n\t\t\t\tbreak;\r\n\t\t\tcase DOWN:\r\n\t\t\t\tny++;\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\t\r\n\t\tif (0 &gt; nx || nx &gt; grid.width-1  ||\r\n\t\t\t0 &gt; ny || ny &gt; grid.height-1 ||\r\n\t\t\tgrid.get(nx, ny) === SNAKE\r\n\t\t) {\r\n\t\t\treturn init();\r\n\t\t}\r\n\r\n\t\tif (grid.get(nx, ny) === FRUIT) {\r\n\t\t\t\r\n\t\t\tscore++;\r\n\t\t\tsetFood();\r\n\t\t} else {\r\n\t\t\t\r\n\t\t\tvar tail = snake.remove();\r\n\t\t\tgrid.set(EMPTY, tail.x, tail.y);\r\n\t\t}\r\n\r\n\t\tgrid.set(SNAKE, nx, ny);\r\n\t\tsnake.insert(nx, ny);\r\n\t}\r\n}\r\n\r\n\r\nfunction draw() {\r\n\t\r\n\tvar tw = canvas.width\/grid.width;\r\n\tvar th = canvas.height\/grid.height;\r\n\t\r\n\tfor (var x=0; x &lt; grid.width; x++) {\r\n\t\tfor (var y=0; y &lt; grid.height; y++) {\r\n\t\t\t\r\n\t\t\tswitch (grid.get(x, y)) {\r\n\t\t\t\tcase EMPTY:\r\n\t\t\t\t\tctx.fillStyle = \"#fff\";\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase SNAKE:\r\n\t\t\t\t\tctx.fillStyle = \"#333\";\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase FRUIT:\r\n\t\t\t\t\tctx.fillStyle = \"#009BFF\";\r\n\t\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t\tctx.fillRect(x*tw, y*th, tw, th);\r\n\t\t}\r\n\t}\r\n\t\r\n\tctx.fillStyle = \"#000\";\r\n\tctx.fillText(\"SCORE: \" + score, 10, canvas.height-10);\r\n}\r\n\r\n\r\nmain();\r\n&lt;\/script&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<p>That&#8217;s it. You have successfully created a snake game. If you have any doubt comment down below.<br \/>\n<span style=\"font-family: impact, sans-serif;\">Thanks For Visiting, Keep Visiting.<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Simple JavaScript Game with Source Code:\u00a0You have no idea what you can do with javascript. JavaScript is one of the most demanding programming languages right now, there are so many libraries of JavaScript. So, There is a snake game built with JavaScript, HTML &amp; CSS little bit. This is a very basic program. This snake [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":875,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[42,46,22,41],"tags":[131,130,61,60,132],"class_list":["post-874","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-html","category-javascript","category-web-design","category-web-development","tag-game-in-javascript","tag-javascript-snake-game","tag-javascript-tips-and-tricks","tag-javascript-tutorial","tag-snake-game"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.9 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>JavaScript Snake Game | Simple JavaScript Game Source Code<\/title>\n<meta name=\"description\" content=\"How to make a basic snake game in javascript? The answer is in the form of source code.Source code of snake javascript game.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/webdevtrick.com\/javascript-snake-game-source-code\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"JavaScript Snake Game | Simple JavaScript Game Source Code\" \/>\n<meta property=\"og:description\" content=\"How to make a basic snake game in javascript? The answer is in the form of source code.Source code of snake javascript game.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webdevtrick.com\/javascript-snake-game-source-code\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Dev Trick\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webdevtrick\/\" \/>\n<meta property=\"article:published_time\" content=\"2019-03-28T18:45:25+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-03-28T18:47:48+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/webdevtrick.com\/wp-content\/uploads\/javascript-snake-game-source-code.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"629\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"shaan\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"shaan\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/webdevtrick.com\/javascript-snake-game-source-code\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/webdevtrick.com\/javascript-snake-game-source-code\/\"},\"author\":{\"name\":\"shaan\",\"@id\":\"https:\/\/webdevtrick.com\/#\/schema\/person\/c79bae83976f92fe305c22342b2a0be3\"},\"headline\":\"JavaScript Snake Game | Simple JavaScript Game Source Code\",\"datePublished\":\"2019-03-28T18:45:25+00:00\",\"dateModified\":\"2019-03-28T18:47:48+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/webdevtrick.com\/javascript-snake-game-source-code\/\"},\"wordCount\":366,\"commentCount\":12,\"publisher\":{\"@id\":\"https:\/\/webdevtrick.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/webdevtrick.com\/javascript-snake-game-source-code\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/webdevtrick.com\/wp-content\/uploads\/javascript-snake-game-source-code.jpg\",\"keywords\":[\"game in javascript\",\"javascript snake game\",\"javascript tips and tricks\",\"javascript tutorial\",\"snake game\"],\"articleSection\":[\"HTML\",\"JavaScript\",\"Web Design\",\"Web Development\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/webdevtrick.com\/javascript-snake-game-source-code\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/webdevtrick.com\/javascript-snake-game-source-code\/\",\"url\":\"https:\/\/webdevtrick.com\/javascript-snake-game-source-code\/\",\"name\":\"JavaScript Snake Game | Simple JavaScript Game Source Code\",\"isPartOf\":{\"@id\":\"https:\/\/webdevtrick.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/webdevtrick.com\/javascript-snake-game-source-code\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/webdevtrick.com\/javascript-snake-game-source-code\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/webdevtrick.com\/wp-content\/uploads\/javascript-snake-game-source-code.jpg\",\"datePublished\":\"2019-03-28T18:45:25+00:00\",\"dateModified\":\"2019-03-28T18:47:48+00:00\",\"description\":\"How to make a basic snake game in javascript? The answer is in the form of source code.Source code of snake javascript game.\",\"breadcrumb\":{\"@id\":\"https:\/\/webdevtrick.com\/javascript-snake-game-source-code\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webdevtrick.com\/javascript-snake-game-source-code\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webdevtrick.com\/javascript-snake-game-source-code\/#primaryimage\",\"url\":\"https:\/\/webdevtrick.com\/wp-content\/uploads\/javascript-snake-game-source-code.jpg\",\"contentUrl\":\"https:\/\/webdevtrick.com\/wp-content\/uploads\/javascript-snake-game-source-code.jpg\",\"width\":1200,\"height\":629,\"caption\":\"javascript snake game source code\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webdevtrick.com\/javascript-snake-game-source-code\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webdevtrick.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"JavaScript Snake Game | Simple JavaScript Game Source Code\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/webdevtrick.com\/#website\",\"url\":\"https:\/\/webdevtrick.com\/\",\"name\":\"Web Dev Trick\",\"description\":\"HTML5, CSS3, JS, PHP Source Code &amp; Tutorial\",\"publisher\":{\"@id\":\"https:\/\/webdevtrick.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/webdevtrick.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/webdevtrick.com\/#organization\",\"name\":\"Web Dev Trick\",\"url\":\"https:\/\/webdevtrick.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webdevtrick.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/webdevtrick.com\/wp-content\/uploads\/logo-fb-1.png\",\"contentUrl\":\"https:\/\/webdevtrick.com\/wp-content\/uploads\/logo-fb-1.png\",\"width\":512,\"height\":512,\"caption\":\"Web Dev Trick\"},\"image\":{\"@id\":\"https:\/\/webdevtrick.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webdevtrick\/\",\"https:\/\/pinterest.com\/webdevtrick\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/webdevtrick.com\/#\/schema\/person\/c79bae83976f92fe305c22342b2a0be3\",\"name\":\"shaan\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webdevtrick.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/60aa6ee93605bda7bc598d11dd748709a69bdb55a080124cc382114d8d7e7665?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/60aa6ee93605bda7bc598d11dd748709a69bdb55a080124cc382114d8d7e7665?s=96&d=mm&r=g\",\"caption\":\"shaan\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"JavaScript Snake Game | Simple JavaScript Game Source Code","description":"How to make a basic snake game in javascript? The answer is in the form of source code.Source code of snake javascript game.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/webdevtrick.com\/javascript-snake-game-source-code\/","og_locale":"en_US","og_type":"article","og_title":"JavaScript Snake Game | Simple JavaScript Game Source Code","og_description":"How to make a basic snake game in javascript? The answer is in the form of source code.Source code of snake javascript game.","og_url":"https:\/\/webdevtrick.com\/javascript-snake-game-source-code\/","og_site_name":"Web Dev Trick","article_publisher":"https:\/\/www.facebook.com\/webdevtrick\/","article_published_time":"2019-03-28T18:45:25+00:00","article_modified_time":"2019-03-28T18:47:48+00:00","og_image":[{"width":1200,"height":629,"url":"https:\/\/webdevtrick.com\/wp-content\/uploads\/javascript-snake-game-source-code.jpg","type":"image\/jpeg"}],"author":"shaan","twitter_card":"summary_large_image","twitter_misc":{"Written by":"shaan","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/webdevtrick.com\/javascript-snake-game-source-code\/#article","isPartOf":{"@id":"https:\/\/webdevtrick.com\/javascript-snake-game-source-code\/"},"author":{"name":"shaan","@id":"https:\/\/webdevtrick.com\/#\/schema\/person\/c79bae83976f92fe305c22342b2a0be3"},"headline":"JavaScript Snake Game | Simple JavaScript Game Source Code","datePublished":"2019-03-28T18:45:25+00:00","dateModified":"2019-03-28T18:47:48+00:00","mainEntityOfPage":{"@id":"https:\/\/webdevtrick.com\/javascript-snake-game-source-code\/"},"wordCount":366,"commentCount":12,"publisher":{"@id":"https:\/\/webdevtrick.com\/#organization"},"image":{"@id":"https:\/\/webdevtrick.com\/javascript-snake-game-source-code\/#primaryimage"},"thumbnailUrl":"https:\/\/webdevtrick.com\/wp-content\/uploads\/javascript-snake-game-source-code.jpg","keywords":["game in javascript","javascript snake game","javascript tips and tricks","javascript tutorial","snake game"],"articleSection":["HTML","JavaScript","Web Design","Web Development"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/webdevtrick.com\/javascript-snake-game-source-code\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/webdevtrick.com\/javascript-snake-game-source-code\/","url":"https:\/\/webdevtrick.com\/javascript-snake-game-source-code\/","name":"JavaScript Snake Game | Simple JavaScript Game Source Code","isPartOf":{"@id":"https:\/\/webdevtrick.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/webdevtrick.com\/javascript-snake-game-source-code\/#primaryimage"},"image":{"@id":"https:\/\/webdevtrick.com\/javascript-snake-game-source-code\/#primaryimage"},"thumbnailUrl":"https:\/\/webdevtrick.com\/wp-content\/uploads\/javascript-snake-game-source-code.jpg","datePublished":"2019-03-28T18:45:25+00:00","dateModified":"2019-03-28T18:47:48+00:00","description":"How to make a basic snake game in javascript? The answer is in the form of source code.Source code of snake javascript game.","breadcrumb":{"@id":"https:\/\/webdevtrick.com\/javascript-snake-game-source-code\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webdevtrick.com\/javascript-snake-game-source-code\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webdevtrick.com\/javascript-snake-game-source-code\/#primaryimage","url":"https:\/\/webdevtrick.com\/wp-content\/uploads\/javascript-snake-game-source-code.jpg","contentUrl":"https:\/\/webdevtrick.com\/wp-content\/uploads\/javascript-snake-game-source-code.jpg","width":1200,"height":629,"caption":"javascript snake game source code"},{"@type":"BreadcrumbList","@id":"https:\/\/webdevtrick.com\/javascript-snake-game-source-code\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webdevtrick.com\/"},{"@type":"ListItem","position":2,"name":"JavaScript Snake Game | Simple JavaScript Game Source Code"}]},{"@type":"WebSite","@id":"https:\/\/webdevtrick.com\/#website","url":"https:\/\/webdevtrick.com\/","name":"Web Dev Trick","description":"HTML5, CSS3, JS, PHP Source Code &amp; Tutorial","publisher":{"@id":"https:\/\/webdevtrick.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/webdevtrick.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/webdevtrick.com\/#organization","name":"Web Dev Trick","url":"https:\/\/webdevtrick.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webdevtrick.com\/#\/schema\/logo\/image\/","url":"https:\/\/webdevtrick.com\/wp-content\/uploads\/logo-fb-1.png","contentUrl":"https:\/\/webdevtrick.com\/wp-content\/uploads\/logo-fb-1.png","width":512,"height":512,"caption":"Web Dev Trick"},"image":{"@id":"https:\/\/webdevtrick.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webdevtrick\/","https:\/\/pinterest.com\/webdevtrick\/"]},{"@type":"Person","@id":"https:\/\/webdevtrick.com\/#\/schema\/person\/c79bae83976f92fe305c22342b2a0be3","name":"shaan","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webdevtrick.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/60aa6ee93605bda7bc598d11dd748709a69bdb55a080124cc382114d8d7e7665?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/60aa6ee93605bda7bc598d11dd748709a69bdb55a080124cc382114d8d7e7665?s=96&d=mm&r=g","caption":"shaan"}}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/webdevtrick.com\/wp-json\/wp\/v2\/posts\/874","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webdevtrick.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webdevtrick.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webdevtrick.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/webdevtrick.com\/wp-json\/wp\/v2\/comments?post=874"}],"version-history":[{"count":0,"href":"https:\/\/webdevtrick.com\/wp-json\/wp\/v2\/posts\/874\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/webdevtrick.com\/wp-json\/wp\/v2\/media\/875"}],"wp:attachment":[{"href":"https:\/\/webdevtrick.com\/wp-json\/wp\/v2\/media?parent=874"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webdevtrick.com\/wp-json\/wp\/v2\/categories?post=874"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webdevtrick.com\/wp-json\/wp\/v2\/tags?post=874"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}