用html5写一个王者荣耀英雄技能,出装计算模拟器

我来为您创建一个王者荣耀英雄技能与出装模拟器。这个模拟器将包含英雄选择、技能展示、装备搭配等功能。

<!DOCTYPE html>

<html lang="zh-CN">

<head>

<meta charset="UTF-8">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>王者荣耀英雄技能&出装模拟器</title>

<style>

* {

margin: 0;

padding: 0;

box-sizing: border-box;

}

body {

font-family: 'Microsoft YaHei', sans-serif;

background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);

min-height: 100vh;

color: #fff;

}

.container {

max-width: 1200px;

margin: 0 auto;

padding: 20px;

}

header {

text-align: center;

margin-bottom: 30px;

animation: fadeIn 1s ease-in;

}

h1 {

font-size: 2.5em;

text-shadow: 2px 2px 4px rgba(0,0,0,0.3);

margin-bottom: 10px;

}

.main-content {

display: grid;

grid-template-columns: 1fr 1fr;

gap: 30px;

animation: slideUp 0.8s ease-out;

}

@keyframes fadeIn {

from { opacity: 0; }

to { opacity: 1; }

}

@keyframes slideUp {

from {

opacity: 0;

transform: translateY(30px);

}

to {

opacity: 1;

transform: translateY(0);

}

}

.hero-section, .equipment-section {

background: rgba(255,255,255,0.1);

backdrop-filter: blur(10px);

border-radius: 15px;

padding: 25px;

box-shadow: 0 8px 32px rgba(0,0,0,0.1);

}

.hero-selector {

margin-bottom: 20px;

}

select {

width: 100%;

padding: 10px;

border-radius: 8px;

border: none;

background: rgba(255,255,255,0.9);

color: #333;

font-size: 16px;

cursor: pointer;

}

.hero-info {

display: flex;

gap: 20px;

margin-bottom: 20px;

}

.hero-avatar {

width: 120px;

height: 120px;

border-radius: 15px;

background: #ddd;

display: flex;

align-items: center;

justify-content: center;

font-size: 14px;

color: #666;

}

.hero-stats {

flex: 1;

}

.stat-item {

margin-bottom: 10px;

display: flex;

justify-content: space-between;

}

.stat-bar {

width: 150px;

height: 8px;

background: rgba(255,255,255,0.2);

border-radius: 4px;

overflow: hidden;

}

.stat-fill {

height: 100%;

background: linear-gradient(90deg, #4CAF50, #8BC34A);

transition: width 0.3s ease;

}

.skills-container {

display: grid;

grid-template-columns: repeat(4, 1fr);

gap: 15px;

margin-bottom: 20px;

}

.skill {

text-align: center;

cursor: pointer;

transition: transform 0.3s ease;

}

.skill:hover {

transform: translateY(-5px);

}

.skill-icon {

width: 70px;

height: 70px;

border-radius: 10px;

background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);

display: flex;

align-items: center;

justify-content: center;

margin: 0 auto 8px;

font-size: 24px;

box-shadow: 0 4px 15px rgba(0,0,0,0.2);

}

.skill-name {

font-size: 12px;

margin-bottom: 4px;

}

.skill-desc {

font-size: 10px;

color: rgba(255,255,255,0.7);

}

.equipment-grid {

display: grid;

grid-template-columns: repeat(3, 1fr);

gap: 15px;

margin-bottom: 20px;

}

.equipment-slot {

width: 80px;

height: 80px;

border: 2px dashed rgba(255,255,255,0.3);

border-radius: 10px;

display: flex;

align-items: center;

justify-content: center;

cursor: pointer;

transition: all 0.3s ease;

background: rgba(255,255,255,0.05);

}

.equipment-slot:hover {

border-color: rgba(255,255,255,0.6);

background: rgba(255,255,255,0.1);

}

.equipment-slot.filled {

border-style: solid;

border-color: #4CAF50;

background: rgba(76, 175, 80, 0.1);

}

.equipment-selector {

display: none;

grid-template-columns: repeat(4, 1fr);

gap: 10px;

max-height: 300px;

overflow-y: auto;

padding: 10px;

background: rgba(0,0,0,0.3);

border-radius: 10px;

margin-top: 10px;

}

.equipment-item {

width: 60px;

height: 60px;

border-radius: 8px;

background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);

display: flex;

align-items: center;

justify-content: center;

cursor: pointer;

font-size: 10px;

text-align: center;

padding: 5px;

transition: transform 0.2s ease;

}

.equipment-item:hover {

transform: scale(1.1);

}

.stats-summary {

background: rgba(0,0,0,0.2);

border-radius: 10px;

padding: 15px;

margin-top: 20px;

}

.stats-summary h3 {

margin-bottom: 10px;

color: #ffd700;

}

