Skip to content

Commit

Permalink
Update index.html
Browse files Browse the repository at this point in the history
  • Loading branch information
MajesticWafer authored Nov 12, 2024
1 parent 4a1e9b0 commit 72ab6b4
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions slots/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
0% { opacity: 1; }
100% { opacity: 0; }
}
.score {
.money {
font-size: 1.25rem;
font-weight: bold;
position: absolute;
Expand All @@ -109,7 +109,7 @@
</style>
</head>
<body>
<div class="score" id="score">Score: 0 | High Score: 0</div>
<div class="money" id="money">Money: 0</div>

<div class="controls">
<div class="control-button" onclick="toggleAudio()">
Expand Down Expand Up @@ -146,19 +146,21 @@ <h1>🎰 Slot Machine 🎰</h1>
const emojis = ["🍒", "🍋", "🍉", "🍇", "🔔", "⭐", "💎"];
const slotMachine = document.getElementById("slot-machine");
const moneyRainDiv = document.getElementById("money-rain");
const scoreDisplay = document.getElementById("score");
let score = 0;
let highScore = getCookie("highScore") || 0;
const moneyDisplay = document.getElementById("money");
let money = getCookie("savedMoney") || 0;

// Update high score
scoreDisplay.textContent = `Score: ${score} | High Score: ${highScore}`;
scoreDisplay.textContent = `Money: $${money}`;

function pullsfx() {
const sfx = document.getElementById("pull-audio");
sfx.play();
}

function spin() {
money -= 5;
updateMoney();

const slot1 = document.getElementById("slot1");
const slot2 = document.getElementById("slot2");
const slot3 = document.getElementById("slot3");
Expand All @@ -177,8 +179,8 @@ <h1>🎰 Slot Machine 🎰</h1>

if (emoji1 === emoji2 && emoji2 === emoji3) {
result.textContent = "🎉 Jackpot! 🎉";
score += 100;
updateHighScore();
money += 100;
updateMoney();
slotMachine.style.boxShadow = "0 0 20px gold";
moneyRain();
setTimeout(() => slotMachine.style.boxShadow = "", 500);
Expand All @@ -190,13 +192,13 @@ <h1>🎰 Slot Machine 🎰</h1>

setTimeout(() => spinButton.disabled = false, 800);

scoreDisplay.textContent = `Score: ${score} | High Score: ${highScore}`;
moneyDisplay.textContent = `Money: ${money}`;
}

function updateHighScore() {
if (score > highScore) {
highScore = score;
setCookie("highScore", highScore, 365);
function updateMoney() {
if (money > savedMoney) {
savedMoney = money;
setCookie("savedMoney", savedMoney, 365);
}
}

Expand Down

0 comments on commit 72ab6b4

Please sign in to comment.