Web-based Retro Snake game. Demo, server backend project.
You will need the following things properly installed on your computer.
git clone <repository-url>this repository- change into the new directory
npm install
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.jsnpm run build
npm run start
Open URL http://localhost:8080/ and enjoy.
| Key | Alternative | Action |
|---|---|---|
W |
ARROW UP |
Move up |
S |
ARROW DOWN |
Move down |
A |
ARROW LEFT |
Move left |
D |
ARROW RIGHT |
Move right |
SPACE |
Throw | |
P |
ESCAPE |
Pause |
R |
ENTER |
Restart |
H |
Help | |
C |
Color mode | |
V |
Vibration | |
T |
Score table |
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]
}
]
}
];- number
speed- start speed - number
score- minimum score to level up - Array
items- items list (please read below) - string
items[{type}]- item type (wallorbarrier)
Wall item is just a wall. If the snake touches the wall the game end.
- string
type-'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 is a moving wall.
- string
type-'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.