All Projects → theronic → cljs-snake

theronic / cljs-snake

Licence: other
Snake in 100 lines of ClojureScript using Reagent for a #TechTalk at UCT

Programming Languages

clojure
4091 projects
HTML
75241 projects

Labels

Projects that are alternatives of or similar to cljs-snake

Snake
Artificial intelligence for the Snake game.
Stars: ✭ 1,241 (+5809.52%)
Mutual labels:  snake
snake-server
Snake-Server is a pure Go implementation of the famous arcade game 🐍
Stars: ✭ 31 (+47.62%)
Mutual labels:  snake
AndroidGameSnake
AndroidGameSnake
Stars: ✭ 37 (+76.19%)
Mutual labels:  snake
Dotnet Console Games
Game examples implemented in .NET console applications primarily for educational purposes.
Stars: ✭ 157 (+647.62%)
Mutual labels:  snake
3dstool
An all-in-one tool for extracting/creating 3ds roms.
Stars: ✭ 246 (+1071.43%)
Mutual labels:  snake
go-snake-telnet
Snake Game over telnet protocol in Go
Stars: ✭ 22 (+4.76%)
Mutual labels:  snake
Tastysnake
A two-player (Bluetooth) game on Android.
Stars: ✭ 61 (+190.48%)
Mutual labels:  snake
wxgame-snake
🐍 微信小程序游戏,贪吃蛇
Stars: ✭ 20 (-4.76%)
Mutual labels:  snake
Cpp-Snake
A simple snake game written in c++
Stars: ✭ 35 (+66.67%)
Mutual labels:  snake
Python.io
Snake game inspired from Slither.io but features a python instead of a snake. Made in Python 3
Stars: ✭ 15 (-28.57%)
Mutual labels:  snake
Slither.io Clone
Learn how to make Slither.io with JavaScript and Phaser! This game clones all the core features of Slither.io, including mouse-following controls, snake collisions, food, snake growth, eyes, and more. Progress through each part of the source code with our Slither.io tutorial series.
Stars: ✭ 168 (+700%)
Mutual labels:  snake
Case
String case utitility: convert, identify, flip, extend
Stars: ✭ 237 (+1028.57%)
Mutual labels:  snake
Snake
用Java语言开发的AI贪吃蛇
Stars: ✭ 62 (+195.24%)
Mutual labels:  snake
Sharedfonttool
3DS SharedFontTool
Stars: ✭ 140 (+566.67%)
Mutual labels:  snake
snake game
This is a simple implementation of the classic snake game in rust
Stars: ✭ 16 (-23.81%)
Mutual labels:  snake
Snake
🐍🎮 Snake game made with Expo & PIXI.js 👾 iOS, Android, and Web
Stars: ✭ 67 (+219.05%)
Mutual labels:  snake
Wortuhr ESP8266
Wortuhr mit ESP8266 WeMos D1 mini und NeoPixel WS2812B LEDs mit mp3 Sounds, Animationen, Transitions, Events und Spiele
Stars: ✭ 33 (+57.14%)
Mutual labels:  snake
snax86
A snake game written in x86 Assembly language for windows console
Stars: ✭ 21 (+0%)
Mutual labels:  snake
Snake
A simple game built using Python Pygame Library
Stars: ✭ 17 (-19.05%)
Mutual labels:  snake
snake-reinforcement-learning
AI (A2C agent) mastering the game of Snake with TensorFlow 2.0
Stars: ✭ 37 (+76.19%)
Mutual labels:  snake

Snake in 100 Lines of ClojureScript

Snake Gameplay GIF

On 12 August 2015, I presented a talk at UCT on The State of the Art in Front End Development, during which we built a game in ClojureScript.

You can download the slides with coding videos and audio by reading the blog post.

Tools:

  • ClojureScript 1.7
  • Boot-clj

To Run:

boot dev

When it's done compiling, open http://localhost:8002/

To Build for Production:

boot prod

This will write out artifacts to the docs folder.

Features:

You can:

  • Turn left/right with the arrow keys
  • Take the red pill
  • Die by running into your tail
  • Get a high score

Turning

When turning, the velocity vector is rotated by 90 degrees clockwise or counter-clockwise in the next-state function using a hard-coded rotation matrix.

Data Model

The simulation state is stored in an atom named state with these keys:

  • :size stores the size of the body of the snake, initially 3.
  • :position stores the snake's head as an [x y] coordinate, e.g. [7 9]
  • :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] ...).
  • :velocity holds a relative [x y] vector that is added to the :position coordinate on every animation tick.
  • :dead? will be true when the snake die by running into its own body.
  • :pills stores a set of edible [x y] pill coordinates.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].