diff --git a/README.md b/README.md index fa46e8d3..bb72521e 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,8 @@ HTML5 canvas制作的魔塔样板,支持全平台游戏! **即使完全不会编程的用户,按照模板和说明文档也能很快做出一个魔塔游戏!** * [Demo / 样板效果](https://ckcz123.com/games/template/) -* [Docs / 使用文档说明](https://ckcz123.github.io/mota-js) +* [Docs / 使用文档说明](https://ckcz123.github.io/mota-js/) +* [Video / 视频教程](http://www.bilibili.com/video/av17608025/) ![样板](./docs/img/sample0.png) diff --git a/docs/event.md b/docs/event.md index 37599924..3fa2df43 100644 --- a/docs/event.md +++ b/docs/event.md @@ -251,7 +251,7 @@ value是一个表达式,将通过这个表达式计算出的结果赋值给nam {"type": "setValue", "name": "status:money", "value": "1000" } // 将金币数设为1000(不是+1000) {"type": "setValue", "name": "status:hp", "value": "status:hp*2" } // 生命值翻倍 {"type": "setValue", "name": "item:yellowKey", "value": "item:yellowKey+3" } // 黄钥匙个数加3 - {"type": "setValue", "name": "item:boom", "value": "item:boom+10" } // 炸弹个数+10 + {"type": "setValue", "name": "item:bomb", "value": "item:bomb+10" } // 炸弹个数+10 {"type": "setValue", "name": "flag:man_times", "value": "0" } // 将变量man_times设为0 {"type": "setValue", "name": "flag:man_times", "value": "flag:man_times+2*status:atk" } // 将变量man_times的值加上勇士的攻击数值的两倍 ] diff --git a/docs/index.md b/docs/index.md index 59a0d17d..ad17349c 100644 --- a/docs/index.md +++ b/docs/index.md @@ -11,6 +11,8 @@ 继续查看文档的详细介绍,让你学会如何使用这一个样板来制作属于自己的HTML5魔塔。 +视频教程地址:http://www.bilibili.com/video/av17608025/ ,配合本教程观看效果更佳~ + ========================================================================================== [继续阅读下一章:现在就做出自己的第一部H5魔塔!](start) diff --git a/docs/personalization.md b/docs/personalization.md index 3fd37899..08328a78 100644 --- a/docs/personalization.md +++ b/docs/personalization.md @@ -80,7 +80,7 @@ if (id == 65) tmp.event = {'cls': 'items', 'id': 'hammer'} // 圣锤 1. 指定一个唯一的英文ID,不能和enemys中现有的重复。 2. 进入icons.js,在enemys分类下进行添加(对应图标在图片上的位置,即index) 3. 在maps.js的getBlock下继续进行添加。请注意其ID为200开始的顺序,即如果新增一行为261,依次类推 -4. 在items.js中仿照其他道具,来添加道具的信息。 +4. 在enemys.js中仿照其他怪物,来添加怪物的信息。 ``` js if (id == 258) tmp.event = {'cls': 'enemys', 'id': 'octopus'}; diff --git a/libs/core.js b/libs/core.js index aed539ee..6c6cfc0d 100644 --- a/libs/core.js +++ b/libs/core.js @@ -76,6 +76,9 @@ function core() { 'mouseOutCheck': 1, 'moveStepBeforeStop': [], + // 勇士状态;中心对称飞行器 + 'usingCenterFly':false, + // event事件 'savePage': null, 'shops': {}, @@ -373,7 +376,8 @@ core.prototype.onkeyUp = function(e) { break; } } - core.stopHero(); + //core.stopHero(); + core.keyUp(e.keyCode); } else { core.keyUp(e.keyCode); } @@ -424,6 +428,33 @@ core.prototype.keyDown = function(keyCode) { case 40: core.moveHero('down'); break; + case 51: // 快捷键3:飞 + // 因为加入了两次的检测机制,从keydown转移到keyup,同时保证位置信息正确,但以下情况会触发作图的bug: + // 在鼠标的路线移动中使用飞,绿块会滞后一格,显示的位置不对,同时也不会倍以下的代码清除 + if (core.status.heroStop && core.hasItem('centerFly')) { + if (core.status.usingCenterFly) { + if (core.canUseItem('centerFly')) { + core.useItem('centerFly'); + core.clearMap('ui', core.getHeroLoc('x')*32,core.getHeroLoc('y')*32,32,32); + + } + else { + core.drawTip('当前不能使用中心对称飞行器'); + core.clearMap('ui', (12-core.getHeroLoc('x'))*32,(12-core.getHeroLoc('y'))*32,32,32); + } + core.status.usingCenterFly = false; + } else { + core.status.usingCenterFly = true; + var fillstyle = 'rgba(255,0,0,0.5)'; + if (core.canUseItem('centerFly')) fillstyle = 'rgba(0,255,0,0.5)'; + core.fillRect('ui',(12-core.getHeroLoc('x'))*32,(12-core.getHeroLoc('y'))*32,32,32,fillstyle); + } + } + break; + } + if (core.status.usingCenterFly && keyCode!=51) { + core.clearMap('ui', (12-core.getHeroLoc('x'))*32,(12-core.getHeroLoc('y'))*32,32,32); + core.status.usingCenterFly= false; } } @@ -547,17 +578,9 @@ core.prototype.keyUp = function(keyCode) { } } break; - case 51: // 快捷键3:飞 - if (core.status.heroStop && core.hasItem('centerFly')) { - if (core.canUseItem('centerFly')) { - core.useItem('centerFly'); - } - else { - core.drawTip('当前不能使用中心对称飞行器'); - } - } - break; + } + core.stopHero(); } @@ -649,6 +672,25 @@ core.prototype.onclick = function (x, y, stepPostfix) { // 非游戏屏幕内 if (x<0 || y<0 || x>12 || y>12) return; + // 中心对称飞行器 + if (core.status.usingCenterFly) { + if (x!=12-core.getHeroLoc('x') || y!=12-core.getHeroLoc('y')) { + core.clearMap('ui', (12-core.getHeroLoc('x'))*32,(12-core.getHeroLoc('y'))*32,32,32); + } else { + if (core.canUseItem('centerFly')) { + core.useItem('centerFly'); + core.clearMap('ui', core.getHeroLoc('x')*32,core.getHeroLoc('y')*32,32,32); + + return; + } + else { + core.drawTip('当前不能使用中心对称飞行器'); + core.clearMap('ui', (12-core.getHeroLoc('x'))*32,(12-core.getHeroLoc('y'))*32,32,32); + } + } + core.status.usingCenterFly= false; + } + // 寻路 if (!core.status.lockControl) { core.setAutomaticRoute(x, y, stepPostfix); diff --git a/libs/events.js b/libs/events.js index fac9f95e..74f6a00e 100644 --- a/libs/events.js +++ b/libs/events.js @@ -457,8 +457,15 @@ events.prototype.useItem = function(itemId) { core.useFly(false); return; } + if (itemId=='centerFly') { + core.status.usingCenterFly= true; + var fillstyle = 'rgba(255,0,0,0.5)'; + if (core.canUseItem('centerFly')) fillstyle = 'rgba(0,255,0,0.5)'; + core.fillRect('ui',(12-core.getHeroLoc('x'))*32,(12-core.getHeroLoc('y'))*32,32,32,fillstyle); + return; + } - if (core.canUseItem(itemId)) core.useItem(itemId); + if (core.canUseItem(itemId))core.useItem(itemId); else core.drawTip("当前无法使用"+core.material.items[itemId].name); } diff --git a/libs/floors/sample0.js b/libs/floors/sample0.js index 5f296247..0b730b25 100644 --- a/libs/floors/sample0.js +++ b/libs/floors/sample0.js @@ -15,8 +15,8 @@ main.floors.sample0 = { [216, 247, 256, 235, 248, 6, 0, 3, 49, 50, 51, 52, 38], [6, 6, 125, 6, 6, 6, 0, 1, 45, 46, 47, 48, 37], [224, 254, 212, 232, 204, 5, 0, 1, 31, 32, 34, 33, 36], - [201, 205, 217, 215, 207, 5, 0, 1, 27, 28, 29, 30, 35], - [5, 5, 125, 5, 5, 5, 0, 1, 21, 22, 23, 24, 25], + [201, 205, 217, 215, 207, 5, 50, 1, 27, 28, 29, 30, 35], + [5, 5, 125, 5, 5, 5, 50, 1, 21, 22, 23, 24, 25], [0, 0, 0, 0, 0, 0, 45, 1, 1, 1, 121, 1, 1], [4, 4, 126, 4, 4, 4, 0, 0, 0, 0, 0, 85, 124], [87, 11, 12, 13, 14, 4, 4, 2, 2, 2, 122, 2, 2], diff --git a/常用工具/便捷PS工具.exe b/常用工具/便捷PS工具.exe index ffe1447f..7ec2fc98 100644 Binary files a/常用工具/便捷PS工具.exe and b/常用工具/便捷PS工具.exe differ