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

网站开发流程 ppt广州网络seo优化

网站开发流程 ppt,广州网络seo优化,做导购网站有哪些,j江苏省建设工程招投标网站介绍&#xff1a; 一个简单的打怪小游戏&#xff0c;点击开始游戏后&#xff0c;出现攻击按钮&#xff0c;击败怪物后可以选择继续下一关和结束游戏。 继续下一个怪兽的血量会增加5点&#xff0c;攻击按钮会随机变色。 效果图&#xff1a; html代码&#xff1a; <!DOCTYPE…

介绍:

    一个简单的打怪小游戏,点击开始游戏后,出现攻击按钮,击败怪物后可以选择继续下一关和结束游戏。

    继续下一个怪兽的血量会增加5点,攻击按钮会随机变色。

效果图:

html代码:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>打怪</title>
<link rel="stylesheet" href="../layui/css/layui.css" media="all">
<style>
/* 添加样式以中心布局两个游戏并增加一些间距 */
.game-container {text-align: center;margin: 5% auto;
}.game-container > button {margin: 0 5px; /* 添加按钮间距 */
}#result, #message {margin: 20px 0;
}</style>
</head>
<body>
<!-- 在HTML中添加开始游戏按钮 -->
<div class="game-container"><h1>打怪小游戏</h1><h2 id="monster">怪物 HP: <span id="monsterHp">10</span></h2><button id="startGameButton" class="layui-btn layui-btn-primary">开始游戏</button><button id="attackButton" class="layui-btn layui-btn-warm" style="display: none;">攻击怪物</button><button id="nextLevelButton" class="layui-btn layui-btn-normal" style="display: none;">进入下一关</button><button id="endGameButton" class="layui-btn layui-btn-danger" style="display: none;">结束游戏</button><p id="message"></p>
</div><script src="./gamejs/game.js"></script>
</body>
</html>

js代码:

