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 b65d79a commit 4b11eaf
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 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; }
}
.currency {
.score {
font-size: 1.25rem;
font-weight: bold;
position: absolute;
Expand All @@ -109,7 +109,7 @@
</style>
</head>
<body>
<div class="currency" id="currency">Moolah: 0</div>
<div class="score" id="score">Score: 0 | High Score: 0</div>

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

// Update high score
currencyDisplay.textContent = `Moolah: ${currency}`;
scoreDisplay.textContent = `Score: ${score} | High Score: ${highScore}`;

function pullsfx() {
const sfx = document.getElementById("pull-audio");
Expand All @@ -178,8 +177,8 @@ <h1>🎰 Slot Machine 🎰</h1>

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

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

currencyDisplay.textContent = `Moolah: ${currency}`;
scoreDisplay.textContent = `Score: ${score} | High Score: ${highScore}`;
}

function updateSavedCurrency() {
if (currency > savedCurrency) {
savedCurrency = currency;
setCookie("savedCurrency", savedCurrency, 365);
function updateHighScore() {
if (score > highScore) {
highScore = score;
setCookie("highScore", highScore, 365);
}
}

Expand Down

0 comments on commit 4b11eaf

Please sign in to comment.