0.0.7 • Published 6 years ago

game-2048 v0.0.7

Weekly downloads
19
License
MIT
Repository
github
Last release
6 years ago

2048

Just change the origin code to CommonJS version and publish it to npm to make it easy to use.

Demo

https://ppq1991.github.io/2048/

Usage

import
npm i -S game-2048
html
<div id="container"></div>
javascript
import 'game-2048/style/main.css';
import Game from 'game-2048';
const game = new Game({
  gameContainer: document.getElementById('container')
}); 

Config

constructor
propertytypedescrequireddefault
gameContainerHTMLElementthe game containerundefined
startTilesnumbernumber of tiles in the game beginningX2
endScorenumberthe score to win the gameX2048
keepPlayingbooleanshow keep playing button after player reach the end scoreXfalse
titlestringtitleX2048
descstringbrief introXJoin the numbers and get to the 2048 tile!
playerWinMessagestringalert message content when game wonXYou Win!
playerLoseMessagestringalert message content when game overXGame Over!
retryButtonTextstringretry button textXTry Again
keepPlayingButtonTextstringkeep playing button textXKeep Going!
newGameButtonTextstringbutton textXNew Game
initValuenumberinit value of the first tileX2
getNextValuefunctioncall this function to get next valueXv => v * 2
getClassNameByValuefunctioncall this function to get classnameXv => tile-${v}
onGameStartfunctionon game start hookXundefined
onGameOverfunctiononGameOver(score, isWin)Xundefined
methods

Screenshot

License

2048 is licensed under the MIT license.

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago