Comparing version 0.1.1 to 0.1.2
{ | ||
"name": "snekjs", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "no step on snek", | ||
@@ -5,0 +5,0 @@ "author": { |
@@ -1,7 +0,9 @@ | ||
# no step on snek | ||
# 🐍 no step on snek [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT) [![snekjs on NPM](https://img.shields.io/npm/v/snekjs.svg?color=green&label=snekjs)](https://https://www.npmjs.com/package/snekjs) | ||
Snake written in JavaScript for the terminal (Node.js) | ||
Snake written in JavaScript for the terminal (Node.js). | ||
## Instructions | ||
### Clone from repository | ||
```bash | ||
@@ -12,1 +14,65 @@ git clone git@github.com:taniarascia/snek | ||
``` | ||
### npm module | ||
Install the snek package: | ||
```bash | ||
yarn add snekjs | ||
``` | ||
Create `play.js` | ||
```js | ||
// play.js | ||
const blessed = require('blessed') | ||
const screen = blessed.screen({ smartCSR: true }) | ||
const { Interface, Game } = require('snekjs') | ||
const ui = new Interface(screen, blessed) | ||
const game = new Game(ui) | ||
function tick() { | ||
if (game.gameOver()) { | ||
// Show game over screen on collision and end game | ||
ui.gameOverScreen() | ||
ui.render() | ||
return | ||
} | ||
ui.clearScreen() | ||
ui.clearDirection() | ||
game.renderDot() | ||
game.moveSnake() | ||
game.renderSnake() | ||
ui.render() | ||
} | ||
// Iterate every 50ms | ||
function main() { | ||
setInterval(tick, 50) | ||
} | ||
// Generate the coordinates of the first dot before the game begins | ||
game.generateDot() | ||
// Begin game | ||
main() | ||
``` | ||
Run the game. | ||
```bash | ||
node play.js | ||
``` | ||
## Author | ||
- [Tania Rascia](https://www.taniarascia.com) | ||
## License | ||
This project is open source and available under the [MIT License](LICENSE). |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
10107
78
0