{"id":15633286,"url":"https://github.com/theronic/cljs-snake","last_synced_at":"2025-04-30T04:39:13.830Z","repository":{"id":36290492,"uuid":"40595019","full_name":"theronic/cljs-snake","owner":"theronic","description":"Snake in 100 lines of ClojureScript using Reagent for a #TechTalk at UCT","archived":false,"fork":false,"pushed_at":"2023-05-15T11:00:37.000Z","size":276,"stargazers_count":21,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-30T04:39:09.234Z","etag":null,"topics":["clojure","clojurescript","snake"],"latest_commit_sha":null,"homepage":"http://petrustheron.com/posts/sota-front-end-development-clojurescript.html","language":"Clojure","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/theronic.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":"2015-08-12T10:29:40.000Z","updated_at":"2023-05-15T10:59:34.000Z","dependencies_parsed_at":"2024-10-23T02:48:50.740Z","dependency_job_id":null,"html_url":"https://github.com/theronic/cljs-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/theronic%2Fcljs-snake","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theronic%2Fcljs-snake/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theronic%2Fcljs-snake/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theronic%2Fcljs-snake/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/theronic","download_url":"https://codeload.github.com/theronic/cljs-snake/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251644823,"owners_count":21620629,"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":["clojure","clojurescript","snake"],"created_at":"2024-10-03T10:48:04.954Z","updated_at":"2025-04-30T04:39:13.788Z","avatar_url":"https://github.com/theronic.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Snake in 100 Lines of ClojureScript\n\n![Snake Gameplay GIF](https://s3-eu-west-1.amazonaws.com/petrus-blog/snake-gameplay-3.gif)\n\nOn 12 August 2015, I presented a talk at UCT on [The State of the Art in Front End Development](http://petrustheron.com/posts/sota-front-end-development-clojurescript.html), during which we built a game in ClojureScript.\n\nYou can download the slides with coding videos and audio by [reading the blog post](http://petrustheron.com/posts/sota-front-end-development-clojurescript.html).\n\n## Tools:\n\n- ClojureScript 1.7\n- Boot-clj\n\n## To Run:\n\n```\nboot dev\n```\n\nWhen it's done compiling, open `http://localhost:8002/`\n\n## To Build for Production:\n\n```\nboot prod\n```\n\nThis will write out artifacts to the `docs` folder.\n\n## Features:\n\nYou can:\n- Turn left/right with the arrow keys\n- Take the red pill\n- Die by running into your tail\n- Get a high score\n\n## Turning\n\nWhen turning, the velocity vector is rotated by 90 degrees clockwise or counter-clockwise in the `next-state` function using a hard-coded [rotation matrix](https://en.wikipedia.org/wiki/Rotation_matrix).\n\n## Data Model\n\nThe simulation state is stored in an atom named `state` with these keys:\n\n- `:size` stores the size of the body of the snake, initially 3.\n- `:position` stores the snake's head as an `[x y]` coordinate, e.g. `[7 9]`\n- `:history` stores a list of previous head positions, so we can render the snake's body as the last N head positions, e.g. `([7 9] [6 9] [6 8] ...)`.\n- `:velocity` holds a relative `[x y]` vector that is added to the `:position` coordinate on every animation tick.\n- `:dead?` will be true when the snake die by running into its own body.\n- `:pills` stores a set of edible `[x y]` pill coordinates.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheronic%2Fcljs-snake","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftheronic%2Fcljs-snake","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheronic%2Fcljs-snake/lists"}