557 lines
18 KiB
HTML
557 lines
18 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="zh-CN">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>🧸 地狱抓娃娃机 V6 - 抓到谁就是谁! 🧸</title>
|
|
<style>
|
|
@import url('https://fonts.googleapis.com/css2?family=ZCOOL+KuaiLe&display=swap');
|
|
|
|
:root {
|
|
--machine-pink: #fd79a8;
|
|
--machine-purple: #a29bfe;
|
|
--neon-blue: #00d2ff;
|
|
--neon-pink: #ff00ff;
|
|
}
|
|
|
|
body {
|
|
margin: 0;
|
|
padding: 0;
|
|
background-color: #2d3436;
|
|
color: #fff;
|
|
font-family: 'ZCOOL KuaiLe', cursive, sans-serif;
|
|
height: 100vh;
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
justify-content: center;
|
|
overflow: hidden;
|
|
}
|
|
|
|
h1 {
|
|
font-size: 2.5rem;
|
|
color: #fff;
|
|
text-shadow: 0 0 10px var(--neon-blue), 0 0 20px var(--neon-pink);
|
|
margin-bottom: 20px;
|
|
}
|
|
|
|
/* 娃娃机主体 */
|
|
.claw-machine {
|
|
position: relative;
|
|
width: 500px;
|
|
height: 650px;
|
|
background: #34495e;
|
|
border: 15px solid #2c3e50;
|
|
border-radius: 20px;
|
|
box-shadow: 0 20px 50px rgba(0,0,0,0.5);
|
|
display: flex;
|
|
flex-direction: column;
|
|
overflow: hidden;
|
|
}
|
|
|
|
/* 玻璃展示区 */
|
|
.display-area {
|
|
position: relative;
|
|
width: 100%;
|
|
height: 450px;
|
|
background: linear-gradient(to bottom, #1e272e, #2f3542);
|
|
overflow: hidden;
|
|
border-bottom: 10px solid #2c3e50;
|
|
}
|
|
|
|
/* 天花板轨道 */
|
|
.rail {
|
|
position: absolute;
|
|
top: 10px;
|
|
left: 50px;
|
|
right: 50px;
|
|
height: 10px;
|
|
background: #7f8c8d;
|
|
border-radius: 5px;
|
|
}
|
|
|
|
/* 爪子组件 */
|
|
.claw-assembly {
|
|
position: absolute;
|
|
top: 10px;
|
|
left: 50px;
|
|
width: 60px;
|
|
transition: left 0.5s ease;
|
|
z-index: 100;
|
|
}
|
|
|
|
/* 激光射线 */
|
|
.laser-beam {
|
|
position: absolute;
|
|
top: 80px;
|
|
left: 50%;
|
|
width: 4px;
|
|
height: 0;
|
|
background: linear-gradient(to bottom, #ff0000, transparent);
|
|
transform: translateX(-50%);
|
|
z-index: 90;
|
|
display: none;
|
|
box-shadow: 0 0 10px #ff0000;
|
|
}
|
|
|
|
.laser-beam.firing {
|
|
display: block;
|
|
height: 400px;
|
|
animation: laserFlash 0.1s infinite;
|
|
}
|
|
|
|
@keyframes laserFlash {
|
|
0% { opacity: 0.8; width: 4px; }
|
|
50% { opacity: 1; width: 8px; }
|
|
100% { opacity: 0.8; width: 4px; }
|
|
}
|
|
|
|
.claw-string {
|
|
position: absolute;
|
|
top: 0;
|
|
left: 50%;
|
|
width: 4px;
|
|
height: 50px;
|
|
background: #bdc3c7;
|
|
transform: translateX(-50%);
|
|
transition: height 1s ease;
|
|
}
|
|
|
|
.claw-head {
|
|
position: absolute;
|
|
top: 50px;
|
|
left: 50%;
|
|
width: 40px;
|
|
height: 30px;
|
|
background: #ecf0f1;
|
|
transform: translateX(-50%);
|
|
border-radius: 10px 10px 0 0;
|
|
transition: top 1s ease;
|
|
}
|
|
|
|
.claw-arm {
|
|
position: absolute;
|
|
width: 10px;
|
|
height: 30px;
|
|
background: #ecf0f1;
|
|
top: 20px;
|
|
transition: transform 0.3s;
|
|
}
|
|
|
|
.arm-left { left: 0; transform-origin: top right; transform: rotate(30deg); }
|
|
.arm-right { right: 0; transform-origin: top left; transform: rotate(-30deg); }
|
|
|
|
.claw-assembly.grabbing .arm-left { transform: rotate(0deg); }
|
|
.claw-assembly.grabbing .arm-right { transform: rotate(0deg); }
|
|
|
|
/* 娃娃 (学生) */
|
|
.doll {
|
|
position: absolute;
|
|
width: 70px;
|
|
height: 70px;
|
|
border-radius: 15px;
|
|
border: 4px solid var(--neon-blue);
|
|
background: #fff;
|
|
overflow: hidden;
|
|
transition: transform 0.1s;
|
|
}
|
|
|
|
.doll img {
|
|
width: 100%;
|
|
height: 100%;
|
|
object-fit: cover;
|
|
}
|
|
|
|
/* 娃娃消失动画 */
|
|
.doll.eliminated {
|
|
animation: explode 0.5s forwards;
|
|
pointer-events: none;
|
|
}
|
|
|
|
@keyframes explode {
|
|
0% { transform: scale(1) rotate(0deg); filter: brightness(1); }
|
|
50% { transform: scale(1.5) rotate(20deg); filter: brightness(5) saturate(2); opacity: 1; }
|
|
100% { transform: scale(0) rotate(-45deg); opacity: 0; }
|
|
}
|
|
|
|
/* 瞄准红点 */
|
|
.target-dot {
|
|
position: absolute;
|
|
width: 10px;
|
|
height: 10px;
|
|
background: #ff0000;
|
|
border-radius: 50%;
|
|
box-shadow: 0 0 10px #ff0000;
|
|
display: none;
|
|
z-index: 80;
|
|
animation: blink 0.2s infinite;
|
|
}
|
|
|
|
@keyframes blink {
|
|
0% { opacity: 0; }
|
|
100% { opacity: 1; }
|
|
}
|
|
|
|
/* 操作面板 */
|
|
.control-panel {
|
|
flex-grow: 1;
|
|
background: var(--machine-pink);
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-around;
|
|
padding: 20px;
|
|
}
|
|
|
|
.joystick-base {
|
|
width: 80px;
|
|
height: 80px;
|
|
background: #c0392b;
|
|
border-radius: 50%;
|
|
position: relative;
|
|
box-shadow: inset 0 5px 10px rgba(0,0,0,0.5);
|
|
}
|
|
|
|
.joystick-stick {
|
|
width: 20px;
|
|
height: 60px;
|
|
background: #7f8c8d;
|
|
position: absolute;
|
|
bottom: 40px;
|
|
left: 30px;
|
|
border-radius: 10px;
|
|
transform-origin: bottom center;
|
|
transition: transform 0.2s;
|
|
}
|
|
|
|
.joystick-ball {
|
|
width: 40px;
|
|
height: 40px;
|
|
background: #e74c3c;
|
|
border-radius: 50%;
|
|
position: absolute;
|
|
top: -30px;
|
|
left: -10px;
|
|
box-shadow: 0 5px 0 #c0392b;
|
|
}
|
|
|
|
.btn-grab {
|
|
width: 100px;
|
|
height: 100px;
|
|
background: #f1c40f;
|
|
border: none;
|
|
border-radius: 50%;
|
|
color: #2d3436;
|
|
font-family: 'ZCOOL KuaiLe', cursive;
|
|
font-size: 1.5rem;
|
|
cursor: pointer;
|
|
box-shadow: 0 8px 0 #d4ac0d, 0 10px 20px rgba(0,0,0,0.3);
|
|
transition: all 0.1s;
|
|
}
|
|
|
|
.btn-grab:active {
|
|
transform: translateY(4px);
|
|
box-shadow: 0 4px 0 #d4ac0d;
|
|
}
|
|
|
|
.btn-grab:disabled {
|
|
background: #bdc3c7;
|
|
box-shadow: 0 4px 0 #95a5a6;
|
|
cursor: not-allowed;
|
|
}
|
|
|
|
/* 结果展示 */
|
|
#resultOverlay {
|
|
position: fixed;
|
|
top: 0; left: 0; width: 100%; height: 100%;
|
|
background: rgba(0,0,0,0.9);
|
|
display: none;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
justify-content: center;
|
|
z-index: 1000;
|
|
}
|
|
|
|
.prize-card {
|
|
background: #fff;
|
|
padding: 30px;
|
|
border-radius: 20px;
|
|
border: 10px solid var(--neon-blue);
|
|
text-align: center;
|
|
animation: bounceIn 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
|
|
}
|
|
|
|
@keyframes bounceIn {
|
|
0% { transform: scale(0); }
|
|
100% { transform: scale(1); }
|
|
}
|
|
|
|
.prize-img {
|
|
width: 250px;
|
|
height: 250px;
|
|
border-radius: 15px;
|
|
object-fit: cover;
|
|
margin-bottom: 20px;
|
|
}
|
|
|
|
.prize-name {
|
|
font-size: 3rem;
|
|
color: #2d3436;
|
|
margin-bottom: 20px;
|
|
}
|
|
|
|
#closeBtn {
|
|
padding: 10px 40px;
|
|
background: var(--neon-blue);
|
|
color: #fff;
|
|
border: none;
|
|
border-radius: 10px;
|
|
font-size: 1.5rem;
|
|
cursor: pointer;
|
|
font-family: 'ZCOOL KuaiLe', cursive;
|
|
}
|
|
|
|
/* 装饰霓虹灯 */
|
|
.neon-light {
|
|
position: absolute;
|
|
width: 100%;
|
|
height: 5px;
|
|
background: var(--neon-blue);
|
|
box-shadow: 0 0 10px var(--neon-blue);
|
|
top: 0;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
<h1>🧸 地狱抓娃娃机 V6 🧸</h1>
|
|
|
|
<div class="claw-machine">
|
|
<div class="neon-light"></div>
|
|
<div class="display-area" id="displayArea">
|
|
<div class="rail"></div>
|
|
<div class="target-dot" id="targetDot"></div>
|
|
|
|
<!-- 爪子 -->
|
|
<div class="claw-assembly" id="claw">
|
|
<div class="laser-beam" id="laserBeam"></div>
|
|
<div class="claw-string" id="clawString"></div>
|
|
<div class="claw-head" id="clawHead">
|
|
<div class="claw-arm arm-left"></div>
|
|
<div class="claw-arm arm-right"></div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 娃娃将由JS生成 -->
|
|
</div>
|
|
|
|
<div class="control-panel">
|
|
<div class="joystick-base">
|
|
<div class="joystick-stick" id="joystick">
|
|
<div class="joystick-ball"></div>
|
|
</div>
|
|
</div>
|
|
<button class="btn-grab" id="grabBtn" onclick="startGrabbing()">抓取!</button>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="resultOverlay">
|
|
<div class="prize-card">
|
|
<div style="font-size: 1.5rem; color: var(--neon-blue); margin-bottom: 10px;">恭喜抓到幸运儿!</div>
|
|
<img src="" class="prize-img" id="resultImg">
|
|
<div class="prize-name" id="resultName">???</div>
|
|
<button id="closeBtn" onclick="resetMachine()">放回去重抓</button>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
const totalStudents = 14;
|
|
const imagePath = './Result/';
|
|
const displayArea = document.getElementById('displayArea');
|
|
const dolls = [];
|
|
let isGrabbing = false;
|
|
|
|
// 音效系统
|
|
const audioCtx = new (window.AudioContext || window.webkitAudioContext)();
|
|
function playSound(freq, type, duration, vol = 0.1) {
|
|
const osc = audioCtx.createOscillator();
|
|
const gain = audioCtx.createGain();
|
|
osc.type = type;
|
|
osc.frequency.setValueAtTime(freq, audioCtx.currentTime);
|
|
gain.gain.setValueAtTime(vol, audioCtx.currentTime);
|
|
gain.gain.exponentialRampToValueAtTime(0.01, audioCtx.currentTime + duration);
|
|
osc.connect(gain);
|
|
gain.connect(audioCtx.destination);
|
|
osc.start();
|
|
osc.stop(audioCtx.currentTime + duration);
|
|
}
|
|
|
|
function init() {
|
|
for (let i = 1; i <= totalStudents; i++) {
|
|
const doll = document.createElement('div');
|
|
doll.className = 'doll';
|
|
doll.id = `doll-${i}`;
|
|
|
|
// 底部堆叠
|
|
const x = 50 + Math.random() * 330;
|
|
const y = 350 + (Math.random() - 0.5) * 30;
|
|
doll.style.left = x + 'px';
|
|
doll.style.top = y + 'px';
|
|
doll.style.transform = `rotate(${(Math.random()-0.5)*30}deg)`;
|
|
|
|
const img = document.createElement('img');
|
|
img.src = `${imagePath}${i}.png`;
|
|
img.onerror = () => img.src = 'https://via.placeholder.com/70?text=Doll';
|
|
|
|
doll.appendChild(img);
|
|
displayArea.appendChild(doll);
|
|
|
|
dolls.push({
|
|
el: doll,
|
|
id: i,
|
|
x: x,
|
|
y: y
|
|
});
|
|
}
|
|
}
|
|
|
|
async function startGrabbing() {
|
|
if (isGrabbing) return;
|
|
isGrabbing = true;
|
|
document.getElementById('grabBtn').disabled = true;
|
|
if (audioCtx.state === 'suspended') audioCtx.resume();
|
|
|
|
const claw = document.getElementById('claw');
|
|
const clawString = document.getElementById('clawString');
|
|
const clawHead = document.getElementById('clawHead');
|
|
const joystick = document.getElementById('joystick');
|
|
const laser = document.getElementById('laserBeam');
|
|
const targetDot = document.getElementById('targetDot');
|
|
|
|
// 1. 左右扫描 (制造恐慌)
|
|
const scanTimes = 3;
|
|
for(let i=0; i<scanTimes; i++) {
|
|
const scanX = 50 + Math.random() * 330;
|
|
claw.style.left = scanX + 'px';
|
|
joystick.style.transform = scanX > 200 ? 'rotate(20deg)' : 'rotate(-20deg)';
|
|
playSound(200 + i*100, 'sine', 0.3, 0.05);
|
|
|
|
// 扫描过程中随机开火
|
|
if (Math.random() > 0.4) {
|
|
await new Promise(r => setTimeout(r, 400));
|
|
await fireLaser(scanX);
|
|
}
|
|
await new Promise(r => setTimeout(r, 600));
|
|
}
|
|
|
|
// 2. 最终锁定目标
|
|
const aliveDolls = dolls.filter(d => !d.eliminated);
|
|
if (aliveDolls.length === 0) {
|
|
alert("所有人都被消灭了... 地狱之门重新开启!");
|
|
location.reload();
|
|
return;
|
|
}
|
|
|
|
const targetDoll = aliveDolls[Math.floor(Math.random() * aliveDolls.length)];
|
|
const targetX = targetDoll.x;
|
|
|
|
claw.style.left = targetX + 'px';
|
|
joystick.style.transform = targetX > 200 ? 'rotate(20deg)' : 'rotate(-20deg)';
|
|
await new Promise(r => setTimeout(r, 800));
|
|
joystick.style.transform = 'rotate(0deg)';
|
|
|
|
// 3. 下降
|
|
clawString.style.height = '350px';
|
|
clawHead.style.top = '350px';
|
|
playSound(300, 'sine', 1, 0.05);
|
|
await new Promise(r => setTimeout(r, 1000));
|
|
|
|
// 4. 抓取动作
|
|
claw.classList.add('grabbing');
|
|
playSound(150, 'square', 0.2, 0.1);
|
|
await new Promise(r => setTimeout(r, 300));
|
|
|
|
// 5. 上升
|
|
targetDoll.el.style.transition = 'top 1s ease, left 1s ease';
|
|
targetDoll.el.style.zIndex = '150';
|
|
targetDoll.el.style.top = '50px';
|
|
targetDoll.el.style.left = (targetX - 5) + 'px';
|
|
|
|
clawString.style.height = '50px';
|
|
clawHead.style.top = '50px';
|
|
await new Promise(r => setTimeout(r, 1000));
|
|
|
|
// 6. 展示结果
|
|
showResult(targetDoll.id);
|
|
}
|
|
|
|
async function fireLaser(x) {
|
|
const laser = document.getElementById('laserBeam');
|
|
const targetDot = document.getElementById('targetDot');
|
|
|
|
// 显示红点
|
|
targetDot.style.left = (x + 25) + 'px';
|
|
targetDot.style.top = '380px';
|
|
targetDot.style.display = 'block';
|
|
playSound(800, 'sine', 0.1, 0.2);
|
|
await new Promise(r => setTimeout(r, 300));
|
|
|
|
// 发射激光
|
|
laser.classList.add('firing');
|
|
playSound(100, 'sawtooth', 0.3, 0.3);
|
|
|
|
// 判定是否击中
|
|
const hitDoll = dolls.find(d => !d.eliminated && Math.abs(d.x - x) < 40);
|
|
if (hitDoll) {
|
|
hitDoll.eliminated = true;
|
|
hitDoll.el.classList.add('eliminated');
|
|
playSound(50, 'noise', 0.5, 0.5);
|
|
}
|
|
|
|
await new Promise(r => setTimeout(r, 200));
|
|
laser.classList.remove('firing');
|
|
targetDot.style.display = 'none';
|
|
}
|
|
|
|
function showResult(id) {
|
|
const overlay = document.getElementById('resultOverlay');
|
|
const img = document.getElementById('resultImg');
|
|
const name = document.getElementById('resultName');
|
|
|
|
img.src = `${imagePath}${id}.png`;
|
|
name.innerText = `玩家 ${id} 号`;
|
|
overlay.style.display = 'flex';
|
|
|
|
playSound(523, 'sine', 0.3);
|
|
setTimeout(() => playSound(659, 'sine', 0.3), 150);
|
|
setTimeout(() => playSound(783, 'sine', 0.5), 300);
|
|
}
|
|
|
|
function resetMachine() {
|
|
document.getElementById('resultOverlay').style.display = 'none';
|
|
document.getElementById('grabBtn').disabled = false;
|
|
isGrabbing = false;
|
|
|
|
const claw = document.getElementById('claw');
|
|
claw.classList.remove('grabbing');
|
|
|
|
// 重置娃娃位置
|
|
dolls.forEach(d => {
|
|
d.el.style.transition = 'none';
|
|
d.el.style.zIndex = '10';
|
|
d.el.classList.remove('eliminated');
|
|
d.eliminated = false;
|
|
const x = 50 + Math.random() * 330;
|
|
const y = 350 + (Math.random() - 0.5) * 30;
|
|
d.x = x; d.y = y;
|
|
d.el.style.left = x + 'px';
|
|
d.el.style.top = y + 'px';
|
|
d.el.style.transform = `rotate(${(Math.random()-0.5)*30}deg) scale(1)`;
|
|
d.el.style.opacity = '1';
|
|
});
|
|
}
|
|
|
|
window.onload = init;
|
|
</script>
|
|
</body>
|
|
</html>
|