The NAGA BONAR Project is an open source game project with license GPL-3.0, build with HTML, CSS JS (include jQuery library) and some image assets. Everyone can contribution to this project with fork and pull request from my github.
[Important!] Naga Bonar Class using jQuery for core library like animate, dom and anything
Rule Of Game (Its the rule of the game, everything algoritmas of this game defining from this rule)
- Every pion move if start button or space key on clicked
- Every pion move to blok with formula current location + getting random number (ex. current location is 1 and then this pion get dice 4 so this pion move to blok 5)
- If pion walk above stairs so this pion will move up to end of stairs [Up]
- If pion walk above dragon head so this pion will move down to end of tail dragon [Drop]
- If pion get dice and > last blok so move pion to last blok and then move to blok "Last blok - rest of move" (ex. My pion on blok 96 and i get dice 6 so my pion move to blok 100 and move again to blok 98 ) [Retreat]
- Player poin +10 if player moving, if player up so poin +20 and player drop so poin -5
- Player move is summary for all getting dice
Formula Of Game (Define formula of game as math for moving and detection of pion and blok)
- Use
Math.floor(Math.random() * 10 * 4)
to get random pixel position to set margin all of pion - Use attribute data-blok to find specific blok
- Use
(Blok offset left - (board offset left - 20 pixel) )
to set position left of pion - Use
(Blok offset top - (570 pixel + (Math.floor(Math.random() * 2) + 1) * 10)
to set position top of pion - If pion moving before last blok use (location of pion + moving) step else (location of pion - moving)
- If moving number as negative value convert it to positive with
Math.abs()
function - Set last pion with "If last pion + 1 > maximum pion define it with 1 else define it with last pion + 1"
- Use
150 * moving
step to set interval of moving pion - If moving step > 5 convert moving step to 5
Everything on this class using namespace NagaBonar
for initialize.
Default Configuration
In this list i'm use variable to set all configuration with define :
allPion
to set pion to use of game, maximum 4 pion [Dont Change]maxPion
to get how many pion in gametrigger
optional variable for trigger on some methodlastPion
to set last pion on last movelastBlok
to get how many blok in game [Dont Change]board
to define board elementlang
to define language for game (default id [Indonesia])env
to set environtment for this game (dev or prod)blok
is default array to make blok grid [Dont Change]extraBlok
is customizible array to make extra blok in grid like dragon movingpionObject
is default object for pion for save in localstorage
isUndefined()
Method to check a value is undefined or norandom()
Method to get random number from 1 until 6storage()
Method to access HTML 5 Local Storageparse()
Method to parse stringify to JSON (alias from JSON.parse())string()
Method to convert JSON to stringify (alias from JSON.stringify())echo()
Method to display console.log() with custom color (red, green & blue)getStorage()
Method to getnaga_bonar
storage from browser
initGrid()
Method to Initialize grid for gameinitStart()
Method to create pioninitWord()
Method to create default text for player name etc.initPion()
Method to set position pion to default positioninitMove()
Method to Initialize moving pioninitAnimate()
Method to Animate pion from start to end formuladoStart()
Method to trigger moving piondoRestart()
Method to re-setup all of gameplaceColor()
Method to change background color when pion moveplaceDice()
Method to change dice numberplaceScore()
Method to set score, name etc.saveAction()
Method to save all move and action to local storagemessageUp()
Method to trigger if pion wall above stairsmessageDrop()
Method to trigger if pion wall above dragoncloseGame()
Method to trigger if pion has finish gamepopupMessageShow()
Method to show popup messagepopupMessageClose()
Method to close popup message
- Ali
- Nilam
- William
- Richard
- jQuery Project [Awesome Core Library]
- Animate CSS [Awesome CSS Animation Library]
- Font Awesome
- Chinese Background Design Credits [Background on Grid Board]
- Inkscape [All Assets Images]
If you have any question for contribution, feedback and anything just contact me at my social media account.
This project under license GPL-3.0 See License