https://github.com/cribbles/snake
JavaScript remake of the Nokia classic
https://github.com/cribbles/snake
Last synced: about 2 months ago
JSON representation
JavaScript remake of the Nokia classic
- Host: GitHub
- URL: https://github.com/cribbles/snake
- Owner: cribbles
- License: mit
- Created: 2015-09-06T01:00:39.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2015-10-14T12:13:04.000Z (over 10 years ago)
- Last Synced: 2025-03-10T23:59:04.450Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 270 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Snake.js
[Live](http://chrissloop.com/snake)
## Summary
This is a remake of the classic Snake arcade game using JavaScript, jQuery and
CSS. I added a twist by including a computer AI that competes for apples.
## Features
- JavaScript and jQuery back-end, HTML/CSS front-end
- Implements core gameplay using events handling and DOM manipulation
- Smooth rendering engine only redraws changing portions of the screen
## How It Works
The Computer AI calculates its next move by sorting the adjacent cardinal
coordinates of its 'head' according to their distance from the apple, using the
[Manhattan method](https://en.wikipedia.org/wiki/Taxicab_geometry) as a
heuristic. It doesn't evaluate unsafe coordinates, i.e. ones that would cause it
to run into itself, out of range, or into another player.
The board is rendered in pure HTML/CSS. The rendering engine works by applying
`$.removeClass` and `$.addClass` to dynamic elements (the apple and snakes) in
sync with player movement. This keeps the animation smooth, even as the game speeds up.
## License
Snake.js is released under the [MIT License](/LICENSE).
---
Developed by [Chris Sloop](http://chrissloop.com)