formatted like my Boss wants it (help!)

This commit is contained in:
sageTheDM 2025-02-25 10:04:34 +01:00
parent 5d11f87dd3
commit b507a6b0ea
19 changed files with 1425 additions and 1136 deletions

View file

@ -22,7 +22,9 @@ document.addEventListener("DOMContentLoaded", () => {
const burgerMenu = document.querySelector(".burger-menu");
if (!menu || !burgerMenu) {
console.warn("Menu or burger menu element not found. Ensure they exist in the DOM.");
console.warn(
"Menu or burger menu element not found. Ensure they exist in the DOM."
);
return;
}
@ -41,7 +43,10 @@ document.addEventListener("DOMContentLoaded", () => {
// Close the menu if clicking outside of it
function closeMenu(event) {
if (!menu.contains(event.target) && !event.target.classList.contains("burger-menu")) {
if (
!menu.contains(event.target) &&
!event.target.classList.contains("burger-menu")
) {
menu.classList.remove("active");
document.removeEventListener("click", closeMenu);
}

View file

@ -37,17 +37,16 @@ class Footer extends HTMLElement {
`;
// Add event listener for button click
this.querySelector('.secret-button').addEventListener('click', () => {
window.open('secret/index.html', '_blank');
this.querySelector(".secret-button").addEventListener("click", () => {
window.open("secret/index.html", "_blank");
});
}
}
customElements.define('footer-component', Footer);
customElements.define("footer-component", Footer);
// CSS for the hidden button
const style = document.createElement('style');
const style = document.createElement("style");
style.textContent = `
.secret-button {
display: none;

View file

@ -42,5 +42,5 @@ class Header extends HTMLElement {
}
}
customElements.define('header-component', Header);
customElements.define("header-component", Header);
// @license-end

View file

@ -1,7 +1,7 @@
"use strict";
// Canvas setup
const canvas = document.getElementById('gameCanvas');
const ctx = canvas.getContext('2d');
const canvas = document.getElementById("gameCanvas");
const ctx = canvas.getContext("2d");
const targetFPS = 60;
const targetFrameTime = 1000 / targetFPS;
canvas.width = window.innerWidth;
@ -15,9 +15,9 @@ const player = {
y: canvas.height - 60,
width: 40,
height: 40,
color: 'white',
color: "white",
speed: 5,
dx: 0
dx: 0,
};
let bullets = [];
@ -48,7 +48,7 @@ let greenSphereCooldown = 0;
let rainbowSphereCooldown = 0;
// Sphere types
const sphereTypes = ['blue', 'yellow', 'green', 'rainbow'];
const sphereTypes = ["blue", "yellow", "green", "rainbow"];
/// Control for left button press and release
function btnMoveLeft(isPressed) {
@ -76,31 +76,36 @@ function btnMoveRight(isPressed) {
}
}
document.getElementById('shootBtn').addEventListener('mouseup', () => {
document.getElementById("shootBtn").addEventListener("mouseup", () => {
canShoot = true; // Allow shooting again when button is released
});
window.addEventListener('keydown', (e) => {
if (e.key === 'ArrowLeft' || e.key === 'a') player.dx = -player.speed;
if (e.key === 'ArrowRight' || e.key === 'd') player.dx = player.speed;
window.addEventListener("keydown", (e) => {
if (e.key === "ArrowLeft" || e.key === "a") player.dx = -player.speed;
if (e.key === "ArrowRight" || e.key === "d") player.dx = player.speed;
// Shoot only if it's not a hold, and we can shoot
if (e.key === ' ' && canShoot && !isGameOver) {
if (e.key === " " && canShoot && !isGameOver) {
shootBullet();
canShoot = false; // Prevent shooting until the key is released
}
if (e.key === 'r' && isGameOver) restartGame();
if (e.key === "r" && isGameOver) restartGame();
});
window.addEventListener('keyup', (e) => {
window.addEventListener("keyup", (e) => {
// Stop moving when either the arrow keys or the 'a'/'d' keys are released
if (e.key === 'ArrowLeft' || e.key === 'ArrowRight' || e.key === 'a' || e.key === 'd') {
if (
e.key === "ArrowLeft" ||
e.key === "ArrowRight" ||
e.key === "a" ||
e.key === "d"
) {
player.dx = 0;
}
// Allow shooting again when the space key is released
if (e.key === ' ') {
if (e.key === " ") {
canShoot = true;
}
});
@ -124,8 +129,8 @@ function shootBullet() {
y: player.y,
width: 5,
height: 10,
color: 'yellow',
speed: 7
color: "yellow",
speed: 7,
});
}, i * 50); // Fire bullets with 50ms delay between shots
}
@ -137,9 +142,9 @@ function shootBullet() {
y: player.y,
width: 5,
height: 10,
color: 'yellow',
color: "yellow",
speed: 7,
angle: i * 10 // Spray the bullets at different angles
angle: i * 10, // Spray the bullets at different angles
});
}
} else {
@ -149,15 +154,15 @@ function shootBullet() {
y: player.y,
width: 5,
height: 10,
color: 'yellow',
speed: 7
color: "yellow",
speed: 7,
});
}
}
// Generate random color
function getRandomColor() {
const colors = ['red', 'blue', 'green', 'orange', 'purple', 'pink'];
const colors = ["red", "blue", "green", "orange", "purple", "pink"];
return colors[Math.floor(Math.random() * colors.length)];
}
@ -170,13 +175,14 @@ function createAsteroid() {
width: size,
height: size,
color: getRandomColor(),
speed: (Math.random() * 3 + 2) * asteroidSpeedMultiplier // Faster initial speed
speed: (Math.random() * 3 + 2) * asteroidSpeedMultiplier, // Faster initial speed
});
}
// Item mechanics
function createItem() {
const randomType = sphereTypes[Math.floor(Math.random() * sphereTypes.length)];
const randomType =
sphereTypes[Math.floor(Math.random() * sphereTypes.length)];
const size = 30;
const x = Math.random() * canvas.width;
items.push({
@ -185,8 +191,15 @@ function createItem() {
width: size,
height: size,
type: randomType,
color: randomType === 'blue' ? 'blue' : randomType === 'yellow' ? 'yellow' : randomType === 'green' ? 'green' : 'rainbow',
speed: 3
color:
randomType === "blue"
? "blue"
: randomType === "yellow"
? "yellow"
: randomType === "green"
? "green"
: "rainbow",
speed: 3,
});
}
@ -194,7 +207,8 @@ function createItem() {
function updatePlayer() {
player.x += player.dx;
if (player.x < 0) player.x = 0;
if (player.x + player.width > canvas.width) player.x = canvas.width - player.width;
if (player.x + player.width > canvas.width)
player.x = canvas.width - player.width;
}
function updateBullets() {
@ -230,15 +244,15 @@ function updateItems() {
function applyItemEffect(type) {
let points = Math.floor(Math.random() * 5) + 1; // Random points between 1 and 5
if (type === 'blue') {
if (type === "blue") {
rapidFireActive = true;
setTimeout(() => rapidFireActive = false, 15000); // 15 seconds of rapid fire
} else if (type === 'yellow') {
setTimeout(() => (rapidFireActive = false), 15000); // 15 seconds of rapid fire
} else if (type === "yellow") {
shotgunActive = true;
setTimeout(() => shotgunActive = false, 30000); // 30 seconds of shotgun
} else if (type === 'green') {
setTimeout(() => (shotgunActive = false), 30000); // 30 seconds of shotgun
} else if (type === "green") {
ammo = 100; // Refill ammo
} else if (type === 'rainbow') {
} else if (type === "rainbow") {
rapidFireActive = true;
shotgunActive = true;
setTimeout(() => {
@ -282,7 +296,7 @@ function checkCollisions() {
// Explosion effect
function createExplosion(x, y) {
ctx.fillStyle = 'yellow';
ctx.fillStyle = "yellow";
ctx.beginPath();
ctx.arc(x, y, 20, 0, Math.PI * 2);
ctx.fill();
@ -313,33 +327,47 @@ function drawItems() {
items.forEach((item) => {
ctx.fillStyle = item.color;
ctx.beginPath();
ctx.arc(item.x + item.width / 2, item.y + item.height / 2, item.width / 2, 0, Math.PI * 2);
ctx.arc(
item.x + item.width / 2,
item.y + item.height / 2,
item.width / 2,
0,
Math.PI * 2
);
ctx.fill();
});
}
function drawScore() {
ctx.fillStyle = 'white';
ctx.font = '24px Arial';
ctx.fillStyle = "white";
ctx.font = "24px Arial";
ctx.fillText(`Score: ${score}`, 20, 40); // Score at top-left corner
}
function drawAmmo() {
ctx.fillStyle = 'white';
ctx.font = '24px Arial';
ctx.fillStyle = "white";
ctx.font = "24px Arial";
ctx.fillText(`Ammo: ${ammo}`, 20, 70); // Ammo at top-left corner
}
function drawGameOver() {
if (isGameOver) {
ctx.fillStyle = 'white';
ctx.font = '40px Arial';
ctx.textAlign = 'center';
ctx.fillText('Game Over!', canvas.width / 2, canvas.height / 2 - 40);
ctx.font = '24px Arial';
ctx.fillStyle = "white";
ctx.font = "40px Arial";
ctx.textAlign = "center";
ctx.fillText("Game Over!", canvas.width / 2, canvas.height / 2 - 40);
ctx.font = "24px Arial";
ctx.fillText(`Total Score: ${score}`, canvas.width / 2, canvas.height / 2);
ctx.fillText(`Bullets Fired: ${totalBulletsFired}`, canvas.width / 2, canvas.height / 2 + 40);
ctx.fillText('Press "R" to Restart', canvas.width / 2, canvas.height / 2 + 80);
ctx.fillText(
`Bullets Fired: ${totalBulletsFired}`,
canvas.width / 2,
canvas.height / 2 + 40
);
ctx.fillText(
'Press "R" to Restart',
canvas.width / 2,
canvas.height / 2 + 80
);
}
}

View file

@ -44,7 +44,9 @@ html {
max-width: 600px; /* Limit the width of the content */
position: relative;
color: white;
backdrop-filter: blur(8px); /* Ensure content has some blur as well for contrast */
backdrop-filter: blur(
8px
); /* Ensure content has some blur as well for contrast */
}
h1 {

View file

@ -34,10 +34,15 @@ export default function EndlessRunner() {
if (Math.random() < 0.02) {
obstacles.push({ x: canvas.width, y: 150, width: 20, height: 20 });
}
obstacles = obstacles.map(obstacle => ({ ...obstacle, x: obstacle.x - 5 }));
obstacles = obstacles.filter(obstacle => obstacle.x + obstacle.width > 0);
obstacles = obstacles.map((obstacle) => ({
...obstacle,
x: obstacle.x - 5,
}));
obstacles = obstacles.filter(
(obstacle) => obstacle.x + obstacle.width > 0
);
obstacles.forEach(obstacle => {
obstacles.forEach((obstacle) => {
ctx.fillStyle = "red";
ctx.fillRect(obstacle.x, obstacle.y, obstacle.width, obstacle.height);
@ -72,7 +77,14 @@ export default function EndlessRunner() {
return (
<div className="flex flex-col items-center">
<canvas ref={canvasRef} className="border" onClick={jump}></canvas>
{!running && <button onClick={() => window.location.reload()} className="mt-4 bg-blue-500 text-white px-4 py-2 rounded">Restart</button>}
{!running && (
<button
onClick={() => window.location.reload()}
className="mt-4 bg-blue-500 text-white px-4 py-2 rounded"
>
Restart
</button>
)}
</div>
);
}

View file

@ -1,7 +1,7 @@
"use strict";
// Canvas setup
const canvas = document.getElementById('gameCanvas');
const ctx = canvas.getContext('2d');
const canvas = document.getElementById("gameCanvas");
const ctx = canvas.getContext("2d");
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
@ -11,9 +11,9 @@ const player = {
y: canvas.height - 60,
width: 40,
height: 40,
color: 'white',
color: "white",
speed: 5,
dx: 0
dx: 0,
};
let bullets = [];
@ -44,7 +44,7 @@ let greenSphereCooldown = 0;
let rainbowSphereCooldown = 0;
// Sphere types
const sphereTypes = ['blue', 'yellow', 'green', 'rainbow'];
const sphereTypes = ["blue", "yellow", "green", "rainbow"];
/// Control for left button press and release
function btnMoveLeft(isPressed) {
@ -72,31 +72,36 @@ function btnMoveRight(isPressed) {
}
}
document.getElementById('shootBtn').addEventListener('mouseup', () => {
document.getElementById("shootBtn").addEventListener("mouseup", () => {
canShoot = true; // Allow shooting again when button is released
});
window.addEventListener('keydown', (e) => {
if (e.key === 'ArrowLeft' || e.key === 'a') player.dx = -player.speed;
if (e.key === 'ArrowRight' || e.key === 'd') player.dx = player.speed;
window.addEventListener("keydown", (e) => {
if (e.key === "ArrowLeft" || e.key === "a") player.dx = -player.speed;
if (e.key === "ArrowRight" || e.key === "d") player.dx = player.speed;
// Shoot only if it's not a hold, and we can shoot
if (e.key === ' ' && canShoot && !isGameOver) {
if (e.key === " " && canShoot && !isGameOver) {
shootBullet();
canShoot = false; // Prevent shooting until the key is released
}
if (e.key === 'r' && isGameOver) restartGame();
if (e.key === "r" && isGameOver) restartGame();
});
window.addEventListener('keyup', (e) => {
window.addEventListener("keyup", (e) => {
// Stop moving when either the arrow keys or the 'a'/'d' keys are released
if (e.key === 'ArrowLeft' || e.key === 'ArrowRight' || e.key === 'a' || e.key === 'd') {
if (
e.key === "ArrowLeft" ||
e.key === "ArrowRight" ||
e.key === "a" ||
e.key === "d"
) {
player.dx = 0;
}
// Allow shooting again when the space key is released
if (e.key === ' ') {
if (e.key === " ") {
canShoot = true;
}
});
@ -120,8 +125,8 @@ function shootBullet() {
y: player.y,
width: 5,
height: 10,
color: 'yellow',
speed: 7
color: "yellow",
speed: 7,
});
}, i * 50); // Fire bullets with 50ms delay between shots
}
@ -133,9 +138,9 @@ function shootBullet() {
y: player.y,
width: 5,
height: 10,
color: 'yellow',
color: "yellow",
speed: 7,
angle: i * 10 // Spray the bullets at different angles
angle: i * 10, // Spray the bullets at different angles
});
}
} else {
@ -145,15 +150,15 @@ function shootBullet() {
y: player.y,
width: 5,
height: 10,
color: 'yellow',
speed: 7
color: "yellow",
speed: 7,
});
}
}
// Generate random color
function getRandomColor() {
const colors = ['red', 'blue', 'green', 'orange', 'purple', 'pink'];
const colors = ["red", "blue", "green", "orange", "purple", "pink"];
return colors[Math.floor(Math.random() * colors.length)];
}
@ -166,13 +171,14 @@ function createAsteroid() {
width: size,
height: size,
color: getRandomColor(),
speed: (Math.random() * 3 + 2) * asteroidSpeedMultiplier // Faster initial speed
speed: (Math.random() * 3 + 2) * asteroidSpeedMultiplier, // Faster initial speed
});
}
// Item mechanics
function createItem() {
const randomType = sphereTypes[Math.floor(Math.random() * sphereTypes.length)];
const randomType =
sphereTypes[Math.floor(Math.random() * sphereTypes.length)];
const size = 30;
const x = Math.random() * canvas.width;
items.push({
@ -181,8 +187,15 @@ function createItem() {
width: size,
height: size,
type: randomType,
color: randomType === 'blue' ? 'blue' : randomType === 'yellow' ? 'yellow' : randomType === 'green' ? 'green' : 'rainbow',
speed: 3
color:
randomType === "blue"
? "blue"
: randomType === "yellow"
? "yellow"
: randomType === "green"
? "green"
: "rainbow",
speed: 3,
});
}
@ -190,7 +203,8 @@ function createItem() {
function updatePlayer() {
player.x += player.dx;
if (player.x < 0) player.x = 0;
if (player.x + player.width > canvas.width) player.x = canvas.width - player.width;
if (player.x + player.width > canvas.width)
player.x = canvas.width - player.width;
}
function updateBullets() {
@ -226,15 +240,15 @@ function updateItems() {
function applyItemEffect(type) {
let points = Math.floor(Math.random() * 5) + 1; // Random points between 1 and 5
if (type === 'blue') {
if (type === "blue") {
rapidFireActive = true;
setTimeout(() => rapidFireActive = false, 15000); // 15 seconds of rapid fire
} else if (type === 'yellow') {
setTimeout(() => (rapidFireActive = false), 15000); // 15 seconds of rapid fire
} else if (type === "yellow") {
shotgunActive = true;
setTimeout(() => shotgunActive = false, 30000); // 30 seconds of shotgun
} else if (type === 'green') {
setTimeout(() => (shotgunActive = false), 30000); // 30 seconds of shotgun
} else if (type === "green") {
ammo = 100; // Refill ammo
} else if (type === 'rainbow') {
} else if (type === "rainbow") {
rapidFireActive = true;
shotgunActive = true;
setTimeout(() => {
@ -278,7 +292,7 @@ function checkCollisions() {
// Explosion effect
function createExplosion(x, y) {
ctx.fillStyle = 'yellow';
ctx.fillStyle = "yellow";
ctx.beginPath();
ctx.arc(x, y, 20, 0, Math.PI * 2);
ctx.fill();
@ -309,33 +323,47 @@ function drawItems() {
items.forEach((item) => {
ctx.fillStyle = item.color;
ctx.beginPath();
ctx.arc(item.x + item.width / 2, item.y + item.height / 2, item.width / 2, 0, Math.PI * 2);
ctx.arc(
item.x + item.width / 2,
item.y + item.height / 2,
item.width / 2,
0,
Math.PI * 2
);
ctx.fill();
});
}
function drawScore() {
ctx.fillStyle = 'white';
ctx.font = '24px Arial';
ctx.fillStyle = "white";
ctx.font = "24px Arial";
ctx.fillText(`Score: ${score}`, 20, 40); // Score at top-left corner
}
function drawAmmo() {
ctx.fillStyle = 'white';
ctx.font = '24px Arial';
ctx.fillStyle = "white";
ctx.font = "24px Arial";
ctx.fillText(`Ammo: ${ammo}`, 20, 70); // Ammo at top-left corner
}
function drawGameOver() {
if (isGameOver) {
ctx.fillStyle = 'white';
ctx.font = '40px Arial';
ctx.textAlign = 'center';
ctx.fillText('Game Over!', canvas.width / 2, canvas.height / 2 - 40);
ctx.font = '24px Arial';
ctx.fillStyle = "white";
ctx.font = "40px Arial";
ctx.textAlign = "center";
ctx.fillText("Game Over!", canvas.width / 2, canvas.height / 2 - 40);
ctx.font = "24px Arial";
ctx.fillText(`Total Score: ${score}`, canvas.width / 2, canvas.height / 2);
ctx.fillText(`Bullets Fired: ${totalBulletsFired}`, canvas.width / 2, canvas.height / 2 + 40);
ctx.fillText('Press "R" to Restart', canvas.width / 2, canvas.height / 2 + 80);
ctx.fillText(
`Bullets Fired: ${totalBulletsFired}`,
canvas.width / 2,
canvas.height / 2 + 40
);
ctx.fillText(
'Press "R" to Restart',
canvas.width / 2,
canvas.height / 2 + 80
);
}
}

View file

@ -1,54 +1,65 @@
'use strict';
"use strict";
const targetNum = Math.trunc(Math.random() * 20) + 1;
let highScore = Number(localStorage.getItem('highscore')) || 0;
let highScore = Number(localStorage.getItem("highscore")) || 0;
let userGuess = 10; // Default guess
let currScore = 20;
const screenEl = document.querySelector('.screen');
const msgEl = document.querySelector('.message');
const guessInput = document.querySelector('#guess');
const scoreEl = document.querySelector('.score');
const highScoreEl = document.querySelector('.highScore');
const checkBtn = document.querySelector('#check');
const restartBtn = document.querySelector('#restart');
const incBtn = document.querySelector('#up');
const decBtn = document.querySelector('#down');
const screenEl = document.querySelector(".screen");
const msgEl = document.querySelector(".message");
const guessInput = document.querySelector("#guess");
const scoreEl = document.querySelector(".score");
const highScoreEl = document.querySelector(".highScore");
const checkBtn = document.querySelector("#check");
const restartBtn = document.querySelector("#restart");
const incBtn = document.querySelector("#up");
const decBtn = document.querySelector("#down");
const setMsg = msg => msgEl.textContent = msg;
const setScore = score => scoreEl.textContent = `Score: ${currScore = score}`;
const setMsg = (msg) => (msgEl.textContent = msg);
const setScore = (score) =>
(scoreEl.textContent = `Score: ${(currScore = score)}`);
const setHighScore = () => {
highScoreEl.textContent = `Highscore: ${highScore}`;
localStorage.setItem('highscore', highScore);
localStorage.setItem("highscore", highScore);
};
const changeColor = color => screenEl.style.backgroundColor = color;
const changeColor = (color) => (screenEl.style.backgroundColor = color);
checkBtn.addEventListener('click', () => {
checkBtn.addEventListener("click", () => {
userGuess = Number(guessInput.textContent);
if (!userGuess || userGuess < 1 || userGuess > 20) {
setMsg("Please enter a valid number between 1 and 20.");
} else if (userGuess === targetNum) {
highScore = Math.max(highScore, currScore);
setHighScore();
setMsg(currScore !== 20 ? 'Correct Number!' : 'Are you sure you didn\'t cheat?');
changeColor(currScore !== 20 ? '#1ba100' : '#FFC300');
setMsg(
currScore !== 20 ? "Correct Number!" : "Are you sure you didn't cheat?"
);
changeColor(currScore !== 20 ? "#1ba100" : "#FFC300");
} else {
setMsg(userGuess > targetNum ? 'Too High!' : 'Too Low!');
setMsg(userGuess > targetNum ? "Too High!" : "Too Low!");
if (currScore > 1) {
setScore(currScore - 1);
} else {
setScore(1);
setMsg("You lost the game!");
changeColor('#a10000');
changeColor("#a10000");
}
}
});
restartBtn.addEventListener('click', () => location.reload());
incBtn.addEventListener('click', () => guessInput.textContent = Math.min(Number(guessInput.textContent) + 1, 20));
decBtn.addEventListener('click', () => guessInput.textContent = Math.max(Number(guessInput.textContent) - 1, 1));
restartBtn.addEventListener("click", () => location.reload());
incBtn.addEventListener(
"click",
() =>
(guessInput.textContent = Math.min(Number(guessInput.textContent) + 1, 20))
);
decBtn.addEventListener(
"click",
() =>
(guessInput.textContent = Math.max(Number(guessInput.textContent) - 1, 1))
);
guessInput.textContent = userGuess;
setMsg('Guess a number');
setMsg("Guess a number");
setScore(currScore);
setHighScore();

View file

@ -1,30 +1,116 @@
'use strict';
const left = document.querySelector('#left');
const right = document.querySelector('#right');
const gameboy = document.querySelector('.gameboy');
"use strict";
const left = document.querySelector("#left");
const right = document.querySelector("#right");
const gameboy = document.querySelector(".gameboy");
const html = document.documentElement;
const body = document.body;
const screen = document.querySelector('.screen');
const dpadButtons = document.querySelectorAll('.dpad-btn');
const dpadCenter = document.querySelector('.dpad-center'); // Darker variant
const actionButtons = document.querySelectorAll('.btn');
const screen = document.querySelector(".screen");
const dpadButtons = document.querySelectorAll(".dpad-btn");
const dpadCenter = document.querySelector(".dpad-center"); // Darker variant
const actionButtons = document.querySelectorAll(".btn");
const colors = [
{ gameboyColor: '#B39DDB', htmlColor: '#D1C4E9', screenColor: '#E1BEE7', buttonColor: '#673AB7', buttonTextColor: '#FFFFFF', dpadCenterColor: '#5E35B1' },
{ gameboyColor: '#FFC107', htmlColor: '#FFF9C4', screenColor: '#FFEB3B', buttonColor: '#FF9800', buttonTextColor: '#000000', dpadCenterColor: '#EF6C00' },
{ gameboyColor: '#8BC34A', htmlColor: '#C5E1A5', screenColor: '#A5D6A7', buttonColor: '#FF5722', buttonTextColor: '#FFFFFF', dpadCenterColor: '#E64A19' },
{ gameboyColor: '#F44336', htmlColor: '#FFCDD2', screenColor: '#EF9A9A', buttonColor: '#E91E63', buttonTextColor: '#FFFFFF', dpadCenterColor: '#C2185B' },
{ gameboyColor: '#03A9F4', htmlColor: '#BBDEFB', screenColor: '#90CAF9', buttonColor: '#FFEB3B', buttonTextColor: '#000000', dpadCenterColor: '#0277BD' },
{ gameboyColor: '#FF7043', htmlColor: '#FFCCBC', screenColor: '#FFAB91', buttonColor: '#FF5722', buttonTextColor: '#FFFFFF', dpadCenterColor: '#D84315' },
{ gameboyColor: '#9C27B0', htmlColor: '#E1BEE7', screenColor: '#D1C4E9', buttonColor: '#7B1FA2', buttonTextColor: '#FFFFFF', dpadCenterColor: '#6A1B9A' },
{ gameboyColor: '#FFD700', htmlColor: '#FFF9C4', screenColor: '#FFF59D', buttonColor: '#FF9800', buttonTextColor: '#FFFFFF', dpadCenterColor: '#F57F17' },
{ gameboyColor: '#009688', htmlColor: '#B2DFDB', screenColor: '#80CBC4', buttonColor: '#4CAF50', buttonTextColor: '#FFFFFF', dpadCenterColor: '#00796B' },
{ gameboyColor: '#795548', htmlColor: '#D7CCC8', screenColor: '#A1887F', buttonColor: '#9E9E9E', buttonTextColor: '#000000', dpadCenterColor: '#5D4037' },
{ gameboyColor: '#FF5733', htmlColor: '#FFCCCB', screenColor: '#FFABAB', buttonColor: '#C70039', buttonTextColor: '#FFFFFF', dpadCenterColor: '#B71C1C' },
{ gameboyColor: '#00BCD4', htmlColor: '#B2EBF2', screenColor: '#80DEEA', buttonColor: '#00ACC1', buttonTextColor: '#FFFFFF', dpadCenterColor: '#00838F' }
{
gameboyColor: "#B39DDB",
htmlColor: "#D1C4E9",
screenColor: "#E1BEE7",
buttonColor: "#673AB7",
buttonTextColor: "#FFFFFF",
dpadCenterColor: "#5E35B1",
},
{
gameboyColor: "#FFC107",
htmlColor: "#FFF9C4",
screenColor: "#FFEB3B",
buttonColor: "#FF9800",
buttonTextColor: "#000000",
dpadCenterColor: "#EF6C00",
},
{
gameboyColor: "#8BC34A",
htmlColor: "#C5E1A5",
screenColor: "#A5D6A7",
buttonColor: "#FF5722",
buttonTextColor: "#FFFFFF",
dpadCenterColor: "#E64A19",
},
{
gameboyColor: "#F44336",
htmlColor: "#FFCDD2",
screenColor: "#EF9A9A",
buttonColor: "#E91E63",
buttonTextColor: "#FFFFFF",
dpadCenterColor: "#C2185B",
},
{
gameboyColor: "#03A9F4",
htmlColor: "#BBDEFB",
screenColor: "#90CAF9",
buttonColor: "#FFEB3B",
buttonTextColor: "#000000",
dpadCenterColor: "#0277BD",
},
{
gameboyColor: "#FF7043",
htmlColor: "#FFCCBC",
screenColor: "#FFAB91",
buttonColor: "#FF5722",
buttonTextColor: "#FFFFFF",
dpadCenterColor: "#D84315",
},
{
gameboyColor: "#9C27B0",
htmlColor: "#E1BEE7",
screenColor: "#D1C4E9",
buttonColor: "#7B1FA2",
buttonTextColor: "#FFFFFF",
dpadCenterColor: "#6A1B9A",
},
{
gameboyColor: "#FFD700",
htmlColor: "#FFF9C4",
screenColor: "#FFF59D",
buttonColor: "#FF9800",
buttonTextColor: "#FFFFFF",
dpadCenterColor: "#F57F17",
},
{
gameboyColor: "#009688",
htmlColor: "#B2DFDB",
screenColor: "#80CBC4",
buttonColor: "#4CAF50",
buttonTextColor: "#FFFFFF",
dpadCenterColor: "#00796B",
},
{
gameboyColor: "#795548",
htmlColor: "#D7CCC8",
screenColor: "#A1887F",
buttonColor: "#9E9E9E",
buttonTextColor: "#000000",
dpadCenterColor: "#5D4037",
},
{
gameboyColor: "#FF5733",
htmlColor: "#FFCCCB",
screenColor: "#FFABAB",
buttonColor: "#C70039",
buttonTextColor: "#FFFFFF",
dpadCenterColor: "#B71C1C",
},
{
gameboyColor: "#00BCD4",
htmlColor: "#B2EBF2",
screenColor: "#80DEEA",
buttonColor: "#00ACC1",
buttonTextColor: "#FFFFFF",
dpadCenterColor: "#00838F",
},
];
let currentColorIndex = localStorage.getItem('gameboyColorIndex') ? parseInt(localStorage.getItem('gameboyColorIndex')) : 0;
let currentColorIndex = localStorage.getItem("gameboyColorIndex")
? parseInt(localStorage.getItem("gameboyColorIndex"))
: 0;
function updateGameBoyColor() {
gameboy.style.backgroundColor = colors[currentColorIndex].gameboyColor;
@ -32,7 +118,7 @@ function updateGameBoyColor() {
body.style.backgroundColor = colors[currentColorIndex].htmlColor;
screen.style.backgroundColor = colors[currentColorIndex].screenColor;
dpadButtons.forEach(button => {
dpadButtons.forEach((button) => {
button.style.backgroundColor = colors[currentColorIndex].buttonColor;
button.style.color = colors[currentColorIndex].buttonTextColor;
});
@ -41,21 +127,21 @@ function updateGameBoyColor() {
dpadCenter.style.backgroundColor = colors[currentColorIndex].dpadCenterColor;
dpadCenter.style.color = colors[currentColorIndex].buttonTextColor;
actionButtons.forEach(button => {
actionButtons.forEach((button) => {
button.style.backgroundColor = colors[currentColorIndex].buttonColor;
button.style.color = colors[currentColorIndex].buttonTextColor;
});
}
left.addEventListener('click', () => {
left.addEventListener("click", () => {
currentColorIndex = (currentColorIndex - 1 + colors.length) % colors.length;
localStorage.setItem('gameboyColorIndex', currentColorIndex);
localStorage.setItem("gameboyColorIndex", currentColorIndex);
updateGameBoyColor();
});
right.addEventListener('click', () => {
right.addEventListener("click", () => {
currentColorIndex = (currentColorIndex + 1) % colors.length;
localStorage.setItem('gameboyColorIndex', currentColorIndex);
localStorage.setItem("gameboyColorIndex", currentColorIndex);
updateGameBoyColor();
});

View file

@ -1,15 +1,15 @@
document.getElementById('startGame').addEventListener('click', function () {
const gridSize = parseInt(document.getElementById('gridSize').value);
const bombs = parseInt(document.getElementById('bombs').value);
document.getElementById("startGame").addEventListener("click", function () {
const gridSize = parseInt(document.getElementById("gridSize").value);
const bombs = parseInt(document.getElementById("bombs").value);
document.getElementById('settings').style.display = 'none';
document.getElementById('game').style.display = 'block';
document.getElementById("settings").style.display = "none";
document.getElementById("game").style.display = "block";
renderGame(gridSize, bombs);
});
const canvas = document.getElementById('game');
const ctx = canvas.getContext('2d');
const canvas = document.getElementById("game");
const ctx = canvas.getContext("2d");
class Minesweeper {
constructor(width, height, bombs) {
@ -25,7 +25,8 @@ class Minesweeper {
}
}
this.bombAmount = bombs > width * height / 2 ? width * height / 2 : bombs;
this.bombAmount =
bombs > (width * height) / 2 ? (width * height) / 2 : bombs;
this.width = width;
this.height = height;
this.firstClick = false;
@ -36,7 +37,9 @@ class Minesweeper {
for (let i = 0; i < this.bombAmount; i++) {
let x = Math.floor(Math.random() * this.width);
let y = Math.floor(Math.random() * this.height);
(this.bombs[x][y] || this.field[x][y] == 0) ? i-- : this.bombs[x][y] = true;
this.bombs[x][y] || this.field[x][y] == 0
? i--
: (this.bombs[x][y] = true);
}
this.firstClick = true;
}
@ -45,7 +48,12 @@ class Minesweeper {
let counter = 0;
for (let newX = x - 1; newX <= x + 1; newX++) {
for (let newY = y - 1; newY <= y + 1; newY++) {
if (newX < this.field.length && newX >= 0 && newY < this.field[0].length && newY >= 0) {
if (
newX < this.field.length &&
newX >= 0 &&
newY < this.field[0].length &&
newY >= 0
) {
this.bombs[newX][newY] ? counter++ : {};
}
}
@ -65,7 +73,7 @@ class Minesweeper {
}
}
this.drawField();
alert('You won!');
alert("You won!");
window.location.reload();
}
@ -91,7 +99,7 @@ class Minesweeper {
uncoverSquare(x, y) {
if (x < this.field.length && x >= 0 && y < this.field[0].length && y >= 0) {
if (this.bombs[x][y] && this.field[x][y] == 1) {
alert('You lost!');
alert("You lost!");
window.location.reload();
} else if (this.field[x][y] == 1) {
this.field[x][y] = 0;
@ -99,13 +107,20 @@ class Minesweeper {
if (this.getNearbyBombs(x, y) == 0) {
for (let newX = x - 1; newX <= x + 1; newX++) {
for (let newY = y - 1; newY <= y + 1; newY++) {
if (newX < this.field.length && newX >= 0 && newY < this.field[0].length && newY >= 0) {
this.field[newX][newY] == 1 ? this.uncoverSquare(newX, newY) : {};
if (
newX < this.field.length &&
newX >= 0 &&
newY < this.field[0].length &&
newY >= 0
) {
this.field[newX][newY] == 1
? this.uncoverSquare(newX, newY)
: {};
}
}
}
}
}
};
this.checkWin();
this.drawField();
}
@ -113,11 +128,11 @@ class Minesweeper {
drawSquare(x, y, type) {
ctx.lineWidth = 3;
let uncovered = (x + y) % 2 === 0 ? '#D3D3D3' : '#A9A9A9';
let covered = (x + y) % 2 === 0 ? '#4CAF50' : '#81C784';
let uncovered = (x + y) % 2 === 0 ? "#D3D3D3" : "#A9A9A9";
let covered = (x + y) % 2 === 0 ? "#4CAF50" : "#81C784";
ctx.fillStyle = type != 0 ? covered : uncovered;
ctx.fillRect(x * this.size, y * this.size, this.size, this.size);
ctx.strokeStyle = '#000';
ctx.strokeStyle = "#000";
ctx.strokeRect(x * this.size, y * this.size, this.size, this.size);
if (type != 1) {
@ -125,11 +140,15 @@ class Minesweeper {
const number = this.getNearbyBombs(x, y);
let finalPrint;
ctx.font = `${fontSize}px sans-serif`;
ctx.fillStyle = '#000';
type == 0 ? finalPrint = number ? number : ' ' : {};
type == 2 ? finalPrint = '🚩' : {};
type == 3 ? finalPrint = '❓' : {};
ctx.fillText(finalPrint, x * this.size + fontSize / (type == 0 ? 1.5 : 1.8), y * this.size + fontSize * 1.3);
ctx.fillStyle = "#000";
type == 0 ? (finalPrint = number ? number : " ") : {};
type == 2 ? (finalPrint = "🚩") : {};
type == 3 ? (finalPrint = "❓") : {};
ctx.fillText(
finalPrint,
x * this.size + fontSize / (type == 0 ? 1.5 : 1.8),
y * this.size + fontSize * 1.3
);
}
}
@ -143,8 +162,8 @@ class Minesweeper {
canvas.width = this.size * this.field.length;
canvas.height = this.size * this.field[0].length;
const offsetX = (canvas.width - (this.field.length * this.size)) / 2;
const offsetY = (canvas.height - (this.field[0].length * this.size)) / 2;
const offsetX = (canvas.width - this.field.length * this.size) / 2;
const offsetY = (canvas.height - this.field[0].length * this.size) / 2;
for (let x = 0; x < this.field.length; x++) {
for (let y = 0; y < this.field[x].length; y++) {
@ -156,14 +175,14 @@ class Minesweeper {
const renderGame = (gridSize, bombs) => {
let field = new Minesweeper(gridSize, gridSize, bombs);
window.addEventListener('resize', () => field.drawField());
canvas.addEventListener('click', (event) => {
window.addEventListener("resize", () => field.drawField());
canvas.addEventListener("click", (event) => {
const rect = canvas.getBoundingClientRect();
const x = Math.floor((event.clientX - rect.left) / field.size);
const y = Math.floor((event.clientY - rect.top) / field.size);
field.uncoverSquare(x, y);
});
canvas.addEventListener('contextmenu', (event) => {
canvas.addEventListener("contextmenu", (event) => {
event.preventDefault();
const rect = canvas.getBoundingClientRect();
const x = Math.floor((event.clientX - rect.left) / field.size);

View file

@ -8,7 +8,7 @@ body,
html {
height: 100%;
margin: 0;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
display: flex;
flex-direction: column;
justify-content: center;

View file

@ -1,13 +1,13 @@
'use strict';
"use strict";
const upButton = document.getElementById('up');
const downButton = document.getElementById('down');
const leftButton = document.getElementById('left');
const rightButton = document.getElementById('right');
const startButton = document.getElementById('start');
const grid = document.createElement('div');
grid.id = 'grid';
document.querySelector('.game').appendChild(grid);
const upButton = document.getElementById("up");
const downButton = document.getElementById("down");
const leftButton = document.getElementById("left");
const rightButton = document.getElementById("right");
const startButton = document.getElementById("start");
const grid = document.createElement("div");
grid.id = "grid";
document.querySelector(".game").appendChild(grid);
let snake = [{ x: 5, y: 5 }];
let apple = { x: 8, y: 5 };
@ -17,13 +17,13 @@ let isGameRunning = false;
const gridSize = 10;
function initGame() {
grid.style.display = 'grid';
grid.style.display = "grid";
grid.style.gridTemplateColumns = `repeat(${gridSize}, 1fr)`;
grid.style.gridTemplateRows = `repeat(${gridSize}, 1fr)`;
grid.style.width = '350px';
grid.style.height = '350px';
document.getElementById('title').style.display = 'none';
document.getElementById('description').style.display = 'none';
grid.style.width = "350px";
grid.style.height = "350px";
document.getElementById("title").style.display = "none";
document.getElementById("description").style.display = "none";
isGameRunning = true;
snake = [{ x: 5, y: 5 }];
@ -40,16 +40,20 @@ function spawnApple() {
do {
newApple = {
x: Math.floor(Math.random() * gridSize),
y: Math.floor(Math.random() * gridSize)
y: Math.floor(Math.random() * gridSize),
};
} while (snake.some(segment => segment.x === newApple.x && segment.y === newApple.y));
} while (
snake.some(
(segment) => segment.x === newApple.x && segment.y === newApple.y
)
);
return newApple;
}
function updateSnake() {
const newHead = {
x: snake[0].x + direction.x,
y: snake[0].y + direction.y
y: snake[0].y + direction.y,
};
if (newHead.x < 0) newHead.x = gridSize - 1;
@ -57,7 +61,9 @@ function updateSnake() {
if (newHead.x >= gridSize) newHead.x = 0;
if (newHead.y >= gridSize) newHead.y = 0;
if (snake.some(segment => segment.x === newHead.x && segment.y === newHead.y)) {
if (
snake.some((segment) => segment.x === newHead.x && segment.y === newHead.y)
) {
gameOver();
return;
}
@ -85,7 +91,7 @@ function render() {
cell.classList.add("dark-green");
}
if (snake.some(segment => segment.x === x && segment.y === y)) {
if (snake.some((segment) => segment.x === x && segment.y === y)) {
cell.classList.add("snake");
}
@ -105,40 +111,40 @@ function gameLoop() {
}
function gameOver() {
alert('Game Over!');
alert("Game Over!");
clearInterval(gameInterval);
isGameRunning = false;
}
function handleDirectionInput(key) {
switch (key) {
case 'ArrowUp':
case 'w':
case "ArrowUp":
case "w":
if (direction.y === 0) direction = { x: 0, y: -1 };
break;
case 'ArrowDown':
case 's':
case "ArrowDown":
case "s":
if (direction.y === 0) direction = { x: 0, y: 1 };
break;
case 'ArrowLeft':
case 'a':
case "ArrowLeft":
case "a":
if (direction.x === 0) direction = { x: -1, y: 0 };
break;
case 'ArrowRight':
case 'd':
case "ArrowRight":
case "d":
if (direction.x === 0) direction = { x: 1, y: 0 };
break;
}
}
upButton.addEventListener('click', () => handleDirectionInput('ArrowUp'));
downButton.addEventListener('click', () => handleDirectionInput('ArrowDown'));
leftButton.addEventListener('click', () => handleDirectionInput('ArrowLeft'));
rightButton.addEventListener('click', () => handleDirectionInput('ArrowRight'));
startButton.addEventListener('click', () => {
upButton.addEventListener("click", () => handleDirectionInput("ArrowUp"));
downButton.addEventListener("click", () => handleDirectionInput("ArrowDown"));
leftButton.addEventListener("click", () => handleDirectionInput("ArrowLeft"));
rightButton.addEventListener("click", () => handleDirectionInput("ArrowRight"));
startButton.addEventListener("click", () => {
if (!isGameRunning) initGame();
});
document.addEventListener('keydown', (event) => {
document.addEventListener("keydown", (event) => {
handleDirectionInput(event.key);
});

View file

@ -13,7 +13,7 @@ html {
/* GameBoy Layout */
.gameboy {
background-color: #5f4c82; /* Game Boy Color purple shell */
background-color: #5f4c82;
width: 441px;
height: 735px;
border-radius: 20px;

View file

@ -1,36 +1,110 @@
'use strict';
const aBtn = document.querySelector('#a');
const bBtn = document.querySelector('#b');
const gameboy = document.querySelector('.gameboy');
"use strict";
const aBtn = document.querySelector("#a");
const bBtn = document.querySelector("#b");
const gameboy = document.querySelector(".gameboy");
const html = document.documentElement;
const body = document.body;
const dpadButtons = document.querySelectorAll('.dpad-btn');
const dpadCenter = document.querySelector('.dpad-center'); // Darker variant
const actionButtons = document.querySelectorAll('.btn');
const dpadButtons = document.querySelectorAll(".dpad-btn");
const dpadCenter = document.querySelector(".dpad-center"); // Darker variant
const actionButtons = document.querySelectorAll(".btn");
const colors = [
{ gameboyColor: '#B39DDB', htmlColor: '#D1C4E9', buttonColor: '#673AB7', buttonTextColor: '#FFFFFF', dpadCenterColor: '#5E35B1' },
{ gameboyColor: '#FFC107', htmlColor: '#FFF9C4', buttonColor: '#FF9800', buttonTextColor: '#000000', dpadCenterColor: '#EF6C00' },
{ gameboyColor: '#8BC34A', htmlColor: '#C5E1A5', buttonColor: '#FF5722', buttonTextColor: '#FFFFFF', dpadCenterColor: '#E64A19' },
{ gameboyColor: '#F44336', htmlColor: '#FFCDD2', buttonColor: '#E91E63', buttonTextColor: '#FFFFFF', dpadCenterColor: '#C2185B' },
{ gameboyColor: '#03A9F4', htmlColor: '#BBDEFB', buttonColor: '#FFEB3B', buttonTextColor: '#000000', dpadCenterColor: '#0277BD' },
{ gameboyColor: '#FF7043', htmlColor: '#FFCCBC', buttonColor: '#FF5722', buttonTextColor: '#FFFFFF', dpadCenterColor: '#D84315' },
{ gameboyColor: '#9C27B0', htmlColor: '#E1BEE7', buttonColor: '#7B1FA2', buttonTextColor: '#FFFFFF', dpadCenterColor: '#6A1B9A' },
{ gameboyColor: '#FFD700', htmlColor: '#FFF9C4', buttonColor: '#FF9800', buttonTextColor: '#FFFFFF', dpadCenterColor: '#F57F17' },
{ gameboyColor: '#009688', htmlColor: '#B2DFDB', buttonColor: '#4CAF50', buttonTextColor: '#FFFFFF', dpadCenterColor: '#00796B' },
{ gameboyColor: '#795548', htmlColor: '#D7CCC8', buttonColor: '#9E9E9E', buttonTextColor: '#000000', dpadCenterColor: '#5D4037' },
{ gameboyColor: '#FF5733', htmlColor: '#FFCCCB', buttonColor: '#C70039', buttonTextColor: '#FFFFFF', dpadCenterColor: '#B71C1C' },
{ gameboyColor: '#00BCD4', htmlColor: '#B2EBF2', buttonColor: '#00ACC1', buttonTextColor: '#FFFFFF', dpadCenterColor: '#00838F' }
{
gameboyColor: "#B39DDB",
htmlColor: "#D1C4E9",
buttonColor: "#673AB7",
buttonTextColor: "#FFFFFF",
dpadCenterColor: "#5E35B1",
},
{
gameboyColor: "#FFC107",
htmlColor: "#FFF9C4",
buttonColor: "#FF9800",
buttonTextColor: "#000000",
dpadCenterColor: "#EF6C00",
},
{
gameboyColor: "#8BC34A",
htmlColor: "#C5E1A5",
buttonColor: "#FF5722",
buttonTextColor: "#FFFFFF",
dpadCenterColor: "#E64A19",
},
{
gameboyColor: "#F44336",
htmlColor: "#FFCDD2",
buttonColor: "#E91E63",
buttonTextColor: "#FFFFFF",
dpadCenterColor: "#C2185B",
},
{
gameboyColor: "#03A9F4",
htmlColor: "#BBDEFB",
buttonColor: "#FFEB3B",
buttonTextColor: "#000000",
dpadCenterColor: "#0277BD",
},
{
gameboyColor: "#FF7043",
htmlColor: "#FFCCBC",
buttonColor: "#FF5722",
buttonTextColor: "#FFFFFF",
dpadCenterColor: "#D84315",
},
{
gameboyColor: "#9C27B0",
htmlColor: "#E1BEE7",
buttonColor: "#7B1FA2",
buttonTextColor: "#FFFFFF",
dpadCenterColor: "#6A1B9A",
},
{
gameboyColor: "#FFD700",
htmlColor: "#FFF9C4",
buttonColor: "#FF9800",
buttonTextColor: "#FFFFFF",
dpadCenterColor: "#F57F17",
},
{
gameboyColor: "#009688",
htmlColor: "#B2DFDB",
buttonColor: "#4CAF50",
buttonTextColor: "#FFFFFF",
dpadCenterColor: "#00796B",
},
{
gameboyColor: "#795548",
htmlColor: "#D7CCC8",
buttonColor: "#9E9E9E",
buttonTextColor: "#000000",
dpadCenterColor: "#5D4037",
},
{
gameboyColor: "#FF5733",
htmlColor: "#FFCCCB",
buttonColor: "#C70039",
buttonTextColor: "#FFFFFF",
dpadCenterColor: "#B71C1C",
},
{
gameboyColor: "#00BCD4",
htmlColor: "#B2EBF2",
buttonColor: "#00ACC1",
buttonTextColor: "#FFFFFF",
dpadCenterColor: "#00838F",
},
];
let currentColorIndex = localStorage.getItem('gameboyColorIndex') ? parseInt(localStorage.getItem('gameboyColorIndex')) : 0;
let currentColorIndex = localStorage.getItem("gameboyColorIndex")
? parseInt(localStorage.getItem("gameboyColorIndex"))
: 0;
function updateGameBoyColor() {
gameboy.style.backgroundColor = colors[currentColorIndex].gameboyColor;
html.style.backgroundColor = colors[currentColorIndex].htmlColor;
body.style.backgroundColor = colors[currentColorIndex].htmlColor;
dpadButtons.forEach(button => {
dpadButtons.forEach((button) => {
button.style.backgroundColor = colors[currentColorIndex].buttonColor;
button.style.color = colors[currentColorIndex].buttonTextColor;
});
@ -39,21 +113,21 @@ function updateGameBoyColor() {
dpadCenter.style.backgroundColor = colors[currentColorIndex].dpadCenterColor;
dpadCenter.style.color = colors[currentColorIndex].buttonTextColor;
actionButtons.forEach(button => {
actionButtons.forEach((button) => {
button.style.backgroundColor = colors[currentColorIndex].buttonColor;
button.style.color = colors[currentColorIndex].buttonTextColor;
});
}
aBtn.addEventListener('click', () => {
aBtn.addEventListener("click", () => {
currentColorIndex = (currentColorIndex - 1 + colors.length) % colors.length;
localStorage.setItem('gameboyColorIndex', currentColorIndex);
localStorage.setItem("gameboyColorIndex", currentColorIndex);
updateGameBoyColor();
});
bBtn.addEventListener('click', () => {
bBtn.addEventListener("click", () => {
currentColorIndex = (currentColorIndex + 1) % colors.length;
localStorage.setItem('gameboyColorIndex', currentColorIndex);
localStorage.setItem("gameboyColorIndex", currentColorIndex);
updateGameBoyColor();
});

View file

@ -5,12 +5,12 @@
}
body {
font-family: 'Courier New', Courier, monospace;
font-family: "Courier New", Courier, monospace;
background-color: #0d0d0d;
color: #b0b0b0;
margin: 0;
line-height: 1.6;
background-image: url('images/background.jpg');
background-image: url("images/background.jpg");
background-size: cover; /* Adjust size for tape appearance */
}
@ -27,22 +27,26 @@ header {
/* Create the flickering neon light effect */
@keyframes neonFlicker {
0% {
text-shadow: 0 0 5px #ffcc00, 0 0 10px #ffcc00, 0 0 15px #ffcc00, 0 0 20px #ffcc00, 0 0 30px #ffcc00, 0 0 40px #ffcc00, 0 0 50px #ffcc00;
text-shadow: 0 0 5px #ffcc00, 0 0 10px #ffcc00, 0 0 15px #ffcc00,
0 0 20px #ffcc00, 0 0 30px #ffcc00, 0 0 40px #ffcc00, 0 0 50px #ffcc00;
}
20% {
text-shadow: 0 0 3px #ffcc00, 0 0 7px #ffcc00, 0 0 10px #ffcc00, 0 0 15px #ffcc00, 0 0 20px #ffcc00;
text-shadow: 0 0 3px #ffcc00, 0 0 7px #ffcc00, 0 0 10px #ffcc00,
0 0 15px #ffcc00, 0 0 20px #ffcc00;
}
40% {
text-shadow: 0 0 5px #ffcc00, 0 0 15px #ffcc00, 0 0 25px #ffcc00;
}
60% {
text-shadow: 0 0 5px #ffcc00, 0 0 10px #ffcc00, 0 0 15px #ffcc00, 0 0 20px #ffcc00, 0 0 30px #ffcc00;
text-shadow: 0 0 5px #ffcc00, 0 0 10px #ffcc00, 0 0 15px #ffcc00,
0 0 20px #ffcc00, 0 0 30px #ffcc00;
}
80% {
text-shadow: 0 0 3px #ffcc00, 0 0 7px #ffcc00, 0 0 10px #ffcc00;
}
100% {
text-shadow: 0 0 5px #ffcc00, 0 0 10px #ffcc00, 0 0 15px #ffcc00, 0 0 20px #ffcc00, 0 0 30px #ffcc00, 0 0 40px #ffcc00;
text-shadow: 0 0 5px #ffcc00, 0 0 10px #ffcc00, 0 0 15px #ffcc00,
0 0 20px #ffcc00, 0 0 30px #ffcc00, 0 0 40px #ffcc00;
}
}

View file

@ -206,7 +206,8 @@ article ul a li {
margin-bottom: 10px;
border-radius: var(--border-radius);
padding: 10px;
transition: background-color var(--transition-speed), box-shadow var(--transition-speed);
transition: background-color var(--transition-speed),
box-shadow var(--transition-speed);
}
article ul a li:hover {
@ -263,7 +264,12 @@ section .card a {
section .card {
text-align: center;
list-style: none;
background: linear-gradient(180deg, rgba(0, 0, 50, 0.9), rgba(10, 10, 100, 0.9), rgba(30, 30, 150, 0.9));
background: linear-gradient(
180deg,
rgba(0, 0, 50, 0.9),
rgba(10, 10, 100, 0.9),
rgba(30, 30, 150, 0.9)
);
border-radius: 12px;
box-shadow: 0 5px 20px rgba(0, 0, 50, 0.8), 0 0 10px rgba(255, 255, 255, 0.1);
border: 1px solid #2e3a60;
@ -278,7 +284,12 @@ section .card {
/* Hover effect */
section .card:hover {
transform: translateY(-8px);
background: linear-gradient(180deg, rgba(30, 30, 150, 0.9), rgba(40, 0, 100, 0.9), rgba(100, 0, 150, 0.9));
background: linear-gradient(
180deg,
rgba(30, 30, 150, 0.9),
rgba(40, 0, 100, 0.9),
rgba(100, 0, 150, 0.9)
);
box-shadow: 0 10px 30px rgba(0, 0, 100, 0.7), 0 0 20px rgba(255, 221, 85, 0.8);
}
@ -314,7 +325,11 @@ section .card::before {
width: 60px;
height: 60px;
border-radius: 50%;
background: radial-gradient(circle, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.02));
background: radial-gradient(
circle,
rgba(255, 255, 255, 0.1),
rgba(255, 255, 255, 0.02)
);
box-shadow: 0 0 50px rgba(255, 255, 255, 0.5);
animation: spin 8s linear infinite;
}

View file

@ -14,7 +14,7 @@ body {
}
header {
background-color: #4CAF50;
background-color: #4caf50;
color: white;
text-align: center;
padding: 1em 0;