{"id":26154383,"url":"https://github.com/rcdmk/js-snake","last_synced_at":"2026-05-26T13:36:04.806Z","repository":{"id":142080751,"uuid":"260805824","full_name":"rcdmk/js-snake","owner":"rcdmk","description":"Simple snake game written in JavaScript with modules support","archived":false,"fork":false,"pushed_at":"2025-01-03T04:52:33.000Z","size":25,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-03T05:28:31.581Z","etag":null,"topics":["game-dev","javascript","snake-game"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rcdmk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-05-03T01:18:47.000Z","updated_at":"2025-01-03T04:52:36.000Z","dependencies_parsed_at":"2023-07-22T16:15:13.299Z","dependency_job_id":null,"html_url":"https://github.com/rcdmk/js-snake","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rcdmk%2Fjs-snake","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rcdmk%2Fjs-snake/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rcdmk%2Fjs-snake/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rcdmk%2Fjs-snake/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rcdmk","download_url":"https://codeload.github.com/rcdmk/js-snake/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242999808,"owners_count":20219567,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["game-dev","javascript","snake-game"],"created_at":"2025-03-11T08:29:26.609Z","updated_at":"2026-05-26T13:36:04.775Z","avatar_url":"https://github.com/rcdmk.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# js-snake\n\nThis is a simple snake game implementation in JavaScript using the modules format, including all basic features:\n\n- [x] simple navigation with ARROW keys (UP, DOWN, LEFT and RIGHT)\n- [x] avoid moving out of bounds\n- [x] random food placement\n- [x] food pickup\n- [x] growing when eating food\n- [x] scoring when eating food\n- [x] pause and unpause game with SPACE\n- [x] dying when touching own body\n- [x] dying when touching borders\n- [x] game over when dead, pauses game\n- [x] unpausing after game over resets the game\n- [x] high-score keeps track of highest score between games\n- [x] reversing direction if pressing opposite direction\n\n## Reversing the direction\n\nThe direction reversion logic reverses the snake direction based on the tail direction, turning the tail into the new head. For instance, if the body of the snake is performing a U shaped moviment going up and \u003ckbd\u003eDOWN\u003c/kbd\u003e is pressed, the tail will become the head and the snake will start going up from the other end.\n\nAnother example is when the snake body is performing an L shape move, going up after going left, and \u003ckbd\u003eDOWN\u003c/kbd\u003e is pressed. In that case, the snake will go right because the tail was going left and it is now the head and the direction was reversed.\n\n## Dependencies\n\nTo allow browsers to run modules locally, a static server is needed to avoid CORS rules from blocking the module imports.\n\nFor first time only, navigate to the root of the project and install the dependencies:\n\n```sh\nnpm install\n# OR\nyarn install\n```\n\n## Running\n\nTo execute the included static server, run:\n\n```sh\nnpm start\n# OR\nyarn start\n```\n\nThen open `http://localhost:5000` in your browser.\n\n## Controls\n\n| Action                  | Keys                                                                |\n|-------------------------|---------------------------------------------------------------------|\n| Starting                | \u003ckbd\u003eUP\u003c/kbd\u003e, \u003ckbd\u003eDOWN\u003c/kbd\u003e, \u003ckbd\u003eLEFT\u003c/kbd\u003e or \u003ckbd\u003eRIGHT\u003c/kbd\u003e |\n| Moving                  | \u003ckbd\u003eUP\u003c/kbd\u003e, \u003ckbd\u003eDOWN\u003c/kbd\u003e, \u003ckbd\u003eLEFT\u003c/kbd\u003e or \u003ckbd\u003eRIGHT\u003c/kbd\u003e |\n| Pause toggle            | \u003ckbd\u003eSPACE\u003c/kbd\u003e                                                    |\n| Restarting on game over | \u003ckbd\u003eSPACE\u003c/kbd\u003e                                                    |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frcdmk%2Fjs-snake","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frcdmk%2Fjs-snake","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frcdmk%2Fjs-snake/lists"}