Skip to content

Latest commit

 

History

History
78 lines (47 loc) · 2.03 KB

README.md

File metadata and controls

78 lines (47 loc) · 2.03 KB

GridGame

A TypeScript class that makes it easy to create grid based games.

GridGame is a TypeScript helper class that creates a playing field.
It needs to know the amount of tiles you want horizontally and vertically.
It also supports a function that it can call that will set custom information that the game needs per tile.
For example a click counter or a secret that lies beneath the tile.
For Minesweeper the secret would be the kind of the tile: Is it a bomb or not.

GridGame contains the following helper methods: (see API document)

It lets you create a lot with just a few lines of code:

  • Minesweeper: 45 lines of code
  • Sokoban: 67 lines of code
  • Tic-tac-toe with decision tree AI: 137 lines of code
  • Chess with Toledo Nanochess AI: 70 lines of code
  • Peg-Solitair: 36 lines of code
  • Lightsout: 25 lines of code
  • Tetris: unfinished

Usage:

npm install @java4life/gridgame --save
and then in (TypeScript) code do
import {GridGame} from '@java4life/gridgame';

Here are some demos:

Minesweeper

https://stackblitz.com/edit/gridgame-minesweeper

Sokoban

Sokoban

https://stackblitz.com/edit/gridgame-sokoban
https://stackblitz.com/edit/sokoban-level-editor

Tetris

https://stackblitz.com/edit/gridgame-tetris

Tic-tac-toe

https://stackblitz.com/edit/gridgame-tictactoe

Chess

https://stackblitz.com/edit/gridgame-nanochess

Peg-Solitair

Peg-Solitair

https://stackblitz.com/edit/gridgame-peg-solitair

Lightsout

https://stackblitz.com/edit/gridgame-lightsout
Play: https://gridgame-lightsout.stackblitz.io/

Conway's Game of Life

https://stackblitz.com/edit/conways-game-of-life-using-gridgame