diff --git a/secret/endlessRunner/index.html b/secret/endlessRunner/index.html new file mode 100644 index 0000000..e69de29 diff --git a/secret/endlessRunner/script.js b/secret/endlessRunner/script.js new file mode 100644 index 0000000..e69de29 diff --git a/secret/endlessRunner/styles.css b/secret/endlessRunner/styles.css new file mode 100644 index 0000000..e69de29 diff --git a/secret/images/default.jpeg b/secret/images/default.jpeg new file mode 100644 index 0000000..610df27 Binary files /dev/null and b/secret/images/default.jpeg differ diff --git a/secret/index.html b/secret/index.html index bbfd0d7..110c75b 100644 --- a/secret/index.html +++ b/secret/index.html @@ -31,7 +31,7 @@ - Image can't be displayed + Image can't be displayed

Secret Blackjack

@@ -41,7 +41,7 @@

- Image can't be displayed + Image can't be displayed

Snake

@@ -51,7 +51,7 @@

- Image can't be displayed + Image can't be displayed

Solitaire

@@ -81,7 +81,7 @@

- Image can't be displayed + Image can't be displayed

Endless Runner

diff --git a/secret/snake/game.js b/secret/snake/game.js new file mode 100644 index 0000000..a9f50a8 --- /dev/null +++ b/secret/snake/game.js @@ -0,0 +1,144 @@ +'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); + +let snake = [{ x: 5, y: 5 }]; +let apple = { x: 8, y: 5 }; +let direction = { x: 0, y: 0 }; +let gameInterval = null; +let isGameRunning = false; +const gridSize = 10; + +function initGame() { + 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'; + + isGameRunning = true; + snake = [{ x: 5, y: 5 }]; + apple = spawnApple(); + direction = { x: 0, y: 0 }; + + clearInterval(gameInterval); + gameInterval = setInterval(gameLoop, 200); + render(); +} + +function spawnApple() { + let newApple; + do { + newApple = { + x: Math.floor(Math.random() * gridSize), + y: Math.floor(Math.random() * gridSize) + }; + } 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 + }; + + if (newHead.x < 0) newHead.x = gridSize - 1; + if (newHead.y < 0) newHead.y = gridSize - 1; + 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)) { + gameOver(); + return; + } + + snake.unshift(newHead); + + if (newHead.x === apple.x && newHead.y === apple.y) { + apple = spawnApple(); + } else { + snake.pop(); + } +} + +function render() { + grid.innerHTML = ""; + + for (let y = 0; y < gridSize; y++) { + for (let x = 0; x < gridSize; x++) { + const cell = document.createElement("div"); + cell.classList.add("cell"); + + if ((x + y) % 2 === 0) { + cell.classList.add("light-green"); + } else { + cell.classList.add("dark-green"); + } + + if (snake.some(segment => segment.x === x && segment.y === y)) { + cell.classList.add("snake"); + } + + if (apple.x === x && apple.y === y) { + cell.classList.add("apple"); + } + + grid.appendChild(cell); + } + } +} + +function gameLoop() { + if (!isGameRunning) return; + updateSnake(); + render(); +} + +function gameOver() { + alert('Game Over!'); + clearInterval(gameInterval); + isGameRunning = false; +} + +function handleDirectionInput(key) { + switch (key) { + case 'ArrowUp': + case 'w': + if (direction.y === 0) direction = { x: 0, y: -1 }; + break; + case 'ArrowDown': + case 's': + if (direction.y === 0) direction = { x: 0, y: 1 }; + break; + case 'ArrowLeft': + case 'a': + if (direction.x === 0) direction = { x: -1, y: 0 }; + break; + 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', () => { + if (!isGameRunning) initGame(); +}); + +document.addEventListener('keydown', (event) => { + handleDirectionInput(event.key); +}); diff --git a/secret/snake/index.html b/secret/snake/index.html new file mode 100644 index 0000000..47205b4 --- /dev/null +++ b/secret/snake/index.html @@ -0,0 +1,49 @@ + + + + + + Snake - Game + + + +

+ +
+
+

Snake - Game

+
+

Description

+

Eat as many apples and grow as much as possible

+

◀ or A or arrow left = move left

+

▶ or D or arrow right = move right

+

▲ or W or arrow up = move up

+

▼ or S or arrow down = move down

+
+ +
+
+ + +
+ +
+ + +
+ + +
+ + +
+ + + +
+
+
+ + + + diff --git a/secret/snake/styles.css b/secret/snake/styles.css new file mode 100644 index 0000000..556a94a --- /dev/null +++ b/secret/snake/styles.css @@ -0,0 +1,238 @@ +/* Base Reset */ +body, +html { + margin: 0; + padding: 0; + font-family: monospace; + background-color: #3a2d56; + display: flex; + justify-content: center; + align-items: center; + height: 100vh; +} + +/* GameBoy Layout */ +.gameboy { + background-color: #5f4c82; /* Game Boy Color purple shell */ + width: 441px; + height: 735px; + border-radius: 20px; + box-shadow: 0 8px 16px rgba(0, 0, 0, 0.6); + display: flex; + flex-direction: column; + align-items: center; + padding: 10px; + position: relative; +} + +@media(max-width: 768px) { + .gameboy { + width: 100vw; + height: 100vh; + border-radius: 0; + } +} + +/* Screen */ +.screen { + background-color: black; + border: 4px solid #0f380f; + width: 90%; + height: 55%; + margin-top: 20px; + border-radius: 10px; + display: flex; + justify-content: center; + align-items: center; + box-shadow: inset 0 4px 8px rgba(0, 0, 0, 0.5); + overflow: hidden; +} + +.game { + text-align: center; + width: 90%; +} + +/* Titles */ +h1 { + font-size: 2rem; + margin-bottom: 10px; + text-transform: uppercase; + color: #9bbc0f; +} + +.description, +.description p { + font-size: 1.2rem; + margin: 0 auto; + padding: 0 auto; + color: white; +} + +/* Grid container */ +#grid { + display: grid; + grid-template-columns: repeat(10, 1fr); /* Adjust to match gridSize */ + grid-template-rows: repeat(10, 1fr); /* Adjust to match gridSize */ + width: 400px; /* Adjust as needed */ + height: 400px; /* Adjust as needed */ + border: 2px solid #0f380f; + margin: 20px auto; + /* initially hide */ + display: none; +} + +/* Individual cells */ +.cell { + width: 100%; + height: 100%; +} + +.cell.light-green { + background-color: #9bbc0f; +} + +.cell.dark-green { + background-color: #0f380f; +} + +/* Snake styling */ +.snake { + background-color: #e600ff; /* Snake color */ + z-index: 1000; +} + +/* Apple styling */ +.apple { + background-color: red; /* Apple color */ + z-index: 999; +} + +/* Controls Section */ +.controls { + margin-top: 20px; + display: flex; + justify-content: space-between; + width: 80%; + align-items: center; +} + +/* D-Pad */ +.dpad { + position: relative; + width: 120px; + height: 120px; +} + +/* Base Styling for D-Pad Buttons */ +.dpad-btn { + background-color: #0f380f; + color: #9bbc0f; + border: none; + border-radius: 5px; + position: absolute; + width: 42px; + height: 42px; + font-size: 1.5rem; + display: flex; + justify-content: center; + align-items: center; + cursor: pointer; + z-index: 1; +} + +.dpad-btn.up { + top: 0; + left: 50%; + transform: translateX(-50%); +} + +.dpad-btn.down { + bottom: 0; + left: 50%; + transform: translateX(-50%); +} + +.dpad-btn.left { + top: 50%; + left: 0; + transform: translateY(-50%); +} + +.dpad-btn.right { + top: 50%; + right: 0; + transform: translateY(-50%); +} + +/* D-Pad Center to Connect Buttons */ +.dpad-center { + background-color: #0f380f; + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + width: 40px; + height: 40px; + border: 2px solid transparent; + z-index: 0; + border-radius: 5px; +} + +/* A and B Buttons */ +.action-buttons { + display: flex; + flex-direction: column; + justify-content: space-between; + height: 200px; +} + +.btn { + background-color: #0f380f; + color: #9bbc0f; + border: 2px solid #9bbc0f; + border-radius: 50%; + width: 60px; + height: 60px; + font-size: 1.8rem; + cursor: pointer; + transition: transform 0.1s, background-color 0.2s; +} + +.btn:hover { + background-color: #9bbc0f; + color: #0f380f; +} + +.btn:active { + transform: scale(0.9); +} + +/* Start Button */ +.start-btn { + background-color: #0f380f; + color: #9bbc0f; + border: 2px solid #9bbc0f; + border-radius: 5px; + width: 100px; + height: 40px; + font-size: 1.2rem; + cursor: pointer; + transition: transform 0.1s, background-color 0.2s; + margin-bottom: 20px; +} + +.start-btn:hover { + background-color: #9bbc0f; + color: #0f380f; +} + +.start-btn:active { + transform: scale(0.9); +} + +/* Hidden Canvas for Debugging or Fallback */ +canvas { + display: none; + z-index: 1000; +} diff --git a/secret/snake/styles.js b/secret/snake/styles.js new file mode 100644 index 0000000..6706f60 --- /dev/null +++ b/secret/snake/styles.js @@ -0,0 +1,60 @@ +'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 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' } +]; + +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 => { + button.style.backgroundColor = colors[currentColorIndex].buttonColor; + button.style.color = colors[currentColorIndex].buttonTextColor; + }); + + // Using darker dpad center color + dpadCenter.style.backgroundColor = colors[currentColorIndex].dpadCenterColor; + dpadCenter.style.color = colors[currentColorIndex].buttonTextColor; + + actionButtons.forEach(button => { + button.style.backgroundColor = colors[currentColorIndex].buttonColor; + button.style.color = colors[currentColorIndex].buttonTextColor; + }); +} + +aBtn.addEventListener('click', () => { + currentColorIndex = (currentColorIndex - 1 + colors.length) % colors.length; + localStorage.setItem('gameboyColorIndex', currentColorIndex); + updateGameBoyColor(); +}); + +bBtn.addEventListener('click', () => { + currentColorIndex = (currentColorIndex + 1) % colors.length; + localStorage.setItem('gameboyColorIndex', currentColorIndex); + updateGameBoyColor(); +}); + +updateGameBoyColor(); diff --git a/webGames/index.html b/webGames/index.html index fe1628d..320999d 100644 --- a/webGames/index.html +++ b/webGames/index.html @@ -15,7 +15,7 @@
Image can't be displayed

Snake

@@ -28,7 +28,7 @@
Image can't be displayed

Solitaire

@@ -71,7 +71,7 @@
Image can't be displayed

Endless Runner