.summary-item {

display: flex;

justify-content: space-between;

margin-bottom: 8px;

font-size: 14px;

}

.btn-calculate {

width: 100%;

padding: 12px;

background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);

border: none;

border-radius: 8px;

color: white;

font-size: 16px;

font-weight: bold;

cursor: pointer;

transition: all 0.3s ease;

margin-top: 15px;

}

.btn-calculate:hover {

transform: translateY(-2px);

box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);

}

@media (max-width: 768px) {

.main-content {

grid-template-columns: 1fr;

}

.skills-container {

grid-template-columns: repeat(2, 1fr);

}

.equipment-grid {

grid-template-columns: repeat(3, 1fr);

}

}

</style>

</head>

<body>

<div class="container">

<header>

<h1>⚔️ 王者荣耀模拟器</h1>

<p>选择英雄,搭配装备,计算最强属性组合</p>

</header>

<main class="main-content">

<section class="hero-section">

<h2>英雄选择</h2>

<div class="hero-selector">

<select id="heroSelect">

<option value="">请选择英雄</option>

<option value="diaochan">貂蝉</option>

<option value="luban">鲁班七号</option>

<option value="zhaoyun">赵云</option>

<option value="libai">李白</option>

<option value="dianwei">典韦</option>

</select>

</div>

<div class="hero-info" id="heroInfo" style="display: none;">

<div class="hero-avatar" id="heroAvatar">英雄头像</div>

<div class="hero-stats">

<div class="stat-item">

<span>生命值:</span>

<div>

<span id="hpValue">3200</span>

<div class="stat-bar">

<div class="stat-fill" style="width: 70%"></div>

</div>

</div>

</div>

<div class="stat-item">

<span>攻击力:</span>

<div>

<span id="atkValue">180</span>

<div class="stat-bar">

<div class="stat-fill" style="width: 60%"></div>

</div>

</div>

</div>

<div class="stat-item">

<span>防御力:</span>

<div>

<span id="defValue">120</span>

<div class="stat-bar">

<div class="stat-fill" style="width: 50%"></div>

</div>

</div>

</div>

<div class="stat-item">

<span>移速:</span>

<div>

<span id="speedValue">360</span>

<div class="stat-bar">

<div class="stat-fill" style="width: 80%"></div>

</div>

</div>

</div>

</div>

</div>

<h3>技能展示</h3>

<div class="skills-container" id="skillsContainer">

<div class="skill" onclick="showSkillDetail(0)">

<div class="skill-icon">📖</div>

<div class="skill-name">被动技能</div>

<div class="skill-desc">点击选择英雄查看</div>

</div>

<div class="skill" onclick="showSkillDetail(1)">

<div class="skill-icon">✨</div>

<div class="skill-name">一技能</div>

<div class="skill-desc">点击选择英雄查看</div>

</div>

<div class="skill" onclick="showSkillDetail(2)">

<div class="skill-icon">💫</div>

<div class="skill-name">二技能</div>

<div class="skill-desc">点击选择英雄查看</div>

</div>

<div class="skill" onclick="showSkillDetail(3)">

<div class="skill-icon">🌟</div>

<div class="skill-name">大招</div>

<div class="skill-desc">点击选择英雄查看</div>

</div>

</div>

</section>

<section class="equipment-section">

<h2>装备搭配</h2>

<div class="equipment-grid" id="equipmentGrid">

<div class="equipment-slot" onclick="selectEquipment(0)">+</div>

<div class="equipment-slot" onclick="selectEquipment(1)">+</div>

<div class="equipment-slot" onclick="selectEquipment(2)">+</div>

<div class="equipment-slot" onclick="selectEquipment(3)">+</div>

<div class="equipment-slot" onclick="selectEquipment(4)">+</div>

<div class="equipment-slot" onclick="selectEquipment(5)">+</div>

</div>

<div class="equipment-selector" id="equipmentSelector">

<div class="equipment-item" onclick="equipItem('attack', 0)">破军</div>

<div class="equipment-item" onclick="equipItem('attack', 1)">无尽战刃</div>

<div class="equipment-item" onclick="equipItem('attack', 2)">宗师之力</div>

<div class="equipment-item" onclick="equipItem('attack', 3)">暗影战斧</div>

<div class="equipment-item" onclick="equipItem('defense', 4)">不祥征兆</div>

<div class="equipment-item" onclick="equipItem('defense', 5)">魔女斗篷</div>

<div class="equipment-item" onclick="equipItem('defense', 6)">反伤刺甲</div>

<div class="equipment-item" onclick="equipItem('magic', 7)">博学者之怒</div>

<div class="equipment-item" onclick="equipItem('magic', 8)">虚无法杖</div>