document.addEventListener('DOMContentLoaded', () => {const monsterHpElement = document.getElementById('monsterHp');const messageElement = document.getElementById('message');const startGameButton = document.getElementById('startGameButton');const nextLevelButton = document.getElementById('nextLevelButton');const endGameButton = document.getElementById('endGameButton');let initialHp = 10;let monsterHp;let level = 1;const hpIncrease = 5;const attackButton = document.getElementById('attackButton');function startGame() {monsterHp = initialHp;level = 1;monsterHpElement.innerText = monsterHp;messageElement.innerText = '怪物出现了!';resetAttackButtonColor();attackButton.style.display = 'inline-block';startGameButton.style.display = 'none';}function updateMonsterStatus() {if (monsterHp > 0) {monsterHp--;monsterHpElement.innerText = monsterHp;messageElement.innerText = `怪物受到伤害!还剩 ${monsterHp} 生命值。`;} else {nextLevelButton.style.display = 'inline-block';endGameButton.style.display = 'inline-block';attackButton.style.display = 'none';messageElement.innerText = '恭喜你,打败了怪物!选择下一步操作。';}}function levelUp() {level++;monsterHp = initialHp + hpIncrease * (level - 1);monsterHpElement.innerText = monsterHp;messageElement.innerText = `第 ${level} 关开始!怪物生命值为 ${monsterHp}。`;attackButton.style.display = 'inline-block';nextLevelButton.style.display = 'none';endGameButton.style.display = 'none';changeAttackButtonColor();}function endGame() {messageElement.innerText = '游戏结束,感谢您的玩耍!点击下方按钮可以重新开始。';attackButton.style.display = 'none';nextLevelButton.style.display = 'none';endGameButton.style.display = 'none';startGameButton.style.display = 'inline-block'; // 显示开始游戏按钮}function resetAttackButtonColor() {attackButton.className = 'layui-btn layui-btn-warm'; // 这里设置默认的按钮颜色样式}function changeAttackButtonColor() {// 定义一组可能的颜色const colors = ['layui-btn-primary', 'layui-btn-normal', 'layui-btn-warm', 'layui-btn-danger'];// 随机选择一个颜色const randomColor = colors[Math.floor(Math.random() * colors.length)];attackButton.className = `layui-btn ${randomColor}`; // 更新按钮的 class 以改变颜色}startGameButton.addEventListener('click', startGame);nextLevelButton.addEventListener('click', levelUp);endGameButton.addEventListener('click', endGame);attackButton.addEventListener('click', updateMonsterStatus);
});document.addEventListener02('DOMContentLoaded', () => {const monsterHpElement = document.getElementById('monsterHp');const messageElement = document.getElementById('message');const startGameButton = document.getElementById('startGameButton');const nextLevelButton = document.getElementById('nextLevelButton');const endGameButton = document.getElementById('endGameButton');let initialHp = 10;let monsterHp;let level = 1;const hpIncrease = 5;const attackButton = document.getElementById('attackButton');function startGame() {monsterHp = initialHp;level = 1;monsterHpElement.innerText = monsterHp;messageElement.innerText = '怪物出现了!';attackButton.style.display = 'inline-block';startGameButton.style.display = 'none';}function updateMonsterStatus() {if (monsterHp > 0) {monsterHp--;monsterHpElement.innerText = monsterHp;messageElement.innerText = `怪物受到伤害!还剩 ${monsterHp} 生命值。`;} else {nextLevelButton.style.display = 'inline-block';endGameButton.style.display = 'inline-block';attackButton.style.display = 'none';messageElement.innerText = '恭喜你,打败了怪物!选择下一步操作。';}}function levelUp() {level++;monsterHp = initialHp + hpIncrease * (level - 1);monsterHpElement.innerText = monsterHp;messageElement.innerText = `第 ${level} 关开始!怪物生命值为 ${monsterHp}。`;attackButton.style.display = 'inline-block';nextLevelButton.style.display = 'none';endGameButton.style.display = 'none';}function endGame() {messageElement.innerText = '游戏结束,感谢您的玩耍!点击下方按钮可以重新开始。';attackButton.style.display = 'none';nextLevelButton.style.display = 'none';endGameButton.style.display = 'none';startGameButton.style.display = 'inline-block'; // 显示开始游戏按钮}startGameButton.addEventListener('click', startGame);nextLevelButton.addEventListener('click', levelUp);endGameButton.addEventListener('click', endGame);attackButton.addEventListener('click', updateMonsterStatus);
});

http://www.bjxfkj.com.cn/article/106283.html

相关文章:

  • 企业在什么网站推广网站推广搜索
  • 网站注册赌博违法吗网站优化名词解释
  • 网站建设申报方案上海网络推广外包
  • 网站建设 贸易seo人员的相关薪资
  • 素材下载网站开发文档seo外包公司排名
  • 网站目录怎么做301跳转关键词在线查询
  • 温州市建设监理协会网站百度云搜索引擎入口
  • 网站报价表对比表怎么做优化网站关键词排名软件
  • 网站开发什么是会话站长统计app下载
  • 做一个网站多长时间万网域名注册查询网
  • 手机网站返回按钮怎么做企业营销培训课程
  • 做网站如何变现推广方案100个
  • 手机如何做任务赚钱的网站网站项目开发流程
  • 有域名 有固定ip怎么做网站国外网站开发
  • 网络服务器安全配置操作竞赛试题温州seo服务
  • 阿里云网站备案登陆桂林seo排名
  • 下城区做网站电商网
  • 长沙企业网站制作哪家好免费奖励自己的网站
  • 计算机前端开发要学哪些软件seo标题优化裤子关键词
  • 更换网站程序营销手机都有什么功能啊
  • 透明主题wordpress百度推广seo优化
  • 服务好的微网站建设今日新闻国家大事
  • 国际贸易进出口东莞网络推广优化排名
  • 做精神科医院网站费用百度电商平台
  • 开发大型网站的最主流语言网站的建设流程
  • 企业微信小程序入口安卓优化大师老版本
  • dz做分类网站百度识图在线入口
  • 网站设计字体短视频关键词优化
  • 青海省建设厅官方网站怎样推广app别人才愿意下载
  • 整个网站建设中的关键步骤是网站注册流程