diff --git a/.gitignore b/.gitignore index d45eeeb..ce82fc6 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,5 @@ temp .sass-cache .idea validation-report.json -validation-status.json \ No newline at end of file +validation-status.json +yarn.lock \ No newline at end of file diff --git a/README.md b/README.md index 8e1efff..df0dd74 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ yarn Then run: ```shell -npm start +node prod/index.js ``` @@ -61,6 +61,7 @@ TODO ## Release History +* 0.1.1 - Added level indicator, fixed lives display * 0.1.0 - alpha release diff --git a/dev/010-constructor.js b/dev/010-constructor.js index 75d102c..d56bd2e 100644 --- a/dev/010-constructor.js +++ b/dev/010-constructor.js @@ -54,11 +54,17 @@ const BEAST = (() => { //constructor factory }, 2: { //increase beasts and solids, decrease blocks beast: 3, + block: 400, + solid: 100, + speed: 1000, + }, + 3: { //increase beasts and solids, decrease blocks + beast: 5, block: 350, solid: 200, speed: 1000, }, - 3: { //increase beasts and solids, decrease blocks and speed + 4: { //increase beasts and solids, decrease blocks and speed beast: 10, block: 100, solid: 500, diff --git a/dev/030-draw.js b/dev/030-draw.js index 30e3185..84424d5 100644 --- a/dev/030-draw.js +++ b/dev/030-draw.js @@ -87,9 +87,11 @@ BEAST.draw = (() => { // score, Draw the score at the bottom of the frame //-------------------------------------------------------------------------------------------------------------------------------------------------------------- score: () => { + BEAST.debugging.report(`draw: score`, 1); + customStdout.muted = false; - //testing screen size and just printing on error + //testing screen size let error = BEAST.checkSize(); if( error === '' ) { let top = Math.floor( ( CliSize().rows - BEAST.MINHEIGHT ) / 2 ); @@ -101,7 +103,11 @@ BEAST.draw = (() => { //calculate the space between lives and beast count let spaceMiddle = ( BEAST.MINWIDTH - 2 ) - ( 3 * BEAST.LIVES ) - 6 - ( Object.keys( BEAST.BEASTS ).length.toString().length ); - BEAST.RL.write(`${spaceLeft}${Chalk.red(' ❤').repeat( BEAST.LIVES - BEAST.DEATHS )}${Chalk.gray(' ❤').repeat( BEAST.DEATHS )}`); + BEAST.RL.write( + `${spaceLeft}${Chalk.red(` ${BEAST.SYMBOLS.hero}`).repeat( BEAST.LIVES - BEAST.DEATHS )}` + + `${Chalk.gray(` ${BEAST.SYMBOLS.hero}`).repeat( BEAST.DEATHS )}` + ); + BEAST.RL.write(`${' '.repeat( spaceMiddle )} ${ Object.keys( BEAST.BEASTS ).length } x ${BEAST.SYMBOLS.beast}`); Readline.cursorTo( BEAST.RL, 0, (CliSize().rows - 1) ); //go to bottom of board and rest cursor there @@ -111,6 +117,33 @@ BEAST.draw = (() => { }, +//-------------------------------------------------------------------------------------------------------------------------------------------------------------- +// Public function +// level, Draw the score at the bottom of the frame +//-------------------------------------------------------------------------------------------------------------------------------------------------------------- + level: () => { + BEAST.debugging.report(`draw: level`, 1); + + customStdout.muted = false; + + //testing screen size + let error = BEAST.checkSize(); + if( error === '' ) { + let top = Math.floor( ( CliSize().rows - BEAST.MINHEIGHT ) / 2 ); + let spaceLeft = Math.floor( ( CliSize().columns - BEAST.MINWIDTH ) / 2 ); //horizontal alignment + let spaceMiddle = ( BEAST.MINWIDTH - 2 ) - 9 - ( Object.keys( BEAST.LEVEL ).length.toString().length ); //calculate the space so we can right align + + Readline.cursorTo( BEAST.RL, (spaceLeft + spaceMiddle), (top + 2) ); //go to top above the board and right align + + BEAST.RL.write(` Level: ${BEAST.LEVEL}`); + + Readline.cursorTo( BEAST.RL, 0, (CliSize().rows - 1) ); //go to bottom of board and rest cursor there + } + + customStdout.muted = true; + }, + + //-------------------------------------------------------------------------------------------------------------------------------------------------------------- // Public function // board, Drawing the board @@ -186,6 +219,7 @@ BEAST.draw = (() => { BEAST.draw.frame(); //draw frame, BEAST.draw.score(); //draw score, + BEAST.draw.level(); //draw level, BEAST.draw.board(); //draw board, I mean the function names are kinda obvious so this comment really doesn't help much. }, } diff --git a/dev/dev.js b/dev/dev.js index 30a03d5..b0c1f1d 100644 --- a/dev/dev.js +++ b/dev/dev.js @@ -54,11 +54,17 @@ const BEAST = (() => { //constructor factory }, 2: { //increase beasts and solids, decrease blocks beast: 3, + block: 400, + solid: 100, + speed: 1000, + }, + 3: { //increase beasts and solids, decrease blocks + beast: 5, block: 350, solid: 200, speed: 1000, }, - 3: { //increase beasts and solids, decrease blocks and speed + 4: { //increase beasts and solids, decrease blocks and speed beast: 10, block: 100, solid: 500, @@ -373,9 +379,11 @@ BEAST.draw = (() => { // score, Draw the score at the bottom of the frame //-------------------------------------------------------------------------------------------------------------------------------------------------------------- score: () => { + BEAST.debugging.report(`draw: score`, 1); + customStdout.muted = false; - //testing screen size and just printing on error + //testing screen size let error = BEAST.checkSize(); if( error === '' ) { let top = Math.floor( ( CliSize().rows - BEAST.MINHEIGHT ) / 2 ); @@ -387,7 +395,11 @@ BEAST.draw = (() => { //calculate the space between lives and beast count let spaceMiddle = ( BEAST.MINWIDTH - 2 ) - ( 3 * BEAST.LIVES ) - 6 - ( Object.keys( BEAST.BEASTS ).length.toString().length ); - BEAST.RL.write(`${spaceLeft}${Chalk.red(' ❤').repeat( BEAST.LIVES - BEAST.DEATHS )}${Chalk.gray(' ❤').repeat( BEAST.DEATHS )}`); + BEAST.RL.write( + `${spaceLeft}${Chalk.red(` ${BEAST.SYMBOLS.hero}`).repeat( BEAST.LIVES - BEAST.DEATHS )}` + + `${Chalk.gray(` ${BEAST.SYMBOLS.hero}`).repeat( BEAST.DEATHS )}` + ); + BEAST.RL.write(`${' '.repeat( spaceMiddle )} ${ Object.keys( BEAST.BEASTS ).length } x ${BEAST.SYMBOLS.beast}`); Readline.cursorTo( BEAST.RL, 0, (CliSize().rows - 1) ); //go to bottom of board and rest cursor there @@ -397,6 +409,33 @@ BEAST.draw = (() => { }, +//-------------------------------------------------------------------------------------------------------------------------------------------------------------- +// Public function +// level, Draw the score at the bottom of the frame +//-------------------------------------------------------------------------------------------------------------------------------------------------------------- + level: () => { + BEAST.debugging.report(`draw: level`, 1); + + customStdout.muted = false; + + //testing screen size + let error = BEAST.checkSize(); + if( error === '' ) { + let top = Math.floor( ( CliSize().rows - BEAST.MINHEIGHT ) / 2 ); + let spaceLeft = Math.floor( ( CliSize().columns - BEAST.MINWIDTH ) / 2 ); //horizontal alignment + let spaceMiddle = ( BEAST.MINWIDTH - 2 ) - 9 - ( Object.keys( BEAST.LEVEL ).length.toString().length ); //calculate the space so we can right align + + Readline.cursorTo( BEAST.RL, (spaceLeft + spaceMiddle), (top + 2) ); //go to top above the board and right align + + BEAST.RL.write(` Level: ${BEAST.LEVEL}`); + + Readline.cursorTo( BEAST.RL, 0, (CliSize().rows - 1) ); //go to bottom of board and rest cursor there + } + + customStdout.muted = true; + }, + + //-------------------------------------------------------------------------------------------------------------------------------------------------------------- // Public function // board, Drawing the board @@ -472,6 +511,7 @@ BEAST.draw = (() => { BEAST.draw.frame(); //draw frame, BEAST.draw.score(); //draw score, + BEAST.draw.level(); //draw level, BEAST.draw.board(); //draw board, I mean the function names are kinda obvious so this comment really doesn't help much. }, } diff --git a/package.json b/package.json index ef2b230..cd7606a 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "beast.js", "description": "ANSI Beast for node", - "version": "0.1.0", + "version": "0.1.1", "homepage": "https://github.com/dominikwilkowski/beast.js", "author": { "name": "Dominik Wilkowski", diff --git a/prod/index.js b/prod/index.js index 07284ff..85db9e9 100644 --- a/prod/index.js +++ b/prod/index.js @@ -54,11 +54,17 @@ const BEAST = (() => { //constructor factory }, 2: { //increase beasts and solids, decrease blocks beast: 3, + block: 400, + solid: 100, + speed: 1000, + }, + 3: { //increase beasts and solids, decrease blocks + beast: 5, block: 350, solid: 200, speed: 1000, }, - 3: { //increase beasts and solids, decrease blocks and speed + 4: { //increase beasts and solids, decrease blocks and speed beast: 10, block: 100, solid: 500, @@ -373,9 +379,11 @@ BEAST.draw = (() => { // score, Draw the score at the bottom of the frame //-------------------------------------------------------------------------------------------------------------------------------------------------------------- score: () => { + BEAST.debugging.report(`draw: score`, 1); + customStdout.muted = false; - //testing screen size and just printing on error + //testing screen size let error = BEAST.checkSize(); if( error === '' ) { let top = Math.floor( ( CliSize().rows - BEAST.MINHEIGHT ) / 2 ); @@ -387,7 +395,11 @@ BEAST.draw = (() => { //calculate the space between lives and beast count let spaceMiddle = ( BEAST.MINWIDTH - 2 ) - ( 3 * BEAST.LIVES ) - 6 - ( Object.keys( BEAST.BEASTS ).length.toString().length ); - BEAST.RL.write(`${spaceLeft}${Chalk.red(' ❤').repeat( BEAST.LIVES - BEAST.DEATHS )}${Chalk.gray(' ❤').repeat( BEAST.DEATHS )}`); + BEAST.RL.write( + `${spaceLeft}${Chalk.red(` ${BEAST.SYMBOLS.hero}`).repeat( BEAST.LIVES - BEAST.DEATHS )}` + + `${Chalk.gray(` ${BEAST.SYMBOLS.hero}`).repeat( BEAST.DEATHS )}` + ); + BEAST.RL.write(`${' '.repeat( spaceMiddle )} ${ Object.keys( BEAST.BEASTS ).length } x ${BEAST.SYMBOLS.beast}`); Readline.cursorTo( BEAST.RL, 0, (CliSize().rows - 1) ); //go to bottom of board and rest cursor there @@ -397,6 +409,33 @@ BEAST.draw = (() => { }, +//-------------------------------------------------------------------------------------------------------------------------------------------------------------- +// Public function +// level, Draw the score at the bottom of the frame +//-------------------------------------------------------------------------------------------------------------------------------------------------------------- + level: () => { + BEAST.debugging.report(`draw: level`, 1); + + customStdout.muted = false; + + //testing screen size + let error = BEAST.checkSize(); + if( error === '' ) { + let top = Math.floor( ( CliSize().rows - BEAST.MINHEIGHT ) / 2 ); + let spaceLeft = Math.floor( ( CliSize().columns - BEAST.MINWIDTH ) / 2 ); //horizontal alignment + let spaceMiddle = ( BEAST.MINWIDTH - 2 ) - 9 - ( Object.keys( BEAST.LEVEL ).length.toString().length ); //calculate the space so we can right align + + Readline.cursorTo( BEAST.RL, (spaceLeft + spaceMiddle), (top + 2) ); //go to top above the board and right align + + BEAST.RL.write(` Level: ${BEAST.LEVEL}`); + + Readline.cursorTo( BEAST.RL, 0, (CliSize().rows - 1) ); //go to bottom of board and rest cursor there + } + + customStdout.muted = true; + }, + + //-------------------------------------------------------------------------------------------------------------------------------------------------------------- // Public function // board, Drawing the board @@ -472,6 +511,7 @@ BEAST.draw = (() => { BEAST.draw.frame(); //draw frame, BEAST.draw.score(); //draw score, + BEAST.draw.level(); //draw level, BEAST.draw.board(); //draw board, I mean the function names are kinda obvious so this comment really doesn't help much. }, }