Skip to content

Repository files navigation

Retro Snake

Web-based Retro Snake game. Demo, server backend project.

License: MIT

Prerequisites

You will need the following things properly installed on your computer.

Installation

  • git clone <repository-url> this repository
  • change into the new directory
  • npm install

Hash

Hash is required for the server requests. You may use your own hash function or copy the default implementation.

cp js/encrypt.example.js js/encrypt.js

Production build

  • npm run build

Run at localhost

  • npm run start

Open URL http://localhost:8080/ and enjoy.

Controls

KeyAlternativeAction
WARROW UPMove up
SARROW DOWNMove down
AARROW LEFTMove left
DARROW RIGHTMove right
SPACEThrow
PESCAPEPause
RENTERRestart
HHelp
CColor mode
VVibration
TScore table

Levels

All levels located into src/js/levels.js file. Field size is 10x20.

Format:

module.exports=[{speed: 0,score: 100,items: [{type: 'barrier',start: [4,5],end: [5,5],pattern: [[1,0],[1,0],[-1,0],[-1,0]]},{type: 'wall',start: [0,4],end: [1,5]}]}];
  • numberspeed - start speed
  • numberscore - minimum score to level up
  • Arrayitems - items list (please read below)
  • stringitems[{type}] - item type (wall or barrier)

Wall item

Wall item is just a wall. If the snake touches the wall the game end.

  • stringtype - 'wall'
  • [number, number]start - wall start coordinates
  • [number, number]end - wall end coordinates

The wall is a filled rectangle. If you want to draw a blank rectangle, then you need to combine four wall items.

Barrier

Barrier is a moving wall.

  • stringtype - 'wall'
  • [number, number]start - wall start coordinates
  • [number, number]end - wall end coordinates
  • Array<[number, number]>pattern - motion pattern cycle

Each element of the motion pattern is an increment of the current barrier coordinates. The movement is cyclic, so be careful when creating a pattern.

License

MIT

About

Snake retro game

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages