GithubHelp home page GithubHelp logo

iamkun / tower_game Goto Github PK

View Code? Open in Web Editor NEW
1.5K 34.0 394.0 1.92 MB

💒 HTML5 Canvas Tower Building Game 🏢🏬🏦🏯🏰

Home Page: https://iamkun.github.io/tower_game/

License: MIT License

JavaScript 79.89% HTML 20.11%
canvas html5 javascript game

tower_game's Introduction

LICENSE

English | 简体中文

Tower Building Game

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

Demo

Mobile Devices can scan following QR code:

Game Rule

The following are the default game rule:

  • In every game player starts with 3 hp. Every time a Tower block is dropped player is deduct 1 hp; game ends when hp is depleted.

  • Player is rewarded with 25 point for every succesful stacked blocks(Success). If a block is stacked pefectly (Perfect) on top of the previous one, then player 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 point. The second consecutive Perfect awards 75 points. The third consecutive Perfect awards 100 points. etc.

Customizing the game rule

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 assets directory.
  • To customize game rules modify the option object in index.html.

Option

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

Note: all constants are optionally included

Option Type Description
width number Width of game interface
height number Height of game interface
canvasId string DOM ID in Canvas
soundOn boolean If sound is on
successScore number Points awarded for success
perfectScore number Additional points awarded for perfect
hookSpeed function Speed of hook's movement
hookAngle function Angle of hook
landBlockSpeed function Speed of block sway
setGameScore function hook for current score
setGameSuccess function hook for number of current succesful game
setGameFailed function hook for number of current failed game

hookSpeed

Speed of hook's movement This function takes in two parameters, currentFloor and currentScore, and returns a speed value.

function(currentFloor, currentScore) {
  return number
}

hookAngle

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

function(currentFloor, currentScore) {
  return number
}

landBlockSpeed

Speed of block sway This function takes in two parameters, currentFloor and currentScore, and returns a speed value.

function(currentFloor, currentScore) {
  return number
}

setGameScore

hook for current score This function takes in one parameters, score, and sets currentScore to score.

function(score) {
  // your logic
}

setGameSuccess

hook for number of current succesful game This function takes in one parameters, score, and sets GameSuccess to successCount.

function(successCount) {
  // your logic
}

setGameFailed

hook for number of current failed game This function takes in one parameters, score, and sets GameFailed to failedCount.

function(failedCount) {
  // your logic
}

License

MIT license.

tower_game's People

Contributors

iamkun avatar wenweil avatar yds9744 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tower_game's Issues

可复现bug

房子在失败掉落的时候,如果未碰到任何建筑直接掉落,下次摇摆上的房子钩住的位置就会有偏移
image

How can i restart the game without having to refresh the page?

game.setVariable(constant.successCount, 0) game.setVariable(constant.failedCount, 0) game.setVariable(constant.gameScore, 0) game.setVariable(constant.hardMode, false) game.setVariable(constant.gameStartNow, true)

I can use these variables to reset the values but how do i go about starting the game from start without creating a new instance of the game?

Importing the game to REACTJS

Great game!

I want to use this with Reactjs, but I'm not able to, the min.js files are showing up as errors and there are other problems as well. Can you help me and let me know how I could do this?

Thanks.

[Documentation] How to customize?

Hi there,

Would it be possible to customize the game a little and add instructions how to do so?

For instance, rather than the chinese picture, perhaps allow users another picture,
such as a cat? Another idea for customization could be for users to modify the
colours?

I assume it is all possible to do, but helpful pointers may be nice if you ever have
the time. Thank you for reading!

怎么做到在ios端的微信里播放背景音乐呢

我尝试把 cooljs 中添加/播放音频的方法加到我的项目里,但是在ios端的微信里无法用js 控制背景音乐的播放。这个小游戏从微信一点开就能播放背景音乐,这是如何做到的呢?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.