<div class="equipment-item" onclick="equipItem('boots', 9)">急速战靴</div>

<div class="equipment-item" onclick="equipItem('boots', 10)">抵抗之靴</div>

<div class="equipment-item" onclick="equipItem('boots', 11)">影忍之足</div>

</div>

<div class="stats-summary">

<h3>属性汇总</h3>

<div class="summary-item">

<span>总攻击力:</span>

<span id="totalAtk">0</span>

</div>

<div class="summary-item">

<span>总防御力:</span>

<span id="totalDef">0</span>

</div>

<div class="summary-item">

<span>总生命值:</span>

<span id="totalHp">0</span>

</div>

<div class="summary-item">

<span>暴击率:</span>

<span id="critRate">0%</span>

</div>

<div class="summary-item">

<span>冷却缩减:</span>

<span id="cdReduction">0%</span>

</div>

</div>

<button class="btn-calculate" onclick="calculateBuild()">计算出装效果</button>

</section>

</main>

</div>

<script>

// 英雄数据

const heroes = {

diaochan: {

name: '貂蝉',

avatar: '貂蝉',

hp: 3200,

atk: 180,

def: 120,

speed: 360,

skills: [

{ name: '语·花印', desc: '技能命中会叠加花印' },

{ name: '落·红雨', desc: '向前挥出花球并收回' },

{ name: '缘·心结', desc: '瞬间消失并立即出现在指定位置' },

{ name: '绽·风华', desc: '绽放风华,在原地结成法阵' }

]

},

luban: {

name: '鲁班七号',

avatar: '鲁班',

hp: 2800,

atk: 200,

def: 100,

speed: 340,

skills: [

{ name: '火力压制', desc: '连续第五次普攻会扫射' },

{ name: '河豚手雷', desc: '投掷河豚手雷' },

{ name: '无敌鲨嘴炮', desc: '发射火箭炮' },

{ name: '空中支援', desc: '召唤河豚飞艇轰炸' }

]

},

zhaoyun: {

name: '赵云',

avatar: '赵云',

hp: 3500,

atk: 170,

def: 150,

speed: 380,

skills: [

{ name: '龙鸣', desc: '每损失一定生命值获得免伤' },

{ name: '惊雷之龙', desc: '冲锋并强化下一次普攻' },

{ name: '破云之龙', desc: '快速刺出龙枪' },

{ name: '天翔之龙', desc: '跃向空中,冲击地面' }

]

}

};

// 装备数据

const equipment = {

0: { name: '破军', atk: 180, hp: 0, def: 0, crit: 0, cd: 0 },

1: { name: '无尽战刃', atk: 110, hp: 0, def: 0, crit: 25, cd: 0 },

2: { name: '宗师之力', atk: 100, hp: 400, def: 0, crit: 20, cd: 0 },

3: { name: '暗影战斧', atk: 85, hp: 500, def: 0, crit: 0, cd: 15 },

4: { name: '不祥征兆', atk: 0, hp: 1200, def: 270, crit: 0, cd: 0 },

5: { name: '魔女斗篷', atk: 0, hp: 1000, def: 0, crit: 0, cd: 0 },

6: { name: '反伤刺甲', atk: 40, hp: 0, def: 420, crit: 0, cd: 0 },

7: { name: '博学者之怒', atk: 240, hp: 0, def: 0, crit: 0, cd: 0 },

8: { name: '虚无法杖', atk: 160, hp: 0, def: 0, crit: 0, cd: 0 },

9: { name: '急速战靴', atk: 0, hp: 0, def: 0, crit: 0, cd: 0 },

10: { name: '抵抗之靴', atk: 0, hp: 0, def: 0, crit: 0, cd: 0 },

11: { name: '影忍之足', atk: 0, hp: 0, def: 110, crit: 0, cd: 0 }

};

let currentHero = null;

let currentEquipment = [null, null, null, null, null, null];

let selectedSlot = null;

// 英雄选择

document.getElementById('heroSelect').addEventListener('change', function(e) {

const heroKey = e.target.value;

if (heroKey && heroes[heroKey]) {

currentHero = heroes[heroKey];

displayHeroInfo();

}

});

function displayHeroInfo() {

document.getElementById('heroInfo').style.display = 'flex';

document.getElementById('heroAvatar').textContent = currentHero.avatar;

document.getElementById('hpValue').textContent = currentHero.hp;

document.getElementById('atkValue').textContent = currentHero.atk;

document.getElementById('defValue').textContent = currentHero.def;

document.getElementById('speedValue').textContent = currentHero.speed;

// 更新技能信息

const skills = document.querySelectorAll('.skill');

skills.forEach((skill, index) => {

if (currentHero.skills[index]) {

skill.querySelector('.skill-name').textContent = currentHero.skills[index].name;

skill.querySelector('.skill-desc').textContent = currentHero.skills[index].desc;

}

});

}

