formatted like my Boss wants it (help!)
This commit is contained in:
parent
5d11f87dd3
commit
b507a6b0ea
19 changed files with 1425 additions and 1136 deletions
|
@ -22,7 +22,9 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||||
const burgerMenu = document.querySelector(".burger-menu");
|
const burgerMenu = document.querySelector(".burger-menu");
|
||||||
|
|
||||||
if (!menu || !burgerMenu) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +43,10 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||||
|
|
||||||
// Close the menu if clicking outside of it
|
// Close the menu if clicking outside of it
|
||||||
function closeMenu(event) {
|
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");
|
menu.classList.remove("active");
|
||||||
document.removeEventListener("click", closeMenu);
|
document.removeEventListener("click", closeMenu);
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,17 +37,16 @@ class Footer extends HTMLElement {
|
||||||
`;
|
`;
|
||||||
|
|
||||||
// Add event listener for button click
|
// Add event listener for button click
|
||||||
this.querySelector('.secret-button').addEventListener('click', () => {
|
this.querySelector(".secret-button").addEventListener("click", () => {
|
||||||
window.open('secret/index.html', '_blank');
|
window.open("secret/index.html", "_blank");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
customElements.define('footer-component', Footer);
|
customElements.define("footer-component", Footer);
|
||||||
|
|
||||||
|
|
||||||
// CSS for the hidden button
|
// CSS for the hidden button
|
||||||
const style = document.createElement('style');
|
const style = document.createElement("style");
|
||||||
style.textContent = `
|
style.textContent = `
|
||||||
.secret-button {
|
.secret-button {
|
||||||
display: none;
|
display: none;
|
||||||
|
|
|
@ -42,5 +42,5 @@ class Header extends HTMLElement {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
customElements.define('header-component', Header);
|
customElements.define("header-component", Header);
|
||||||
// @license-end
|
// @license-end
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
// Canvas setup
|
// Canvas setup
|
||||||
const canvas = document.getElementById('gameCanvas');
|
const canvas = document.getElementById("gameCanvas");
|
||||||
const ctx = canvas.getContext('2d');
|
const ctx = canvas.getContext("2d");
|
||||||
const targetFPS = 60;
|
const targetFPS = 60;
|
||||||
const targetFrameTime = 1000 / targetFPS;
|
const targetFrameTime = 1000 / targetFPS;
|
||||||
canvas.width = window.innerWidth;
|
canvas.width = window.innerWidth;
|
||||||
|
@ -15,9 +15,9 @@ const player = {
|
||||||
y: canvas.height - 60,
|
y: canvas.height - 60,
|
||||||
width: 40,
|
width: 40,
|
||||||
height: 40,
|
height: 40,
|
||||||
color: 'white',
|
color: "white",
|
||||||
speed: 5,
|
speed: 5,
|
||||||
dx: 0
|
dx: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
let bullets = [];
|
let bullets = [];
|
||||||
|
@ -48,7 +48,7 @@ let greenSphereCooldown = 0;
|
||||||
let rainbowSphereCooldown = 0;
|
let rainbowSphereCooldown = 0;
|
||||||
|
|
||||||
// Sphere types
|
// Sphere types
|
||||||
const sphereTypes = ['blue', 'yellow', 'green', 'rainbow'];
|
const sphereTypes = ["blue", "yellow", "green", "rainbow"];
|
||||||
|
|
||||||
/// Control for left button press and release
|
/// Control for left button press and release
|
||||||
function btnMoveLeft(isPressed) {
|
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
|
canShoot = true; // Allow shooting again when button is released
|
||||||
});
|
});
|
||||||
|
|
||||||
window.addEventListener('keydown', (e) => {
|
window.addEventListener("keydown", (e) => {
|
||||||
if (e.key === 'ArrowLeft' || e.key === 'a') player.dx = -player.speed;
|
if (e.key === "ArrowLeft" || e.key === "a") player.dx = -player.speed;
|
||||||
if (e.key === 'ArrowRight' || e.key === 'd') 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
|
// Shoot only if it's not a hold, and we can shoot
|
||||||
if (e.key === ' ' && canShoot && !isGameOver) {
|
if (e.key === " " && canShoot && !isGameOver) {
|
||||||
shootBullet();
|
shootBullet();
|
||||||
canShoot = false; // Prevent shooting until the key is released
|
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
|
// 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;
|
player.dx = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allow shooting again when the space key is released
|
// Allow shooting again when the space key is released
|
||||||
if (e.key === ' ') {
|
if (e.key === " ") {
|
||||||
canShoot = true;
|
canShoot = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -124,8 +129,8 @@ function shootBullet() {
|
||||||
y: player.y,
|
y: player.y,
|
||||||
width: 5,
|
width: 5,
|
||||||
height: 10,
|
height: 10,
|
||||||
color: 'yellow',
|
color: "yellow",
|
||||||
speed: 7
|
speed: 7,
|
||||||
});
|
});
|
||||||
}, i * 50); // Fire bullets with 50ms delay between shots
|
}, i * 50); // Fire bullets with 50ms delay between shots
|
||||||
}
|
}
|
||||||
|
@ -137,9 +142,9 @@ function shootBullet() {
|
||||||
y: player.y,
|
y: player.y,
|
||||||
width: 5,
|
width: 5,
|
||||||
height: 10,
|
height: 10,
|
||||||
color: 'yellow',
|
color: "yellow",
|
||||||
speed: 7,
|
speed: 7,
|
||||||
angle: i * 10 // Spray the bullets at different angles
|
angle: i * 10, // Spray the bullets at different angles
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -149,15 +154,15 @@ function shootBullet() {
|
||||||
y: player.y,
|
y: player.y,
|
||||||
width: 5,
|
width: 5,
|
||||||
height: 10,
|
height: 10,
|
||||||
color: 'yellow',
|
color: "yellow",
|
||||||
speed: 7
|
speed: 7,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate random color
|
// Generate random color
|
||||||
function getRandomColor() {
|
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)];
|
return colors[Math.floor(Math.random() * colors.length)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,13 +175,14 @@ function createAsteroid() {
|
||||||
width: size,
|
width: size,
|
||||||
height: size,
|
height: size,
|
||||||
color: getRandomColor(),
|
color: getRandomColor(),
|
||||||
speed: (Math.random() * 3 + 2) * asteroidSpeedMultiplier // Faster initial speed
|
speed: (Math.random() * 3 + 2) * asteroidSpeedMultiplier, // Faster initial speed
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Item mechanics
|
// Item mechanics
|
||||||
function createItem() {
|
function createItem() {
|
||||||
const randomType = sphereTypes[Math.floor(Math.random() * sphereTypes.length)];
|
const randomType =
|
||||||
|
sphereTypes[Math.floor(Math.random() * sphereTypes.length)];
|
||||||
const size = 30;
|
const size = 30;
|
||||||
const x = Math.random() * canvas.width;
|
const x = Math.random() * canvas.width;
|
||||||
items.push({
|
items.push({
|
||||||
|
@ -185,8 +191,15 @@ function createItem() {
|
||||||
width: size,
|
width: size,
|
||||||
height: size,
|
height: size,
|
||||||
type: randomType,
|
type: randomType,
|
||||||
color: randomType === 'blue' ? 'blue' : randomType === 'yellow' ? 'yellow' : randomType === 'green' ? 'green' : 'rainbow',
|
color:
|
||||||
speed: 3
|
randomType === "blue"
|
||||||
|
? "blue"
|
||||||
|
: randomType === "yellow"
|
||||||
|
? "yellow"
|
||||||
|
: randomType === "green"
|
||||||
|
? "green"
|
||||||
|
: "rainbow",
|
||||||
|
speed: 3,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,7 +207,8 @@ function createItem() {
|
||||||
function updatePlayer() {
|
function updatePlayer() {
|
||||||
player.x += player.dx;
|
player.x += player.dx;
|
||||||
if (player.x < 0) player.x = 0;
|
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() {
|
function updateBullets() {
|
||||||
|
@ -230,15 +244,15 @@ function updateItems() {
|
||||||
|
|
||||||
function applyItemEffect(type) {
|
function applyItemEffect(type) {
|
||||||
let points = Math.floor(Math.random() * 5) + 1; // Random points between 1 and 5
|
let points = Math.floor(Math.random() * 5) + 1; // Random points between 1 and 5
|
||||||
if (type === 'blue') {
|
if (type === "blue") {
|
||||||
rapidFireActive = true;
|
rapidFireActive = true;
|
||||||
setTimeout(() => rapidFireActive = false, 15000); // 15 seconds of rapid fire
|
setTimeout(() => (rapidFireActive = false), 15000); // 15 seconds of rapid fire
|
||||||
} else if (type === 'yellow') {
|
} else if (type === "yellow") {
|
||||||
shotgunActive = true;
|
shotgunActive = true;
|
||||||
setTimeout(() => shotgunActive = false, 30000); // 30 seconds of shotgun
|
setTimeout(() => (shotgunActive = false), 30000); // 30 seconds of shotgun
|
||||||
} else if (type === 'green') {
|
} else if (type === "green") {
|
||||||
ammo = 100; // Refill ammo
|
ammo = 100; // Refill ammo
|
||||||
} else if (type === 'rainbow') {
|
} else if (type === "rainbow") {
|
||||||
rapidFireActive = true;
|
rapidFireActive = true;
|
||||||
shotgunActive = true;
|
shotgunActive = true;
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
@ -282,7 +296,7 @@ function checkCollisions() {
|
||||||
|
|
||||||
// Explosion effect
|
// Explosion effect
|
||||||
function createExplosion(x, y) {
|
function createExplosion(x, y) {
|
||||||
ctx.fillStyle = 'yellow';
|
ctx.fillStyle = "yellow";
|
||||||
ctx.beginPath();
|
ctx.beginPath();
|
||||||
ctx.arc(x, y, 20, 0, Math.PI * 2);
|
ctx.arc(x, y, 20, 0, Math.PI * 2);
|
||||||
ctx.fill();
|
ctx.fill();
|
||||||
|
@ -313,33 +327,47 @@ function drawItems() {
|
||||||
items.forEach((item) => {
|
items.forEach((item) => {
|
||||||
ctx.fillStyle = item.color;
|
ctx.fillStyle = item.color;
|
||||||
ctx.beginPath();
|
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();
|
ctx.fill();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function drawScore() {
|
function drawScore() {
|
||||||
ctx.fillStyle = 'white';
|
ctx.fillStyle = "white";
|
||||||
ctx.font = '24px Arial';
|
ctx.font = "24px Arial";
|
||||||
ctx.fillText(`Score: ${score}`, 20, 40); // Score at top-left corner
|
ctx.fillText(`Score: ${score}`, 20, 40); // Score at top-left corner
|
||||||
}
|
}
|
||||||
|
|
||||||
function drawAmmo() {
|
function drawAmmo() {
|
||||||
ctx.fillStyle = 'white';
|
ctx.fillStyle = "white";
|
||||||
ctx.font = '24px Arial';
|
ctx.font = "24px Arial";
|
||||||
ctx.fillText(`Ammo: ${ammo}`, 20, 70); // Ammo at top-left corner
|
ctx.fillText(`Ammo: ${ammo}`, 20, 70); // Ammo at top-left corner
|
||||||
}
|
}
|
||||||
|
|
||||||
function drawGameOver() {
|
function drawGameOver() {
|
||||||
if (isGameOver) {
|
if (isGameOver) {
|
||||||
ctx.fillStyle = 'white';
|
ctx.fillStyle = "white";
|
||||||
ctx.font = '40px Arial';
|
ctx.font = "40px Arial";
|
||||||
ctx.textAlign = 'center';
|
ctx.textAlign = "center";
|
||||||
ctx.fillText('Game Over!', canvas.width / 2, canvas.height / 2 - 40);
|
ctx.fillText("Game Over!", canvas.width / 2, canvas.height / 2 - 40);
|
||||||
ctx.font = '24px Arial';
|
ctx.font = "24px Arial";
|
||||||
ctx.fillText(`Total Score: ${score}`, canvas.width / 2, canvas.height / 2);
|
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(
|
||||||
ctx.fillText('Press "R" to Restart', canvas.width / 2, canvas.height / 2 + 80);
|
`Bullets Fired: ${totalBulletsFired}`,
|
||||||
|
canvas.width / 2,
|
||||||
|
canvas.height / 2 + 40
|
||||||
|
);
|
||||||
|
ctx.fillText(
|
||||||
|
'Press "R" to Restart',
|
||||||
|
canvas.width / 2,
|
||||||
|
canvas.height / 2 + 80
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,9 @@ html {
|
||||||
max-width: 600px; /* Limit the width of the content */
|
max-width: 600px; /* Limit the width of the content */
|
||||||
position: relative;
|
position: relative;
|
||||||
color: white;
|
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 {
|
h1 {
|
||||||
|
|
|
@ -34,10 +34,15 @@ export default function EndlessRunner() {
|
||||||
if (Math.random() < 0.02) {
|
if (Math.random() < 0.02) {
|
||||||
obstacles.push({ x: canvas.width, y: 150, width: 20, height: 20 });
|
obstacles.push({ x: canvas.width, y: 150, width: 20, height: 20 });
|
||||||
}
|
}
|
||||||
obstacles = obstacles.map(obstacle => ({ ...obstacle, x: obstacle.x - 5 }));
|
obstacles = obstacles.map((obstacle) => ({
|
||||||
obstacles = obstacles.filter(obstacle => obstacle.x + obstacle.width > 0);
|
...obstacle,
|
||||||
|
x: obstacle.x - 5,
|
||||||
|
}));
|
||||||
|
obstacles = obstacles.filter(
|
||||||
|
(obstacle) => obstacle.x + obstacle.width > 0
|
||||||
|
);
|
||||||
|
|
||||||
obstacles.forEach(obstacle => {
|
obstacles.forEach((obstacle) => {
|
||||||
ctx.fillStyle = "red";
|
ctx.fillStyle = "red";
|
||||||
ctx.fillRect(obstacle.x, obstacle.y, obstacle.width, obstacle.height);
|
ctx.fillRect(obstacle.x, obstacle.y, obstacle.width, obstacle.height);
|
||||||
|
|
||||||
|
@ -72,7 +77,14 @@ export default function EndlessRunner() {
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col items-center">
|
<div className="flex flex-col items-center">
|
||||||
<canvas ref={canvasRef} className="border" onClick={jump}></canvas>
|
<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>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
118
secret/game.js
118
secret/game.js
|
@ -1,7 +1,7 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
// Canvas setup
|
// Canvas setup
|
||||||
const canvas = document.getElementById('gameCanvas');
|
const canvas = document.getElementById("gameCanvas");
|
||||||
const ctx = canvas.getContext('2d');
|
const ctx = canvas.getContext("2d");
|
||||||
canvas.width = window.innerWidth;
|
canvas.width = window.innerWidth;
|
||||||
canvas.height = window.innerHeight;
|
canvas.height = window.innerHeight;
|
||||||
|
|
||||||
|
@ -11,9 +11,9 @@ const player = {
|
||||||
y: canvas.height - 60,
|
y: canvas.height - 60,
|
||||||
width: 40,
|
width: 40,
|
||||||
height: 40,
|
height: 40,
|
||||||
color: 'white',
|
color: "white",
|
||||||
speed: 5,
|
speed: 5,
|
||||||
dx: 0
|
dx: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
let bullets = [];
|
let bullets = [];
|
||||||
|
@ -44,7 +44,7 @@ let greenSphereCooldown = 0;
|
||||||
let rainbowSphereCooldown = 0;
|
let rainbowSphereCooldown = 0;
|
||||||
|
|
||||||
// Sphere types
|
// Sphere types
|
||||||
const sphereTypes = ['blue', 'yellow', 'green', 'rainbow'];
|
const sphereTypes = ["blue", "yellow", "green", "rainbow"];
|
||||||
|
|
||||||
/// Control for left button press and release
|
/// Control for left button press and release
|
||||||
function btnMoveLeft(isPressed) {
|
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
|
canShoot = true; // Allow shooting again when button is released
|
||||||
});
|
});
|
||||||
|
|
||||||
window.addEventListener('keydown', (e) => {
|
window.addEventListener("keydown", (e) => {
|
||||||
if (e.key === 'ArrowLeft' || e.key === 'a') player.dx = -player.speed;
|
if (e.key === "ArrowLeft" || e.key === "a") player.dx = -player.speed;
|
||||||
if (e.key === 'ArrowRight' || e.key === 'd') 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
|
// Shoot only if it's not a hold, and we can shoot
|
||||||
if (e.key === ' ' && canShoot && !isGameOver) {
|
if (e.key === " " && canShoot && !isGameOver) {
|
||||||
shootBullet();
|
shootBullet();
|
||||||
canShoot = false; // Prevent shooting until the key is released
|
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
|
// 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;
|
player.dx = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allow shooting again when the space key is released
|
// Allow shooting again when the space key is released
|
||||||
if (e.key === ' ') {
|
if (e.key === " ") {
|
||||||
canShoot = true;
|
canShoot = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -120,8 +125,8 @@ function shootBullet() {
|
||||||
y: player.y,
|
y: player.y,
|
||||||
width: 5,
|
width: 5,
|
||||||
height: 10,
|
height: 10,
|
||||||
color: 'yellow',
|
color: "yellow",
|
||||||
speed: 7
|
speed: 7,
|
||||||
});
|
});
|
||||||
}, i * 50); // Fire bullets with 50ms delay between shots
|
}, i * 50); // Fire bullets with 50ms delay between shots
|
||||||
}
|
}
|
||||||
|
@ -133,9 +138,9 @@ function shootBullet() {
|
||||||
y: player.y,
|
y: player.y,
|
||||||
width: 5,
|
width: 5,
|
||||||
height: 10,
|
height: 10,
|
||||||
color: 'yellow',
|
color: "yellow",
|
||||||
speed: 7,
|
speed: 7,
|
||||||
angle: i * 10 // Spray the bullets at different angles
|
angle: i * 10, // Spray the bullets at different angles
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -145,15 +150,15 @@ function shootBullet() {
|
||||||
y: player.y,
|
y: player.y,
|
||||||
width: 5,
|
width: 5,
|
||||||
height: 10,
|
height: 10,
|
||||||
color: 'yellow',
|
color: "yellow",
|
||||||
speed: 7
|
speed: 7,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate random color
|
// Generate random color
|
||||||
function getRandomColor() {
|
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)];
|
return colors[Math.floor(Math.random() * colors.length)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,13 +171,14 @@ function createAsteroid() {
|
||||||
width: size,
|
width: size,
|
||||||
height: size,
|
height: size,
|
||||||
color: getRandomColor(),
|
color: getRandomColor(),
|
||||||
speed: (Math.random() * 3 + 2) * asteroidSpeedMultiplier // Faster initial speed
|
speed: (Math.random() * 3 + 2) * asteroidSpeedMultiplier, // Faster initial speed
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Item mechanics
|
// Item mechanics
|
||||||
function createItem() {
|
function createItem() {
|
||||||
const randomType = sphereTypes[Math.floor(Math.random() * sphereTypes.length)];
|
const randomType =
|
||||||
|
sphereTypes[Math.floor(Math.random() * sphereTypes.length)];
|
||||||
const size = 30;
|
const size = 30;
|
||||||
const x = Math.random() * canvas.width;
|
const x = Math.random() * canvas.width;
|
||||||
items.push({
|
items.push({
|
||||||
|
@ -181,8 +187,15 @@ function createItem() {
|
||||||
width: size,
|
width: size,
|
||||||
height: size,
|
height: size,
|
||||||
type: randomType,
|
type: randomType,
|
||||||
color: randomType === 'blue' ? 'blue' : randomType === 'yellow' ? 'yellow' : randomType === 'green' ? 'green' : 'rainbow',
|
color:
|
||||||
speed: 3
|
randomType === "blue"
|
||||||
|
? "blue"
|
||||||
|
: randomType === "yellow"
|
||||||
|
? "yellow"
|
||||||
|
: randomType === "green"
|
||||||
|
? "green"
|
||||||
|
: "rainbow",
|
||||||
|
speed: 3,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,7 +203,8 @@ function createItem() {
|
||||||
function updatePlayer() {
|
function updatePlayer() {
|
||||||
player.x += player.dx;
|
player.x += player.dx;
|
||||||
if (player.x < 0) player.x = 0;
|
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() {
|
function updateBullets() {
|
||||||
|
@ -226,15 +240,15 @@ function updateItems() {
|
||||||
|
|
||||||
function applyItemEffect(type) {
|
function applyItemEffect(type) {
|
||||||
let points = Math.floor(Math.random() * 5) + 1; // Random points between 1 and 5
|
let points = Math.floor(Math.random() * 5) + 1; // Random points between 1 and 5
|
||||||
if (type === 'blue') {
|
if (type === "blue") {
|
||||||
rapidFireActive = true;
|
rapidFireActive = true;
|
||||||
setTimeout(() => rapidFireActive = false, 15000); // 15 seconds of rapid fire
|
setTimeout(() => (rapidFireActive = false), 15000); // 15 seconds of rapid fire
|
||||||
} else if (type === 'yellow') {
|
} else if (type === "yellow") {
|
||||||
shotgunActive = true;
|
shotgunActive = true;
|
||||||
setTimeout(() => shotgunActive = false, 30000); // 30 seconds of shotgun
|
setTimeout(() => (shotgunActive = false), 30000); // 30 seconds of shotgun
|
||||||
} else if (type === 'green') {
|
} else if (type === "green") {
|
||||||
ammo = 100; // Refill ammo
|
ammo = 100; // Refill ammo
|
||||||
} else if (type === 'rainbow') {
|
} else if (type === "rainbow") {
|
||||||
rapidFireActive = true;
|
rapidFireActive = true;
|
||||||
shotgunActive = true;
|
shotgunActive = true;
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
@ -278,7 +292,7 @@ function checkCollisions() {
|
||||||
|
|
||||||
// Explosion effect
|
// Explosion effect
|
||||||
function createExplosion(x, y) {
|
function createExplosion(x, y) {
|
||||||
ctx.fillStyle = 'yellow';
|
ctx.fillStyle = "yellow";
|
||||||
ctx.beginPath();
|
ctx.beginPath();
|
||||||
ctx.arc(x, y, 20, 0, Math.PI * 2);
|
ctx.arc(x, y, 20, 0, Math.PI * 2);
|
||||||
ctx.fill();
|
ctx.fill();
|
||||||
|
@ -309,33 +323,47 @@ function drawItems() {
|
||||||
items.forEach((item) => {
|
items.forEach((item) => {
|
||||||
ctx.fillStyle = item.color;
|
ctx.fillStyle = item.color;
|
||||||
ctx.beginPath();
|
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();
|
ctx.fill();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function drawScore() {
|
function drawScore() {
|
||||||
ctx.fillStyle = 'white';
|
ctx.fillStyle = "white";
|
||||||
ctx.font = '24px Arial';
|
ctx.font = "24px Arial";
|
||||||
ctx.fillText(`Score: ${score}`, 20, 40); // Score at top-left corner
|
ctx.fillText(`Score: ${score}`, 20, 40); // Score at top-left corner
|
||||||
}
|
}
|
||||||
|
|
||||||
function drawAmmo() {
|
function drawAmmo() {
|
||||||
ctx.fillStyle = 'white';
|
ctx.fillStyle = "white";
|
||||||
ctx.font = '24px Arial';
|
ctx.font = "24px Arial";
|
||||||
ctx.fillText(`Ammo: ${ammo}`, 20, 70); // Ammo at top-left corner
|
ctx.fillText(`Ammo: ${ammo}`, 20, 70); // Ammo at top-left corner
|
||||||
}
|
}
|
||||||
|
|
||||||
function drawGameOver() {
|
function drawGameOver() {
|
||||||
if (isGameOver) {
|
if (isGameOver) {
|
||||||
ctx.fillStyle = 'white';
|
ctx.fillStyle = "white";
|
||||||
ctx.font = '40px Arial';
|
ctx.font = "40px Arial";
|
||||||
ctx.textAlign = 'center';
|
ctx.textAlign = "center";
|
||||||
ctx.fillText('Game Over!', canvas.width / 2, canvas.height / 2 - 40);
|
ctx.fillText("Game Over!", canvas.width / 2, canvas.height / 2 - 40);
|
||||||
ctx.font = '24px Arial';
|
ctx.font = "24px Arial";
|
||||||
ctx.fillText(`Total Score: ${score}`, canvas.width / 2, canvas.height / 2);
|
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(
|
||||||
ctx.fillText('Press "R" to Restart', canvas.width / 2, canvas.height / 2 + 80);
|
`Bullets Fired: ${totalBulletsFired}`,
|
||||||
|
canvas.width / 2,
|
||||||
|
canvas.height / 2 + 40
|
||||||
|
);
|
||||||
|
ctx.fillText(
|
||||||
|
'Press "R" to Restart',
|
||||||
|
canvas.width / 2,
|
||||||
|
canvas.height / 2 + 80
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,54 +1,65 @@
|
||||||
'use strict';
|
"use strict";
|
||||||
|
|
||||||
const targetNum = Math.trunc(Math.random() * 20) + 1;
|
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 userGuess = 10; // Default guess
|
||||||
let currScore = 20;
|
let currScore = 20;
|
||||||
|
|
||||||
const screenEl = document.querySelector('.screen');
|
const screenEl = document.querySelector(".screen");
|
||||||
const msgEl = document.querySelector('.message');
|
const msgEl = document.querySelector(".message");
|
||||||
const guessInput = document.querySelector('#guess');
|
const guessInput = document.querySelector("#guess");
|
||||||
const scoreEl = document.querySelector('.score');
|
const scoreEl = document.querySelector(".score");
|
||||||
const highScoreEl = document.querySelector('.highScore');
|
const highScoreEl = document.querySelector(".highScore");
|
||||||
const checkBtn = document.querySelector('#check');
|
const checkBtn = document.querySelector("#check");
|
||||||
const restartBtn = document.querySelector('#restart');
|
const restartBtn = document.querySelector("#restart");
|
||||||
const incBtn = document.querySelector('#up');
|
const incBtn = document.querySelector("#up");
|
||||||
const decBtn = document.querySelector('#down');
|
const decBtn = document.querySelector("#down");
|
||||||
|
|
||||||
const setMsg = msg => msgEl.textContent = msg;
|
const setMsg = (msg) => (msgEl.textContent = msg);
|
||||||
const setScore = score => scoreEl.textContent = `Score: ${currScore = score}`;
|
const setScore = (score) =>
|
||||||
|
(scoreEl.textContent = `Score: ${(currScore = score)}`);
|
||||||
const setHighScore = () => {
|
const setHighScore = () => {
|
||||||
highScoreEl.textContent = `Highscore: ${highScore}`;
|
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);
|
userGuess = Number(guessInput.textContent);
|
||||||
if (!userGuess || userGuess < 1 || userGuess > 20) {
|
if (!userGuess || userGuess < 1 || userGuess > 20) {
|
||||||
setMsg("Please enter a valid number between 1 and 20.");
|
setMsg("Please enter a valid number between 1 and 20.");
|
||||||
} else if (userGuess === targetNum) {
|
} else if (userGuess === targetNum) {
|
||||||
highScore = Math.max(highScore, currScore);
|
highScore = Math.max(highScore, currScore);
|
||||||
setHighScore();
|
setHighScore();
|
||||||
setMsg(currScore !== 20 ? 'Correct Number!' : 'Are you sure you didn\'t cheat?');
|
setMsg(
|
||||||
changeColor(currScore !== 20 ? '#1ba100' : '#FFC300');
|
currScore !== 20 ? "Correct Number!" : "Are you sure you didn't cheat?"
|
||||||
|
);
|
||||||
|
changeColor(currScore !== 20 ? "#1ba100" : "#FFC300");
|
||||||
} else {
|
} else {
|
||||||
setMsg(userGuess > targetNum ? 'Too High!' : 'Too Low!');
|
setMsg(userGuess > targetNum ? "Too High!" : "Too Low!");
|
||||||
if (currScore > 1) {
|
if (currScore > 1) {
|
||||||
setScore(currScore - 1);
|
setScore(currScore - 1);
|
||||||
} else {
|
} else {
|
||||||
setScore(1);
|
setScore(1);
|
||||||
setMsg("You lost the game!");
|
setMsg("You lost the game!");
|
||||||
changeColor('#a10000');
|
changeColor("#a10000");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
restartBtn.addEventListener('click', () => location.reload());
|
restartBtn.addEventListener("click", () => location.reload());
|
||||||
incBtn.addEventListener('click', () => guessInput.textContent = Math.min(Number(guessInput.textContent) + 1, 20));
|
incBtn.addEventListener(
|
||||||
decBtn.addEventListener('click', () => guessInput.textContent = Math.max(Number(guessInput.textContent) - 1, 1));
|
"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;
|
guessInput.textContent = userGuess;
|
||||||
setMsg('Guess a number');
|
setMsg("Guess a number");
|
||||||
setScore(currScore);
|
setScore(currScore);
|
||||||
setHighScore();
|
setHighScore();
|
||||||
|
|
|
@ -1,30 +1,116 @@
|
||||||
'use strict';
|
"use strict";
|
||||||
const left = document.querySelector('#left');
|
const left = document.querySelector("#left");
|
||||||
const right = document.querySelector('#right');
|
const right = document.querySelector("#right");
|
||||||
const gameboy = document.querySelector('.gameboy');
|
const gameboy = document.querySelector(".gameboy");
|
||||||
const html = document.documentElement;
|
const html = document.documentElement;
|
||||||
const body = document.body;
|
const body = document.body;
|
||||||
const screen = document.querySelector('.screen');
|
const screen = document.querySelector(".screen");
|
||||||
const dpadButtons = document.querySelectorAll('.dpad-btn');
|
const dpadButtons = document.querySelectorAll(".dpad-btn");
|
||||||
const dpadCenter = document.querySelector('.dpad-center'); // Darker variant
|
const dpadCenter = document.querySelector(".dpad-center"); // Darker variant
|
||||||
const actionButtons = document.querySelectorAll('.btn');
|
const actionButtons = document.querySelectorAll(".btn");
|
||||||
|
|
||||||
const colors = [
|
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: "#B39DDB",
|
||||||
{ gameboyColor: '#8BC34A', htmlColor: '#C5E1A5', screenColor: '#A5D6A7', buttonColor: '#FF5722', buttonTextColor: '#FFFFFF', dpadCenterColor: '#E64A19' },
|
htmlColor: "#D1C4E9",
|
||||||
{ gameboyColor: '#F44336', htmlColor: '#FFCDD2', screenColor: '#EF9A9A', buttonColor: '#E91E63', buttonTextColor: '#FFFFFF', dpadCenterColor: '#C2185B' },
|
screenColor: "#E1BEE7",
|
||||||
{ gameboyColor: '#03A9F4', htmlColor: '#BBDEFB', screenColor: '#90CAF9', buttonColor: '#FFEB3B', buttonTextColor: '#000000', dpadCenterColor: '#0277BD' },
|
buttonColor: "#673AB7",
|
||||||
{ gameboyColor: '#FF7043', htmlColor: '#FFCCBC', screenColor: '#FFAB91', buttonColor: '#FF5722', buttonTextColor: '#FFFFFF', dpadCenterColor: '#D84315' },
|
buttonTextColor: "#FFFFFF",
|
||||||
{ gameboyColor: '#9C27B0', htmlColor: '#E1BEE7', screenColor: '#D1C4E9', buttonColor: '#7B1FA2', buttonTextColor: '#FFFFFF', dpadCenterColor: '#6A1B9A' },
|
dpadCenterColor: "#5E35B1",
|
||||||
{ 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: "#FFC107",
|
||||||
{ gameboyColor: '#FF5733', htmlColor: '#FFCCCB', screenColor: '#FFABAB', buttonColor: '#C70039', buttonTextColor: '#FFFFFF', dpadCenterColor: '#B71C1C' },
|
htmlColor: "#FFF9C4",
|
||||||
{ gameboyColor: '#00BCD4', htmlColor: '#B2EBF2', screenColor: '#80DEEA', buttonColor: '#00ACC1', buttonTextColor: '#FFFFFF', dpadCenterColor: '#00838F' }
|
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() {
|
function updateGameBoyColor() {
|
||||||
gameboy.style.backgroundColor = colors[currentColorIndex].gameboyColor;
|
gameboy.style.backgroundColor = colors[currentColorIndex].gameboyColor;
|
||||||
|
@ -32,7 +118,7 @@ function updateGameBoyColor() {
|
||||||
body.style.backgroundColor = colors[currentColorIndex].htmlColor;
|
body.style.backgroundColor = colors[currentColorIndex].htmlColor;
|
||||||
screen.style.backgroundColor = colors[currentColorIndex].screenColor;
|
screen.style.backgroundColor = colors[currentColorIndex].screenColor;
|
||||||
|
|
||||||
dpadButtons.forEach(button => {
|
dpadButtons.forEach((button) => {
|
||||||
button.style.backgroundColor = colors[currentColorIndex].buttonColor;
|
button.style.backgroundColor = colors[currentColorIndex].buttonColor;
|
||||||
button.style.color = colors[currentColorIndex].buttonTextColor;
|
button.style.color = colors[currentColorIndex].buttonTextColor;
|
||||||
});
|
});
|
||||||
|
@ -41,21 +127,21 @@ function updateGameBoyColor() {
|
||||||
dpadCenter.style.backgroundColor = colors[currentColorIndex].dpadCenterColor;
|
dpadCenter.style.backgroundColor = colors[currentColorIndex].dpadCenterColor;
|
||||||
dpadCenter.style.color = colors[currentColorIndex].buttonTextColor;
|
dpadCenter.style.color = colors[currentColorIndex].buttonTextColor;
|
||||||
|
|
||||||
actionButtons.forEach(button => {
|
actionButtons.forEach((button) => {
|
||||||
button.style.backgroundColor = colors[currentColorIndex].buttonColor;
|
button.style.backgroundColor = colors[currentColorIndex].buttonColor;
|
||||||
button.style.color = colors[currentColorIndex].buttonTextColor;
|
button.style.color = colors[currentColorIndex].buttonTextColor;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
left.addEventListener('click', () => {
|
left.addEventListener("click", () => {
|
||||||
currentColorIndex = (currentColorIndex - 1 + colors.length) % colors.length;
|
currentColorIndex = (currentColorIndex - 1 + colors.length) % colors.length;
|
||||||
localStorage.setItem('gameboyColorIndex', currentColorIndex);
|
localStorage.setItem("gameboyColorIndex", currentColorIndex);
|
||||||
updateGameBoyColor();
|
updateGameBoyColor();
|
||||||
});
|
});
|
||||||
|
|
||||||
right.addEventListener('click', () => {
|
right.addEventListener("click", () => {
|
||||||
currentColorIndex = (currentColorIndex + 1) % colors.length;
|
currentColorIndex = (currentColorIndex + 1) % colors.length;
|
||||||
localStorage.setItem('gameboyColorIndex', currentColorIndex);
|
localStorage.setItem("gameboyColorIndex", currentColorIndex);
|
||||||
updateGameBoyColor();
|
updateGameBoyColor();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
document.getElementById('startGame').addEventListener('click', function () {
|
document.getElementById("startGame").addEventListener("click", function () {
|
||||||
const gridSize = parseInt(document.getElementById('gridSize').value);
|
const gridSize = parseInt(document.getElementById("gridSize").value);
|
||||||
const bombs = parseInt(document.getElementById('bombs').value);
|
const bombs = parseInt(document.getElementById("bombs").value);
|
||||||
|
|
||||||
document.getElementById('settings').style.display = 'none';
|
document.getElementById("settings").style.display = "none";
|
||||||
document.getElementById('game').style.display = 'block';
|
document.getElementById("game").style.display = "block";
|
||||||
|
|
||||||
renderGame(gridSize, bombs);
|
renderGame(gridSize, bombs);
|
||||||
});
|
});
|
||||||
|
|
||||||
const canvas = document.getElementById('game');
|
const canvas = document.getElementById("game");
|
||||||
const ctx = canvas.getContext('2d');
|
const ctx = canvas.getContext("2d");
|
||||||
|
|
||||||
class Minesweeper {
|
class Minesweeper {
|
||||||
constructor(width, height, bombs) {
|
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.width = width;
|
||||||
this.height = height;
|
this.height = height;
|
||||||
this.firstClick = false;
|
this.firstClick = false;
|
||||||
|
@ -36,7 +37,9 @@ class Minesweeper {
|
||||||
for (let i = 0; i < this.bombAmount; i++) {
|
for (let i = 0; i < this.bombAmount; i++) {
|
||||||
let x = Math.floor(Math.random() * this.width);
|
let x = Math.floor(Math.random() * this.width);
|
||||||
let y = Math.floor(Math.random() * this.height);
|
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;
|
this.firstClick = true;
|
||||||
}
|
}
|
||||||
|
@ -45,7 +48,12 @@ class Minesweeper {
|
||||||
let counter = 0;
|
let counter = 0;
|
||||||
for (let newX = x - 1; newX <= x + 1; newX++) {
|
for (let newX = x - 1; newX <= x + 1; newX++) {
|
||||||
for (let newY = y - 1; newY <= y + 1; newY++) {
|
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++ : {};
|
this.bombs[newX][newY] ? counter++ : {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,7 +73,7 @@ class Minesweeper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.drawField();
|
this.drawField();
|
||||||
alert('You won!');
|
alert("You won!");
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,7 +99,7 @@ class Minesweeper {
|
||||||
uncoverSquare(x, y) {
|
uncoverSquare(x, y) {
|
||||||
if (x < this.field.length && x >= 0 && y < this.field[0].length && y >= 0) {
|
if (x < this.field.length && x >= 0 && y < this.field[0].length && y >= 0) {
|
||||||
if (this.bombs[x][y] && this.field[x][y] == 1) {
|
if (this.bombs[x][y] && this.field[x][y] == 1) {
|
||||||
alert('You lost!');
|
alert("You lost!");
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
} else if (this.field[x][y] == 1) {
|
} else if (this.field[x][y] == 1) {
|
||||||
this.field[x][y] = 0;
|
this.field[x][y] = 0;
|
||||||
|
@ -99,13 +107,20 @@ class Minesweeper {
|
||||||
if (this.getNearbyBombs(x, y) == 0) {
|
if (this.getNearbyBombs(x, y) == 0) {
|
||||||
for (let newX = x - 1; newX <= x + 1; newX++) {
|
for (let newX = x - 1; newX <= x + 1; newX++) {
|
||||||
for (let newY = y - 1; newY <= y + 1; newY++) {
|
for (let newY = y - 1; newY <= y + 1; newY++) {
|
||||||
if (newX < this.field.length && newX >= 0 && newY < this.field[0].length && newY >= 0) {
|
if (
|
||||||
this.field[newX][newY] == 1 ? this.uncoverSquare(newX, newY) : {};
|
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.checkWin();
|
||||||
this.drawField();
|
this.drawField();
|
||||||
}
|
}
|
||||||
|
@ -113,11 +128,11 @@ class Minesweeper {
|
||||||
|
|
||||||
drawSquare(x, y, type) {
|
drawSquare(x, y, type) {
|
||||||
ctx.lineWidth = 3;
|
ctx.lineWidth = 3;
|
||||||
let uncovered = (x + y) % 2 === 0 ? '#D3D3D3' : '#A9A9A9';
|
let uncovered = (x + y) % 2 === 0 ? "#D3D3D3" : "#A9A9A9";
|
||||||
let covered = (x + y) % 2 === 0 ? '#4CAF50' : '#81C784';
|
let covered = (x + y) % 2 === 0 ? "#4CAF50" : "#81C784";
|
||||||
ctx.fillStyle = type != 0 ? covered : uncovered;
|
ctx.fillStyle = type != 0 ? covered : uncovered;
|
||||||
ctx.fillRect(x * this.size, y * this.size, this.size, this.size);
|
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);
|
ctx.strokeRect(x * this.size, y * this.size, this.size, this.size);
|
||||||
|
|
||||||
if (type != 1) {
|
if (type != 1) {
|
||||||
|
@ -125,11 +140,15 @@ class Minesweeper {
|
||||||
const number = this.getNearbyBombs(x, y);
|
const number = this.getNearbyBombs(x, y);
|
||||||
let finalPrint;
|
let finalPrint;
|
||||||
ctx.font = `${fontSize}px sans-serif`;
|
ctx.font = `${fontSize}px sans-serif`;
|
||||||
ctx.fillStyle = '#000';
|
ctx.fillStyle = "#000";
|
||||||
type == 0 ? finalPrint = number ? number : ' ' : {};
|
type == 0 ? (finalPrint = number ? number : " ") : {};
|
||||||
type == 2 ? finalPrint = '🚩' : {};
|
type == 2 ? (finalPrint = "🚩") : {};
|
||||||
type == 3 ? finalPrint = '❓' : {};
|
type == 3 ? (finalPrint = "❓") : {};
|
||||||
ctx.fillText(finalPrint, x * this.size + fontSize / (type == 0 ? 1.5 : 1.8), y * this.size + fontSize * 1.3);
|
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.width = this.size * this.field.length;
|
||||||
canvas.height = this.size * this.field[0].length;
|
canvas.height = this.size * this.field[0].length;
|
||||||
|
|
||||||
const offsetX = (canvas.width - (this.field.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;
|
const offsetY = (canvas.height - this.field[0].length * this.size) / 2;
|
||||||
|
|
||||||
for (let x = 0; x < this.field.length; x++) {
|
for (let x = 0; x < this.field.length; x++) {
|
||||||
for (let y = 0; y < this.field[x].length; y++) {
|
for (let y = 0; y < this.field[x].length; y++) {
|
||||||
|
@ -156,14 +175,14 @@ class Minesweeper {
|
||||||
|
|
||||||
const renderGame = (gridSize, bombs) => {
|
const renderGame = (gridSize, bombs) => {
|
||||||
let field = new Minesweeper(gridSize, gridSize, bombs);
|
let field = new Minesweeper(gridSize, gridSize, bombs);
|
||||||
window.addEventListener('resize', () => field.drawField());
|
window.addEventListener("resize", () => field.drawField());
|
||||||
canvas.addEventListener('click', (event) => {
|
canvas.addEventListener("click", (event) => {
|
||||||
const rect = canvas.getBoundingClientRect();
|
const rect = canvas.getBoundingClientRect();
|
||||||
const x = Math.floor((event.clientX - rect.left) / field.size);
|
const x = Math.floor((event.clientX - rect.left) / field.size);
|
||||||
const y = Math.floor((event.clientY - rect.top) / field.size);
|
const y = Math.floor((event.clientY - rect.top) / field.size);
|
||||||
field.uncoverSquare(x, y);
|
field.uncoverSquare(x, y);
|
||||||
});
|
});
|
||||||
canvas.addEventListener('contextmenu', (event) => {
|
canvas.addEventListener("contextmenu", (event) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
const rect = canvas.getBoundingClientRect();
|
const rect = canvas.getBoundingClientRect();
|
||||||
const x = Math.floor((event.clientX - rect.left) / field.size);
|
const x = Math.floor((event.clientX - rect.left) / field.size);
|
||||||
|
|
|
@ -8,7 +8,7 @@ body,
|
||||||
html {
|
html {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
'use strict';
|
"use strict";
|
||||||
|
|
||||||
const upButton = document.getElementById('up');
|
const upButton = document.getElementById("up");
|
||||||
const downButton = document.getElementById('down');
|
const downButton = document.getElementById("down");
|
||||||
const leftButton = document.getElementById('left');
|
const leftButton = document.getElementById("left");
|
||||||
const rightButton = document.getElementById('right');
|
const rightButton = document.getElementById("right");
|
||||||
const startButton = document.getElementById('start');
|
const startButton = document.getElementById("start");
|
||||||
const grid = document.createElement('div');
|
const grid = document.createElement("div");
|
||||||
grid.id = 'grid';
|
grid.id = "grid";
|
||||||
document.querySelector('.game').appendChild(grid);
|
document.querySelector(".game").appendChild(grid);
|
||||||
|
|
||||||
let snake = [{ x: 5, y: 5 }];
|
let snake = [{ x: 5, y: 5 }];
|
||||||
let apple = { x: 8, y: 5 };
|
let apple = { x: 8, y: 5 };
|
||||||
|
@ -17,13 +17,13 @@ let isGameRunning = false;
|
||||||
const gridSize = 10;
|
const gridSize = 10;
|
||||||
|
|
||||||
function initGame() {
|
function initGame() {
|
||||||
grid.style.display = 'grid';
|
grid.style.display = "grid";
|
||||||
grid.style.gridTemplateColumns = `repeat(${gridSize}, 1fr)`;
|
grid.style.gridTemplateColumns = `repeat(${gridSize}, 1fr)`;
|
||||||
grid.style.gridTemplateRows = `repeat(${gridSize}, 1fr)`;
|
grid.style.gridTemplateRows = `repeat(${gridSize}, 1fr)`;
|
||||||
grid.style.width = '350px';
|
grid.style.width = "350px";
|
||||||
grid.style.height = '350px';
|
grid.style.height = "350px";
|
||||||
document.getElementById('title').style.display = 'none';
|
document.getElementById("title").style.display = "none";
|
||||||
document.getElementById('description').style.display = 'none';
|
document.getElementById("description").style.display = "none";
|
||||||
|
|
||||||
isGameRunning = true;
|
isGameRunning = true;
|
||||||
snake = [{ x: 5, y: 5 }];
|
snake = [{ x: 5, y: 5 }];
|
||||||
|
@ -40,16 +40,20 @@ function spawnApple() {
|
||||||
do {
|
do {
|
||||||
newApple = {
|
newApple = {
|
||||||
x: Math.floor(Math.random() * gridSize),
|
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;
|
return newApple;
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateSnake() {
|
function updateSnake() {
|
||||||
const newHead = {
|
const newHead = {
|
||||||
x: snake[0].x + direction.x,
|
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;
|
if (newHead.x < 0) newHead.x = gridSize - 1;
|
||||||
|
@ -57,7 +61,9 @@ function updateSnake() {
|
||||||
if (newHead.x >= gridSize) newHead.x = 0;
|
if (newHead.x >= gridSize) newHead.x = 0;
|
||||||
if (newHead.y >= gridSize) newHead.y = 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();
|
gameOver();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -85,7 +91,7 @@ function render() {
|
||||||
cell.classList.add("dark-green");
|
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");
|
cell.classList.add("snake");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,40 +111,40 @@ function gameLoop() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function gameOver() {
|
function gameOver() {
|
||||||
alert('Game Over!');
|
alert("Game Over!");
|
||||||
clearInterval(gameInterval);
|
clearInterval(gameInterval);
|
||||||
isGameRunning = false;
|
isGameRunning = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleDirectionInput(key) {
|
function handleDirectionInput(key) {
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case 'ArrowUp':
|
case "ArrowUp":
|
||||||
case 'w':
|
case "w":
|
||||||
if (direction.y === 0) direction = { x: 0, y: -1 };
|
if (direction.y === 0) direction = { x: 0, y: -1 };
|
||||||
break;
|
break;
|
||||||
case 'ArrowDown':
|
case "ArrowDown":
|
||||||
case 's':
|
case "s":
|
||||||
if (direction.y === 0) direction = { x: 0, y: 1 };
|
if (direction.y === 0) direction = { x: 0, y: 1 };
|
||||||
break;
|
break;
|
||||||
case 'ArrowLeft':
|
case "ArrowLeft":
|
||||||
case 'a':
|
case "a":
|
||||||
if (direction.x === 0) direction = { x: -1, y: 0 };
|
if (direction.x === 0) direction = { x: -1, y: 0 };
|
||||||
break;
|
break;
|
||||||
case 'ArrowRight':
|
case "ArrowRight":
|
||||||
case 'd':
|
case "d":
|
||||||
if (direction.x === 0) direction = { x: 1, y: 0 };
|
if (direction.x === 0) direction = { x: 1, y: 0 };
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
upButton.addEventListener('click', () => handleDirectionInput('ArrowUp'));
|
upButton.addEventListener("click", () => handleDirectionInput("ArrowUp"));
|
||||||
downButton.addEventListener('click', () => handleDirectionInput('ArrowDown'));
|
downButton.addEventListener("click", () => handleDirectionInput("ArrowDown"));
|
||||||
leftButton.addEventListener('click', () => handleDirectionInput('ArrowLeft'));
|
leftButton.addEventListener("click", () => handleDirectionInput("ArrowLeft"));
|
||||||
rightButton.addEventListener('click', () => handleDirectionInput('ArrowRight'));
|
rightButton.addEventListener("click", () => handleDirectionInput("ArrowRight"));
|
||||||
startButton.addEventListener('click', () => {
|
startButton.addEventListener("click", () => {
|
||||||
if (!isGameRunning) initGame();
|
if (!isGameRunning) initGame();
|
||||||
});
|
});
|
||||||
|
|
||||||
document.addEventListener('keydown', (event) => {
|
document.addEventListener("keydown", (event) => {
|
||||||
handleDirectionInput(event.key);
|
handleDirectionInput(event.key);
|
||||||
});
|
});
|
||||||
|
|
|
@ -13,7 +13,7 @@ html {
|
||||||
|
|
||||||
/* GameBoy Layout */
|
/* GameBoy Layout */
|
||||||
.gameboy {
|
.gameboy {
|
||||||
background-color: #5f4c82; /* Game Boy Color purple shell */
|
background-color: #5f4c82;
|
||||||
width: 441px;
|
width: 441px;
|
||||||
height: 735px;
|
height: 735px;
|
||||||
border-radius: 20px;
|
border-radius: 20px;
|
||||||
|
|
|
@ -1,36 +1,110 @@
|
||||||
'use strict';
|
"use strict";
|
||||||
const aBtn = document.querySelector('#a');
|
const aBtn = document.querySelector("#a");
|
||||||
const bBtn = document.querySelector('#b');
|
const bBtn = document.querySelector("#b");
|
||||||
const gameboy = document.querySelector('.gameboy');
|
const gameboy = document.querySelector(".gameboy");
|
||||||
const html = document.documentElement;
|
const html = document.documentElement;
|
||||||
const body = document.body;
|
const body = document.body;
|
||||||
const dpadButtons = document.querySelectorAll('.dpad-btn');
|
const dpadButtons = document.querySelectorAll(".dpad-btn");
|
||||||
const dpadCenter = document.querySelector('.dpad-center'); // Darker variant
|
const dpadCenter = document.querySelector(".dpad-center"); // Darker variant
|
||||||
const actionButtons = document.querySelectorAll('.btn');
|
const actionButtons = document.querySelectorAll(".btn");
|
||||||
|
|
||||||
const colors = [
|
const colors = [
|
||||||
{ gameboyColor: '#B39DDB', htmlColor: '#D1C4E9', buttonColor: '#673AB7', buttonTextColor: '#FFFFFF', dpadCenterColor: '#5E35B1' },
|
{
|
||||||
{ gameboyColor: '#FFC107', htmlColor: '#FFF9C4', buttonColor: '#FF9800', buttonTextColor: '#000000', dpadCenterColor: '#EF6C00' },
|
gameboyColor: "#B39DDB",
|
||||||
{ gameboyColor: '#8BC34A', htmlColor: '#C5E1A5', buttonColor: '#FF5722', buttonTextColor: '#FFFFFF', dpadCenterColor: '#E64A19' },
|
htmlColor: "#D1C4E9",
|
||||||
{ gameboyColor: '#F44336', htmlColor: '#FFCDD2', buttonColor: '#E91E63', buttonTextColor: '#FFFFFF', dpadCenterColor: '#C2185B' },
|
buttonColor: "#673AB7",
|
||||||
{ gameboyColor: '#03A9F4', htmlColor: '#BBDEFB', buttonColor: '#FFEB3B', buttonTextColor: '#000000', dpadCenterColor: '#0277BD' },
|
buttonTextColor: "#FFFFFF",
|
||||||
{ gameboyColor: '#FF7043', htmlColor: '#FFCCBC', buttonColor: '#FF5722', buttonTextColor: '#FFFFFF', dpadCenterColor: '#D84315' },
|
dpadCenterColor: "#5E35B1",
|
||||||
{ 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: "#FFC107",
|
||||||
{ gameboyColor: '#795548', htmlColor: '#D7CCC8', buttonColor: '#9E9E9E', buttonTextColor: '#000000', dpadCenterColor: '#5D4037' },
|
htmlColor: "#FFF9C4",
|
||||||
{ gameboyColor: '#FF5733', htmlColor: '#FFCCCB', buttonColor: '#C70039', buttonTextColor: '#FFFFFF', dpadCenterColor: '#B71C1C' },
|
buttonColor: "#FF9800",
|
||||||
{ gameboyColor: '#00BCD4', htmlColor: '#B2EBF2', buttonColor: '#00ACC1', buttonTextColor: '#FFFFFF', dpadCenterColor: '#00838F' }
|
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() {
|
function updateGameBoyColor() {
|
||||||
gameboy.style.backgroundColor = colors[currentColorIndex].gameboyColor;
|
gameboy.style.backgroundColor = colors[currentColorIndex].gameboyColor;
|
||||||
html.style.backgroundColor = colors[currentColorIndex].htmlColor;
|
html.style.backgroundColor = colors[currentColorIndex].htmlColor;
|
||||||
body.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.backgroundColor = colors[currentColorIndex].buttonColor;
|
||||||
button.style.color = colors[currentColorIndex].buttonTextColor;
|
button.style.color = colors[currentColorIndex].buttonTextColor;
|
||||||
});
|
});
|
||||||
|
@ -39,21 +113,21 @@ function updateGameBoyColor() {
|
||||||
dpadCenter.style.backgroundColor = colors[currentColorIndex].dpadCenterColor;
|
dpadCenter.style.backgroundColor = colors[currentColorIndex].dpadCenterColor;
|
||||||
dpadCenter.style.color = colors[currentColorIndex].buttonTextColor;
|
dpadCenter.style.color = colors[currentColorIndex].buttonTextColor;
|
||||||
|
|
||||||
actionButtons.forEach(button => {
|
actionButtons.forEach((button) => {
|
||||||
button.style.backgroundColor = colors[currentColorIndex].buttonColor;
|
button.style.backgroundColor = colors[currentColorIndex].buttonColor;
|
||||||
button.style.color = colors[currentColorIndex].buttonTextColor;
|
button.style.color = colors[currentColorIndex].buttonTextColor;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
aBtn.addEventListener('click', () => {
|
aBtn.addEventListener("click", () => {
|
||||||
currentColorIndex = (currentColorIndex - 1 + colors.length) % colors.length;
|
currentColorIndex = (currentColorIndex - 1 + colors.length) % colors.length;
|
||||||
localStorage.setItem('gameboyColorIndex', currentColorIndex);
|
localStorage.setItem("gameboyColorIndex", currentColorIndex);
|
||||||
updateGameBoyColor();
|
updateGameBoyColor();
|
||||||
});
|
});
|
||||||
|
|
||||||
bBtn.addEventListener('click', () => {
|
bBtn.addEventListener("click", () => {
|
||||||
currentColorIndex = (currentColorIndex + 1) % colors.length;
|
currentColorIndex = (currentColorIndex + 1) % colors.length;
|
||||||
localStorage.setItem('gameboyColorIndex', currentColorIndex);
|
localStorage.setItem("gameboyColorIndex", currentColorIndex);
|
||||||
updateGameBoyColor();
|
updateGameBoyColor();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -5,12 +5,12 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
font-family: 'Courier New', Courier, monospace;
|
font-family: "Courier New", Courier, monospace;
|
||||||
background-color: #0d0d0d;
|
background-color: #0d0d0d;
|
||||||
color: #b0b0b0;
|
color: #b0b0b0;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
line-height: 1.6;
|
line-height: 1.6;
|
||||||
background-image: url('images/background.jpg');
|
background-image: url("images/background.jpg");
|
||||||
background-size: cover; /* Adjust size for tape appearance */
|
background-size: cover; /* Adjust size for tape appearance */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,22 +27,26 @@ header {
|
||||||
/* Create the flickering neon light effect */
|
/* Create the flickering neon light effect */
|
||||||
@keyframes neonFlicker {
|
@keyframes neonFlicker {
|
||||||
0% {
|
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% {
|
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% {
|
40% {
|
||||||
text-shadow: 0 0 5px #ffcc00, 0 0 15px #ffcc00, 0 0 25px #ffcc00;
|
text-shadow: 0 0 5px #ffcc00, 0 0 15px #ffcc00, 0 0 25px #ffcc00;
|
||||||
}
|
}
|
||||||
60% {
|
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% {
|
80% {
|
||||||
text-shadow: 0 0 3px #ffcc00, 0 0 7px #ffcc00, 0 0 10px #ffcc00;
|
text-shadow: 0 0 3px #ffcc00, 0 0 7px #ffcc00, 0 0 10px #ffcc00;
|
||||||
}
|
}
|
||||||
100% {
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
23
styles.css
23
styles.css
|
@ -206,7 +206,8 @@ article ul a li {
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
border-radius: var(--border-radius);
|
border-radius: var(--border-radius);
|
||||||
padding: 10px;
|
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 {
|
article ul a li:hover {
|
||||||
|
@ -263,7 +264,12 @@ section .card a {
|
||||||
section .card {
|
section .card {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
list-style: none;
|
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;
|
border-radius: 12px;
|
||||||
box-shadow: 0 5px 20px rgba(0, 0, 50, 0.8), 0 0 10px rgba(255, 255, 255, 0.1);
|
box-shadow: 0 5px 20px rgba(0, 0, 50, 0.8), 0 0 10px rgba(255, 255, 255, 0.1);
|
||||||
border: 1px solid #2e3a60;
|
border: 1px solid #2e3a60;
|
||||||
|
@ -278,7 +284,12 @@ section .card {
|
||||||
/* Hover effect */
|
/* Hover effect */
|
||||||
section .card:hover {
|
section .card:hover {
|
||||||
transform: translateY(-8px);
|
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);
|
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;
|
width: 60px;
|
||||||
height: 60px;
|
height: 60px;
|
||||||
border-radius: 50%;
|
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);
|
box-shadow: 0 0 50px rgba(255, 255, 255, 0.5);
|
||||||
animation: spin 8s linear infinite;
|
animation: spin 8s linear infinite;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ body {
|
||||||
}
|
}
|
||||||
|
|
||||||
header {
|
header {
|
||||||
background-color: #4CAF50;
|
background-color: #4caf50;
|
||||||
color: white;
|
color: white;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
padding: 1em 0;
|
padding: 1em 0;
|
||||||
|
|
Loading…
Add table
Reference in a new issue