Skip to content

vnidev/snake-game

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Retro snake - javascript game

Retro snake game created in javascript. You can play demo on Snake game.

Table of Contents

About

Snake game

For those who don't know the rules of the game (if they exists), the rules are simple. You need to eat food to grow and avoid hitting the walls and yourself. The bigger you are, the more difficult will be. So, take fun and good luck.

Quick start

You need to include snake.css and snake.min.js in your head tag:

<link rel="stylesheet" href="./styles/snake.css" />
<script src="./dist/snake.min.js"></script>

Then add game container to body tag:

<div id="game-container"></div>

Then you need to initialize game in script tag:

function onDocumentLoad() {
   new Game('#game-container');
}
document.addEventListener('DOMContentLoaded', onDocumentLoad);

And that's it. See Documentation section for controls and options.

Documentation

Game controls
  • SPACE BAR - start game or restart after game over,
  • UP ARROW - move up,
  • DOWN ARROW - move down,
  • LEFT ARROW - move left,
  • RIGHT ARROW - move right,
  • Z - decrease game level/speed,
  • X - increase game level/speed.
Options

There is a few options that can be used to change game settings.

new Game('#game-container', {SPEED: 5, BOARD_WIDTH: 20, BOARD_HEIGHT: 10});

Available options:

  • SPEED - initial speed for game start (default: 1, range: 1-10),
  • BOARD_WIDTH - width of the game board (default: 20, range: 10-40),
  • BOARD_HEIGHT - height of the game board (default: 10, range: 5-20).

To be done

  • game graphics

About

Javascript retro snake game

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published