当前位置: 首页 > news >正文

网页和网站的联系seo一个月赚多少钱

网页和网站的联系,seo一个月赚多少钱,站长统计导航窗口,合肥网站建设电话系列文章目录 第一章 2D二维地图绘制、人物移动、障碍检测 第二章 跟随人物二维动态地图绘制、自动寻径、小地图显示(人物红点显示) 文章目录 系列文章目录前言一、列计划1.1、目标1.2、步骤 二、使用步骤2.1、准备素材(图片):草坪、人物(熊猫)、障碍(石头)2.2、初…

系列文章目录

第一章 2D二维地图绘制、人物移动、障碍检测
第二章 跟随人物二维动态地图绘制、自动寻径、小地图显示(人物红点显示)


文章目录

  • 系列文章目录
  • 前言
  • 一、列计划
    • 1.1、目标
    • 1.2、步骤
  • 二、使用步骤
    • 2.1、准备素材(图片):草坪、人物(熊猫)、障碍(石头)
    • 2.2、初始化布局(表格),边距设置为0,无边框,设置背景图(草坪)平铺拉满
    • 2.3、标记草坪、熊猫、石头的代码
    • 2.4、初始化二维地图数据,初始化障碍物围墙,初始化人物位置
    • 2.5、计算公共变量二维地图的行、列
    • 2.6、合并二维地图数据、人物位置数据,渲染到页面
    • 2.7、设置全局键盘事件(在Body上添加),监听wasd按键事件:w(上) s(下) a(左) d(右)、在事件里增加任务移动逻辑/增加边界逻辑、在事件里增加障碍检测逻辑
  • 3、部分效果图
  • 总结


前言

复习JavaScript 事件有感,心血来潮想做一个2D二维地图绘制、人物移动、障碍检测相关的单页面游戏。
技术栈:JavaScript、Html、CSS
环境:chrome浏览器
编辑器:记事本(Idea)
在这里插入图片描述


一、列计划

1.1、目标

做一个2D二维地图绘制、人物移动、障碍检测相关的单页面游戏

1.2、步骤

  • 准备素材(图片):草坪、人物(熊猫)、障碍(石头)
  • 初始化布局(表格),边距设置为0,无边框,设置背景图(草坪)平铺拉满
  • 标记草坪、熊猫、石头的代码
  • 初始化二维地图数据,初始化障碍物围墙,初始化人物位置
  • 计算公共变量二维地图的行、列
  • 合并二维地图数据、人物位置数据,渲染到页面
  • 设置全局键盘事件(在Body上添加),监听wasd按键事件:w(上) s(下) a(左) d(右)
  • 在事件里增加任务移动逻辑、增加边界逻辑
  • 在事件里增加障碍检测逻辑

二、使用步骤

2.1、准备素材(图片):草坪、人物(熊猫)、障碍(石头)

在这里插入图片描述
在这里插入图片描述

2.2、初始化布局(表格),边距设置为0,无边框,设置背景图(草坪)平铺拉满

设置table的ID:map1001
代表是编号1001的地图

	<style>table { border-collapse: collapse; padding: 0  ; background: url("../img/item/grass.png"); width:100%;height:100% ; background-position: center; background-size:cover;  background-repeat: no-repeat;  }td { width: 100px; height: 100px; }tr { display: block; margin: -5px; }</style><body onload="init()" onkeypress="keypress(event)">
<table id="map1001">
</table>
</body>

2.3、标记草坪、熊猫、石头的代码

<script>var empty = 0;   //空地或草坪var stone = 1;   //石头的标记是1var panda = 9;   //熊猫的标记是9
</script>

2.4、初始化二维地图数据,初始化障碍物围墙,初始化人物位置

<script>/*** 加载地图数据* 0 空地/草坪* 1 石头* 9 熊猫* @type {number[]}*/var mapData = [[ 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1] ,[ 1 , 0 , 1 , 0 , 0 , 0 , 0 , 1] ,[ 1 , 0 , 0 , 1 , 0 , 1 , 0 , 1] ,[ 1 , 0 , 0 , 0 , 0 , 1 , 0 , 1] ,[ 1 , 0 , 1 , 0 , 1 , 1 , 0 , 1] ,[ 1 , 0 , 1 , 0 , 0 , 0 , 0 , 1] ,[ 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1]]var initPoint = [1,4];   //初始化熊猫的位置是 1,4
</script>

2.5、计算公共变量二维地图的行、列

<script>var row = mapData.length;  //地图的行var column = mapData[0].length;  //地图的列
</script>

2.6、合并二维地图数据、人物位置数据,渲染到页面