function showSkillDetail(index) {

if (currentHero && currentHero.skills[index]) {

alert(`技能:{currentHero.skills\[index\].name}\\n描述:{currentHero.skills[index].desc}`);

}

}

function selectEquipment(slotIndex) {

selectedSlot = slotIndex;

const selector = document.getElementById('equipmentSelector');

selector.style.display = selector.style.display === 'grid' ? 'none' : 'grid';

}

function equipItem(type, itemIndex) {

if (selectedSlot !== null) {

currentEquipment[selectedSlot] = equipment[itemIndex];

updateEquipmentDisplay();

document.getElementById('equipmentSelector').style.display = 'none';

calculateBuild();

}

}

function updateEquipmentDisplay() {

const slots = document.querySelectorAll('.equipment-slot');

slots.forEach((slot, index) => {

if (currentEquipment[index]) {

slot.textContent = currentEquipment[index].name;

slot.classList.add('filled');

} else {

slot.textContent = '+';

slot.classList.remove('filled');

}

});

}

function calculateBuild() {

let totalAtk = currentHero ? currentHero.atk : 0;

let totalDef = currentHero ? currentHero.def : 0;

let totalHp = currentHero ? currentHero.hp : 0;

let totalCrit = 0;

let totalCd = 0;

currentEquipment.forEach(item => {

if (item) {

totalAtk += item.atk;

totalDef += item.def;

totalHp += item.hp;

totalCrit += item.crit;

totalCd += item.cd;

}

});

document.getElementById('totalAtk').textContent = totalAtk;

document.getElementById('totalDef').textContent = totalDef;

document.getElementById('totalHp').textContent = totalHp;

document.getElementById('critRate').textContent = totalCrit + '%';

document.getElementById('cdReduction').textContent = totalCd + '%';

// 显示计算结果

setTimeout(() => {

alert(`出装计算完成!\n\n总攻击力:{totalAtk}\\n总防御力:{totalDef}\n总生命值:{totalHp}\\n暴击率:{totalCrit}%\n冷却缩减:${totalCd}%`);

}, 100);

}

// 点击空白处关闭装备选择器

document.addEventListener('click', function(e) {

if (!e.target.closest('.equipment-section')) {

document.getElementById('equipmentSelector').style.display = 'none';

}

});

</script>

</body>

</html>

这个王者荣耀英雄技能与出装模拟器包含以下功能:主要特性:1. 英雄选择系统下拉选择不同英雄显示英雄基础属性(生命值、攻击力、防御力、移速)可视化属性条展示2. 技能展示系统展示英雄的4个技能(被动+3个主动技能)点击技能可查看详细信息动态更新技能名称和描述3. 装备搭配系统6个装备栏位自由选择点击装备栏打开装备选择器包含攻击、防御、法术、鞋子等装备类型4. 属性计算系统实时计算出装后的总属性显示攻击力、防御力、生命值、暴击率、冷却缩减一键计算按钮提供详细汇总5. 交互体验平滑的动画效果悬停反馈响应式设计,适配移动端毛玻璃效果背景使用方法:1. 选择英雄查看基础信息和技能2. 点击装备栏选择装备3. 搭配6件装备组成完整出装4. 点击"计算出装效果"查看属性汇总5. 可以随时更换装备重新计算这个模拟器可以帮助玩家更好地理解英雄属性和装备搭配,是一个实用的游戏辅助工具。您可以根据需要扩展更多英雄和装备数据。

相关推荐
java水泥工9 天前
基于Echarts+HTML5可视化数据大屏展示-白茶大数据溯源平台V2
大数据·echarts·html5
2501_918126919 天前
用html5写王者荣耀之王者坟墓的游戏2deepseek版
个人开发
幂简集成9 天前
Realtime API 语音代理端到端接入全流程教程(含 Demo,延迟 280ms)
人工智能·个人开发
2501_918126919 天前
用html5写一个flappybird游戏
css·游戏·html5
HAH-HAH10 天前
【Python 入门】(2)Python 语言基础(变量)
开发语言·python·学习·青少年编程·个人开发·变量·python 语法
DevilSeagull12 天前
JavaScript WebAPI 指南
java·开发语言·javascript·html·ecmascript·html5
全栈技术负责人13 天前
Hybrid应用性能优化实战分享(本文iOS 与 H5为例,安卓同理)
前端·ios·性能优化·html5
Pu_Nine_913 天前
10 分钟上手 ECharts:从“能跑”到“生产级”的完整踩坑之旅
前端·javascript·echarts·css3·html5
空山新雨(大队长)14 天前
HTML第八课:HTML4和HTML5的区别
前端·html·html5