Skip to content

Commit

Permalink
init game
Browse files Browse the repository at this point in the history
  • Loading branch information
iamkun committed Mar 20, 2018
0 parents commit d5b5902
Show file tree
Hide file tree
Showing 69 changed files with 1,812 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"presets": [
[
"@babel/preset-env",
{
"targets": {
"browsers": [
"ios >= 9",
"android >= 4"
]
}
}
]
]
}
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules
.idea/
npm-debug.log
yarn.lock
.DS_Store

112 changes: 112 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
<h1 align="center">盖楼游戏</h1>
<p align="center"><img src="https://o2qq673j2.qnssl.com/tower-loading.gif"/></p>

> 一个基于 Canvas 的盖楼游戏
## Demo 预览
<p align="center"><img src="http://obdhoyfg4.bkt.clouddn.com/tower-preview.gif"/></p>
<h2 align="center"><a href="http://fe.bmqb.com/tower_game/index.html">在线预览地址</a></h2>
<h4 align="center">手机设备可以扫描下方二维码</h4>
<p align="center">
<img src="https://o2qq673j2.qnssl.com/invite_code.png" />
</p>

## Game Rule 游戏规则

以下为默认游戏规则,也可参照下节自定义游戏参数

- 每局游戏生命值为3,掉落一块楼层生命值减1,掉落3块后游戏结束,单局游戏无时间限制

- 成功盖楼加25分,完美盖楼加50分,连续完美盖楼额外加25分,楼层掉落扣除生命值1,单局游戏共有3次掉落机会

栗子:第一块完美盖楼加50分,第二块连续完美盖楼加75分,第三块连续完美盖楼加100分,依此类推……

<p align="center">
<img src="https://o2qq673j2.qnssl.com/Fv7ewqHHXeAnUAlF7AI9ndQulEOC" />
</p>

## Customise 自定义

```
git clone bmqb@tower-game
cd tower-game
npm install
npm start
```
打开 `http://localhost:8082`

- 图片、音频资源可以直接替换 `image` 目录下对应的资源文件
- 游戏规则可以修改 `index.js` 目录中 传入的 `option` 对象

## Option 自定义选项

可以使用以下 `option` 表格里的参数,完成游戏自定义,**所有参数都是非必填项**

| Option | Type | Description |
|---------|--------|-------------|
| width | number | 游戏主画面宽度 |
| height | number | 游戏主画面高度 |
| canvasId | string | Canvas 的 DOM ID |
| soundOn | boolean | 是否开启声音 |
| successScore | number | 成功盖楼分数 |
| perfectScore | number | 完美盖楼额外奖励分数 |
| <a href="#hookspeed">hookSpeed</a> | function | 钩子平移速度 |
| <a href="#hookangle">hookAngle</a> | function | 钩子摆动角度 |
| <a href="#landblockspeed">landBlockSpeed</a> | function | 下方楼房横向速度 |
| <a href="#setgamescore">setGameScore</a> | function | 当前游戏分数hook |
| <a href="#setgamesuccess">setGameSuccess</a> | function | 当前游戏成功次数hook |
| <a href="#setgamefailed">setGameFailed</a> | function | 当前游戏失败次数hook |

#### hookSpeed
钩子平移速度
函数接收两个参数,当前成功楼层和当前分数,返回速度数值
```
function(currentFloor, currentScore) {
return number
}
```

#### hookAngle
钩子摆动角度
函数接收两个参数,当前成功楼层和当前分数,返回角度数值
```
function(currentFloor, currentScore) {
return number
}
```

#### landBlockSpeed
下方楼房平移速度
函数接收两个参数,当前成功楼层和当前分数,返回速度数值
```
function(currentFloor, currentScore) {
return number
}
```

#### setGameScore
当前游戏分数hook
函数接收一个参数,当前游戏分数
```
function(score) {
// your logic
}
```

#### setGameSuccess
当前游戏成功次数hook
函数接收一个参数,当前游戏成功次数
```
function(successCount) {
// your logic
}
```

#### setGameFailed
当前游戏失败次数hook
函数接收一个参数,当前游戏失败次数
```
function(failedCount) {
// your logic
}
```
Binary file added assets/background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/bgm.mp3
Binary file not shown.
Binary file added assets/bgm.ogg
Binary file not shown.
Binary file added assets/block-perfect.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/block-rope.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/block.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/c1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/c2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/c3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/c4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/c5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/c6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/c7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/c8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/drop-perfect.mp3
Binary file not shown.
Binary file added assets/drop-perfect.ogg
Binary file not shown.
Binary file added assets/drop.mp3
Binary file not shown.
Binary file added assets/drop.ogg
Binary file not shown.
Binary file added assets/f1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/f2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/f3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/f4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/f5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/f6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/f7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/game-over.mp3
Binary file not shown.
Binary file added assets/game-over.ogg
Binary file not shown.
Binary file added assets/heart.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/hook.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/main-bg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/main-index-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/main-index-start.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/main-index-title.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/main-loading-logo.png
Binary file added assets/main-loading.gif
Binary file added assets/main-modal-again-b.png
Binary file added assets/main-modal-bg.png
Binary file added assets/main-modal-invite-b.png
Binary file added assets/main-modal-over.png
Binary file added assets/main-share-icon.png
Binary file added assets/rope.png
Binary file added assets/rotate.mp3
Binary file not shown.
Binary file added assets/rotate.ogg
Binary file not shown.
Binary file added assets/score.png
Binary file added assets/tutorial-arrow.png
Binary file added assets/tutorial.png
Binary file added assets/wenxue.eot
Binary file not shown.
1 change: 1 addition & 0 deletions assets/wenxue.svg
Binary file added assets/wenxue.ttf
Binary file not shown.
Binary file added assets/wenxue.woff
Binary file not shown.
2 changes: 2 additions & 0 deletions assets/zepto-1.1.6.min.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/main.js

Large diffs are not rendered by default.

Loading

0 comments on commit d5b5902

Please sign in to comment.