Files
moon-gaming/index.html
T
miles 6014fa0de9 Implement FPS Counter with Cookie Management Across Multiple Games
- Added functionality to display an FPS counter in various games based on a cookie setting.
- Introduced a utility function to retrieve cookies and check if the FPS counter is enabled.
- Updated the FPS calculation logic to start or hide the counter based on user preferences.
- Ensured consistent implementation across multiple HTML files, including games like "Bubble Game", "Basketball Legends", and others.
- Enhanced the main index and settings pages to manage FPS counter visibility and added a clock feature.
2025-04-04 13:09:41 +00:00

192 lines
7.3 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Moon Gaming</title>
<link href="https://fonts.googleapis.com/css2?family=Orbitron:wght@700&family=Press+Start+2P&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css" integrity="sha512-z3gLpd7yknf1YoNbCzqRKc4qyor8gaKU1qmn+CShxbuBusANI9QpRohGBreCFkKxLhei6S9CQXFEbbKuqLg0DA==" crossorigin="anonymous" referrerpolicy="no-referrer">
<style>
:root {
--background-color-dark: #0d0d0d;
--text-color-dark: #00ffcc;
--button-bg-dark: #1a1a1a;
--button-hover-bg-dark: #00ffcc;
--button-hover-text-dark: #0d0d0d;
--background-color-light: #ffffff;
--text-color-light: #333333;
--button-bg-light: #f0f0f0;
--button-hover-bg-light: #333333;
--button-hover-text-light: #ffffff;
}
body {
background-color: var(--background-color);
color: var(--text-color);
font-family: 'Orbitron', sans-serif;
margin: 0;
padding: 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
overflow: hidden;
transition: background-color 0.3s, color 0.3s;
}
h1 {
font-size: 3rem;
text-transform: uppercase;
animation: glow 1.5s infinite alternate;
}
@keyframes glow {
from {
text-shadow: 0 0 10px var(--text-color), 0 0 20px var(--text-color), 0 0 30px var(--text-color), 0 0 40px var(--text-color);
}
to {
text-shadow: 0 0 20px var(--text-color), 0 0 30px var(--text-color), 0 0 40px var(--text-color), 0 0 50px var(--text-color);
}
}
.button-container {
display: flex;
gap: 20px;
margin-top: 20px;
}
.button {
padding: 15px 30px;
font-size: 1.2rem;
font-family: 'Press Start 2P', cursive;
color: var(--text-color);
background-color: var(--button-bg);
border: 2px solid var(--text-color);
border-radius: 5px;
cursor: pointer;
text-transform: uppercase;
transition: background-color 0.3s, color 0.3s, transform 0.2s;
}
.button:hover {
background-color: var(--button-hover-bg);
color: var(--button-hover-text);
transform: scale(1.1);
}
.button:active {
transform: scale(0.95);
}
</style>
</head>
<body>
<div id="clock" style="font-size: 1.5rem; margin-top: 10px; font-family: 'Orbitron', sans-serif; color: var(--text-color); display: none;"></div>
<h1>Moon Gaming</h1>
<div class="button-container">
<button class="button" onclick="location.href='setting.html'">Settings</button>
<button class="button" onclick="location.href='./WebGames-master/WebGames-master/index.html'">Games</button>
</div>
<script>
// Utility function to set a cookie
function setCookie(name, value, days) {
const date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
document.cookie = `${name}=${value};expires=${date.toUTCString()};path=/`;
}
// Utility function to get a cookie
function getCookie(name) {
const cookies = document.cookie.split(';');
for (let i = 0; i < cookies.length; i++) {
const cookie = cookies[i].trim();
if (cookie.startsWith(name + '=')) {
return cookie.substring(name.length + 1);
}
}
return null;
}
// Apply dark or light mode based on cookie
function applyDarkMode(enabled) {
if (enabled) {
document.body.style.setProperty('--background-color', 'var(--background-color-dark)');
document.body.style.setProperty('--text-color', 'var(--text-color-dark)');
document.body.style.setProperty('--button-bg', 'var(--button-bg-dark)');
document.body.style.setProperty('--button-hover-bg', 'var(--button-hover-bg-dark)');
document.body.style.setProperty('--button-hover-text', 'var(--button-hover-text-dark)');
} else {
document.body.style.setProperty('--background-color', 'var(--background-color-light)');
document.body.style.setProperty('--text-color', 'var(--text-color-light)');
document.body.style.setProperty('--button-bg', 'var(--button-bg-light)');
document.body.style.setProperty('--button-hover-bg', 'var(--button-hover-bg-light)');
document.body.style.setProperty('--button-hover-text', 'var(--button-hover-text-light)');
}
}
// Ensure dark mode is the default
if (getCookie('darkMode') === null) {
setCookie('darkMode', 'true', 30); // Default to dark mode
}
// Apply saved mode on load
const darkModeEnabled = getCookie('darkMode') === 'true';
applyDarkMode(darkModeEnabled);
// Clock Functionality
function updateClock() {
const now = new Date();
const hours = String(now.getHours()).padStart(2, '0');
const minutes = String(now.getMinutes()).padStart(2, '0');
const seconds = String(now.getSeconds()).padStart(2, '0');
const timeString = `${hours}:${minutes}:${seconds}`;
const dateString = now.toDateString(); // Get the current date as a string
document.getElementById('clock').innerHTML = `${dateString} <br> ${timeString}`;
}
// Update the clock every second
setInterval(updateClock, 1000);
updateClock(); // Initialize clock immediately
// Ensure FPS Counter is enabled by default
if (getCookie('fpsCounter') === null) {
setCookie('fpsCounter', 'true', 30); // Default to enabled
}
// Check if FPS Counter is enabled
const fpsCounterEnabled = getCookie('fpsCounter') === 'true';
if (fpsCounterEnabled) {
const fpsCounter = document.getElementById('fpsCounter');
let lastFrameTime = performance.now();
let frames = 0;
function calculateFPS() {
const now = performance.now();
frames++;
if (now - lastFrameTime >= 1000) {
const fps = Math.round(frames / ((now - lastFrameTime) / 1000));
fpsCounter.textContent = `FPS: ${fps}`;
frames = 0;
lastFrameTime = now;
}
requestAnimationFrame(calculateFPS);
}
calculateFPS(); // Start FPS calculation
}
// Check if Date and Time is enabled
const dateTimeEnabled = getCookie('dateTime') === 'true';
if (dateTimeEnabled) {
document.getElementById('clock').style.display = 'block'; // Show the clock
}
</script>
</body>
</html>