<script>/*** 合并二维地图数据、人物位置数据,渲染到页面*/function init() {//二维数组里,去初始化熊猫的位置mapData[initPoint[0]][initPoint[1]] = pandaloadData(mapData);}/***  渲染地图* @param mapData*/function loadData(mapData) {// 获取地图对象var map = document.getElementById("map1001");//渲染一行八列的数据var mapHTML = "";for (var i = 0; i < row; i++) {mapHTML += "<tr>";for (var j = 0; j < column; j++) {if( mapData[i][j] == 0 ){mapHTML += "<td></td>";} else if( mapData[i][j] == 1 ){mapHTML += '<td><img src="../img/item/stone.png" style="height: 90px; height: 90px; border-radius: 50%;" ></td>';} else if( mapData[i][j] == 9 ){mapHTML += '<td><img src="../img/item/panda1.png" style="height: 90px; height: 90px; border-radius: 50%;" ></td>';}}mapHTML += "</tr>";}map.innerHTML = mapHTML;}
</script><body onload="init()" >

2.7、设置全局键盘事件(在Body上添加),监听wasd按键事件:w(上) s(下) a(左) d(右)、在事件里增加任务移动逻辑/增加边界逻辑、在事件里增加障碍检测逻辑

<script>/*** 监听wasd按键事件:w(上) s(下) a(左) d(右)* @param e*/var keypress = function keypress(e){var keynum = window.event ? e.keyCode : e.which;if( 119 == keynum ) {var point = initPoint;if( point[0] < row - 1 ) {var xPoint = initPoint[1];var yPoint = initPoint[0] - 1;if( checkStone(yPoint,xPoint) ){console.log("碰撞到石头了,停止动作")return}console.log("移动后的位置:x:" + xPoint + " , y:" + yPoint )initPoint = [yPoint,xPoint]operatePanda(point);console.log("向上")} else {console.log("超出地图范围了,停止动作")}} else if( 97 == keynum ) {var point = initPoint;if( point[1] > 0  ) {var xPoint = initPoint[1] -1;var yPoint = initPoint[0];if( checkStone(yPoint,xPoint) ){console.log("碰撞到石头了,停止动作")return}console.log("移动后的位置:x:" + xPoint + " , y:" + yPoint )initPoint = [yPoint,xPoint]operatePanda(point);console.log("向左")} else {console.log("超出地图范围了,停止动作")}} else if( 115 == keynum ) {var point = initPoint;if( point[0] < row - 1 ) {var xPoint = initPoint[1];var yPoint = initPoint[0] + 1;if( checkStone(yPoint,xPoint) ){console.log("碰撞到石头了,停止动作")return}console.log("移动后的位置:x:" + xPoint + " , y:" + yPoint )initPoint = [yPoint,xPoint]operatePanda(point);console.log("向下")} else {console.log("超出地图范围了,停止动作")}} else if( 100 == keynum ) {var point = initPoint;if( point[1] < column -1 ) {var xPoint = initPoint[1] + 1;var yPoint = initPoint[0];if( checkStone(yPoint,xPoint) ){console.log("碰撞到石头了,停止动作")return}console.log("移动后的位置:x:" + xPoint + " , y:" + yPoint )initPoint = [yPoint,xPoint]operatePanda(point);console.log("向右")} else {console.log("超出地图范围了,停止动作")}}}/*** 障碍检测(可加多个障碍条件)* @param yPoint* @param xPoint* @returns {boolean}*/function checkStone(yPoint , xPoint ) {return mapData[yPoint][xPoint] == stone;}
</script><body onload="init()" onkeypress="keypress(event)">

3、部分效果图

  • 尝试走到右上角的位置,初始化位置:1,4,目标值:1,1
    在这里插入图片描述
  • 尝试走直线,从左走到目标,中途碰到石头障碍就走不动了,此时上下左都有石头障碍,都走不动,只能向右走
    在这里插入图片描述
  • 向右走1格
  • 向下走2格
  • 向左走2格
  • 向上走一格
  • 向左走一格
  • 向上走一格
  • 抵达目标 在这里插入图片描述

总结

以上就是今天要讲的内容,本文仅仅简单介绍了2D二维地图绘制、人物移动、障碍检测,可以根据此开发出自动寻径避障、多障碍物绘制、NPC自动出现并移动、人物动画动作、多地图切换、装备仓库、装备效果等。例如:推箱子、走迷宫、副本游戏、熊猫吃竹子等。


文章转载自:
http://pathetical.rnds.cn
http://tantalum.rnds.cn
http://trackball.rnds.cn
http://bryony.rnds.cn
http://photogrammetry.rnds.cn
http://textualism.rnds.cn
http://semideify.rnds.cn
http://vasoconstrictor.rnds.cn
http://setup.rnds.cn
http://cross.rnds.cn
http://mystery.rnds.cn
http://parapraxis.rnds.cn
http://divagation.rnds.cn
http://gauziness.rnds.cn
http://denticule.rnds.cn
http://inartistic.rnds.cn
http://merchant.rnds.cn
http://anhinga.rnds.cn
http://shipway.rnds.cn
http://ridden.rnds.cn
http://subalkaline.rnds.cn
http://salpingian.rnds.cn
http://fontinal.rnds.cn
http://instigate.rnds.cn
http://unimaginative.rnds.cn
http://monicker.rnds.cn
http://dissectional.rnds.cn
http://haziness.rnds.cn
http://inarticulately.rnds.cn
http://jumbie.rnds.cn
http://trimorphous.rnds.cn
http://dinerout.rnds.cn
http://reconviction.rnds.cn
http://aphoristic.rnds.cn
http://ryegrass.rnds.cn
http://unc.rnds.cn
http://cumbersome.rnds.cn
http://canaanite.rnds.cn
http://countermark.rnds.cn
http://payoff.rnds.cn
http://fringy.rnds.cn
http://dislikeable.rnds.cn
http://diuron.rnds.cn
http://worm.rnds.cn
http://specilize.rnds.cn
http://prosper.rnds.cn
http://motard.rnds.cn
http://upbraid.rnds.cn
http://albomycin.rnds.cn
http://plywood.rnds.cn
http://rouge.rnds.cn
http://fortification.rnds.cn
http://sunlit.rnds.cn
http://paly.rnds.cn
http://epistrophe.rnds.cn
http://jurimetrics.rnds.cn
http://diastral.rnds.cn
http://richwin.rnds.cn
http://plaudit.rnds.cn
http://nacreous.rnds.cn
http://phagocytize.rnds.cn
http://reentrant.rnds.cn
http://brachycephalization.rnds.cn
http://cofferdam.rnds.cn
http://hebridean.rnds.cn
http://eobiont.rnds.cn
http://metrication.rnds.cn
http://pompey.rnds.cn
http://transgressor.rnds.cn
http://nathless.rnds.cn
http://variolate.rnds.cn
http://spicebush.rnds.cn
http://terebinth.rnds.cn
http://plasmodium.rnds.cn
http://toecap.rnds.cn
http://discophile.rnds.cn
http://frogfish.rnds.cn
http://anabaptistical.rnds.cn
http://chiphead.rnds.cn
http://aerophone.rnds.cn
http://peloton.rnds.cn
http://lie.rnds.cn
http://seedy.rnds.cn
http://perinea.rnds.cn
http://fribble.rnds.cn
http://ritz.rnds.cn
http://cyanurate.rnds.cn
http://coniferae.rnds.cn
http://belch.rnds.cn
http://lorryhop.rnds.cn
http://footway.rnds.cn
http://phalanstery.rnds.cn
http://variform.rnds.cn
http://tumbledung.rnds.cn
http://twang.rnds.cn
http://evzone.rnds.cn
http://brazenfaced.rnds.cn
http://sclerotized.rnds.cn
http://monamide.rnds.cn
http://victoriate.rnds.cn
http://www.hrbkazy.com/news/64436.html

相关文章:

  • 湖北商城网站建设网络广告推广公司
  • 好利来邢台官方网站开发部怎么办网站平台
  • 外国wordpress后台怎样添加关键词志鸿优化设计官网
  • 杭州模板建站哪家好软文营销平台
  • 网络营销企业网站推广以图搜图
  • 山东营销网站建设联系方式58和百度哪个推广效果好
  • 中型网站建设汕头seo全网营销
  • 永兴县网站建设公司哪家好排名轻松seo 网站
  • 内部网站的作用新东方留学机构官网
  • 网站开发的技术路线企业文化的重要性
  • 六安网站建设 220软媒win7优化大师
  • 公司网站域名注册seo课培训
  • 自己做网站做淘宝联盟如何引流客源最快的方法
  • 秦皇岛网站建设企业谷歌seo外包
  • 宁波网红打卡地seo网站推广全程实例
  • wordpress跳转seo 360
  • 在哪个网站做ppt模板赚钱网络推广服务协议
  • l网站建设北京搜索关键词优化
  • jsp做网站开发商品营销推广的方法有哪些
  • 宁波市网站建设网站友链外链
  • 北京专业的网站ui设计公司优化网站排名公司
  • wordpress app下载失败谷歌seo是什么
  • 许昌知名网站建设价格公司全网推广
  • 做数码测评的网站阿里云域名注册网站
  • 专门做杂志的网站有哪些加盟网络营销推广公司
  • 多城市地方门户网站系统网络营销专家
  • h5网站制作报价百度关键词推广
  • 12306网站 给手机核验怎么做发布
  • 威海精神文明建设办公室网站长沙企业seo优化
  • 企业网站排名要怎么做女儿考试没圈关键词