Untitled
unknown
java
a month ago
4.1 kB
4
Indexable
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Simple Slot Machine</title>
<style>
body{
margin:0;
height:100vh;
display:flex;
justify-content:center;
align-items:center;
background:#1e1e1e;
font-family:Arial, sans-serif;
color:white;
}
.machine{
background:#c62828;
padding:30px;
border-radius:25px;
width:340px;
box-shadow:0 0 25px rgba(0,0,0,0.5);
text-align:center;
position:relative;
}
h1{
margin-top:0;
}
.slots{
display:flex;
justify-content:center;
gap:10px;
margin:20px 0;
}
.slot{
width:80px;
height:80px;
background:white;
color:black;
border-radius:12px;
display:flex;
justify-content:center;
align-items:center;
font-size:45px;
font-weight:bold;
}
.controls{
margin-top:20px;
display:flex;
justify-content:center;
align-items:center;
gap:25px;
}
.spin-btn{
background:gold;
border:none;
padding:15px 25px;
border-radius:12px;
font-size:18px;
font-weight:bold;
cursor:pointer;
transition:0.2s;
}
.spin-btn:hover{
transform:scale(1.05);
}
.lever-area{
display:flex;
flex-direction:column;
align-items:center;
}
.lever{
width:14px;
height:100px;
background:#999;
border-radius:10px;
position:relative;
transform-origin:top center;
transition:0.25s;
}
.lever-ball{
width:32px;
height:32px;
background:red;
border-radius:50%;
position:absolute;
bottom:-15px;
left:50%;
transform:translateX(-50%);
box-shadow:0 0 10px rgba(255,0,0,0.7);
}
.pulled{
transform:rotate(25deg);
}
.result{
margin-top:20px;
font-size:22px;
min-height:30px;
}
</style>
</head>
<body>
<div class="machine">
<h1>🎰 Slot Machine</h1>
<div class="slots">
<div class="slot" id="slot1">🍒</div>
<div class="slot" id="slot2">🍋</div>
<div class="slot" id="slot3">⭐</div>
</div>
<div class="controls">
<button class="spin-btn" onclick="spin()">SPIN</button>
<div class="lever-area">
<div class="lever" id="lever">
<div class="lever-ball"></div>
</div>
</div>
</div>
<div class="result" id="result">Press Spin!</div>
</div>
<script>
const symbols = ["🍒","🍋","⭐","💎","7️⃣","🍀"];
function randomSymbol(){
return symbols[Math.floor(Math.random() * symbols.length)];
}
function spin(){
const lever = document.getElementById("lever");
lever.classList.add("pulled");
setTimeout(() => {
lever.classList.remove("pulled");
}, 300);
const slot1 = randomSymbol();
const slot2 = randomSymbol();
const slot3 = randomSymbol();
document.getElementById("slot1").textContent = slot1;
document.getElementById("slot2").textContent = slot2;
document.getElementById("slot3").textContent = slot3;
const result = document.getElementById("result");
if(slot1 === slot2 && slot2 === slot3){
result.textContent = "🎉 JACKPOT!";
}
else if(slot1 === slot2 || slot2 === slot3 || slot1 === slot3){
result.textContent = "✨ Nice! Two matched!";
}
else{
result.textContent = "Try Again!";
}
}
</script>
</body>
</html>Editor is loading...
Leave a Comment