Refactor FPS counter implementation across multiple game HTML files; ensure visibility based on cookie settings and mad the binding of ick work

This commit is contained in:
miles committed 2025-04-04 14:25:01 +00:00
1 parent a16895e01a
commit cf79e3ceae
7 files changed
+88 -185

No files matched your search

@@ -277,48 +277,6 @@
frameLoop();
}
calculateFPS(); // Start FPS calculation
} else {
fpsCounter.style.display = 'none'; // Hide FPS counter
}
</script> let frames = 0;
function frameLoop() {
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(frameLoop);
}
frameLoop();
}
calculateFPS(); // Start FPS calculation
} else {
fpsCounter.style.display = 'none'; // Hide FPS counter
}
</script> let frames = 0;
function frameLoop() {
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(frameLoop);
}
frameLoop();
}
calculateFPS(); // Start FPS calculation
} else {
fpsCounter.style.display = 'none'; // Hide FPS counter
@@ -171,69 +171,6 @@
frameLoop();
}
calculateFPS(); // Start FPS calculation
} else {
fpsCounter.style.display = 'none'; // Hide FPS counter
}
</script> let frames = 0;
function frameLoop() {
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(frameLoop);
}
frameLoop();
}
calculateFPS(); // Start FPS calculation
} else {
fpsCounter.style.display = 'none'; // Hide FPS counter
}
</script> let frames = 0;
function frameLoop() {
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(frameLoop);
}
frameLoop();
}
calculateFPS(); // Start FPS calculation
} else {
fpsCounter.style.display = 'none'; // Hide FPS counter
}
</script> let frames = 0;
function frameLoop() {
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(frameLoop);
}
frameLoop();
}
calculateFPS(); // Start FPS calculation
} else {
fpsCounter.style.display = 'none'; // Hide FPS counter
@@ -375,27 +375,6 @@
frameLoop();
}
calculateFPS(); // Start FPS calculation
} else {
fpsCounter.style.display = 'none'; // Hide FPS counter
}
</script> let frames = 0;
function frameLoop() {
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(frameLoop);
}
frameLoop();
}
calculateFPS(); // Start FPS calculation
} else {
fpsCounter.style.display = 'none'; // Hide FPS counter
@@ -286,6 +286,9 @@
<div class="game-title">The Shadow Reform</div>
</a>
</div>
<div class="game">
<a href="/wedrowemdlemtest/webretro-master/webretro-master/embed/Mario-Kart-64.html">
<img src="assets/mareoc64.jpeg" alt="Mario Kart 64">
@@ -322,6 +325,10 @@
<div class="game-title">Tiny Fishing</div>
</a>
</div>
<div class="game">
<a href="games2/game/idle-breakout/index.html">
<img src="games2/assets/idle-breakout.jpg" alt="idle breakout">
@@ -1,4 +1,4 @@
<html>
</html>
<script src="/games/flach games/ruffle.js"></script>
<script src="https://unpkg.com/@ruffle-rs/ruffle"></script>
<body>
@@ -6,6 +6,7 @@
<embed src="/games/flach games/games for flach/the-binding.swf" width="1300" height="640" />
</object>
<script src="https://unpkg.com/@ruffle-rs/ruffle"></script>
</body>
</html>
<div id="fps-counter"></div>
@@ -66,25 +67,4 @@
} else {
fpsCounter.style.display = 'none'; // Hide FPS counter
}
</script> let frames = 0;
function frameLoop() {
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(frameLoop);
}
frameLoop();
}
calculateFPS(); // Start FPS calculation
} else {
fpsCounter.style.display = 'none'; // Hide FPS counter
}
</script>
</script>
@@ -43,26 +43,47 @@
}
</style>
<script>
const fpsCounter = document.getElementById("fps-counter"); // Moved this to the correct place
const fpsCounter = document.getElementById("fps-counter");
function calculateFPS() {
let lastFrameTime = performance.now();
let frames = 0;
function frameLoop() {
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;
// 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);
}
}
requestAnimationFrame(frameLoop);
return null;
}
frameLoop();
}
calculateFPS(); // Ensure the FPS calculation starts
// Check if FPS Counter is enabled
const fpsCounterEnabled = getCookie('fpsCounter') === 'true';
if (fpsCounterEnabled) {
fpsCounter.style.display = 'block'; // Show FPS counter
function calculateFPS() {
let lastFrameTime = performance.now();
let frames = 0;
function frameLoop() {
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(frameLoop);
}
frameLoop();
}
calculateFPS(); // Start FPS calculation
} else {
fpsCounter.style.display = 'none'; // Hide FPS counter
}
</script>
@@ -42,26 +42,47 @@
}
</style>
<script>
const fpsCounter = document.getElementById("fps-counter"); // Moved this to the correct place
const fpsCounter = document.getElementById("fps-counter");
function calculateFPS() {
let lastFrameTime = performance.now();
let frames = 0;
function frameLoop() {
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;
// 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);
}
}
requestAnimationFrame(frameLoop);
return null;
}
frameLoop();
}
calculateFPS(); // Ensure the FPS calculation starts
// Check if FPS Counter is enabled
const fpsCounterEnabled = getCookie('fpsCounter') === 'true';
if (fpsCounterEnabled) {
fpsCounter.style.display = 'block'; // Show FPS counter
function calculateFPS() {
let lastFrameTime = performance.now();
let frames = 0;
function frameLoop() {
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(frameLoop);
}
frameLoop();
}
calculateFPS(); // Start FPS calculation
} else {
fpsCounter.style.display = 'none'; // Hide FPS counter
}
</script>