README.md

August 29, 2025 · View on GitHub

LICENSE

English | 简体中文

Tower Building Game

a tower building game based on ES6 and Canvas (Tower Bloxx Deluxe Skyscraper)

Demo

Link to online Demo (Demo Link)

Mobile Devices can scan following QR code:

Game Rule

The following are the default game rules:

  • The player starts with 3 hp, indicated by the hearts in the top right corner of the screen. Every time a Tower block falls the player loses 1 hp, and the game ends when hp is depleted.

  • The player earns 25 points for every succesful stacked block (Success). If a block is stacked pefectly (Perfect) on top of the previous one, then the player is rewarded with 50 points instead. Consecutive Perfects awards additional 25 points.

Note: Each Success or Perfect constitutes a floor

For example, the first Perfect awards 50 points. The second consecutive Perfect awards 75 points. The third consecutive Perfect awards 100 points. etc.

Customizing the game rules

git clone https://github.com/iamkun/tower_game.git
cd tower_game
npm install
npm start

Open http://localhost:8082 in a web browser.

  • To customize image and sound resource files directly replace the corresponding file under the assets directory.
  • To customize game rules modify the option object in index.html.

Option

Use the following table of option constants to complete customization of game rules.

Note: all constants are optionally included

OptionTypeDescription
widthnumberWidth of game interface
heightnumberHeight of game interface
canvasIdstringDOM ID in Canvas
soundOnbooleanIf sound is on
successScorenumberPoints awarded for success
perfectScorenumberAdditional points awarded for perfect
hookSpeedfunctionSpeed of hook's movement
hookAnglefunctionAngle of hook
landBlockSpeedfunctionSpeed of block sway
setGameScorefunctionhook for current score
setGameSuccessfunctionhook for number of current succesful game
setGameFailedfunctionhook for number of current failed game

hookSpeed

This function takes in two parameters, currentFloor and currentScore, and returns a speed value.

function(currentFloor, currentScore) {
  return number
}

hookAngle

This function takes in two parameters, currentFloor and currentScore, and returns a angle value.

function(currentFloor, currentScore) {
  return number
}

landBlockSpeed

This function takes in two parameters, currentFloor and currentScore, and returns a speed value.

function(currentFloor, currentScore) {
  return number
}

setGameScore

This function takes in one parameter, score, and sets currentScore to score.

function(score) {
  // your logic
}

setGameSuccess

This function takes in one parameter, score, and sets GameSuccess to successCount.

function(successCount) {
  // your logic
}

setGameFailed

This function takes in one parameter, score, and sets GameFailed to failedCount.

function(failedCount) {
  // your logic
}

License

MIT license.