From 210adef2e00b9852f109ef6eb966e1ab711303d0 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Fri, 17 Oct 2025 14:33:33 +0000 Subject: [PATCH 1/2] Auto-update INDEX.md with new games [skip ci] --- INDEX.md | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/INDEX.md b/INDEX.md index c9db9a6..f5c8ada 100644 --- a/INDEX.md +++ b/INDEX.md @@ -2,9 +2,9 @@ Welcome to Game_Scripts โ€” an open-source collection of mini games! This index automatically tracks all games across different programming languages. -Last updated: Wed Oct 15 20:32:09 UTC 2025 +Last updated: Fri Oct 17 14:33:32 UTC 2025 -Tracked 21 games across 3 languages. +Tracked 26 games across 3 languages. ## ๐Ÿ“š Table of Contents - [Java](#java-games) @@ -19,6 +19,9 @@ A fun game built with core programming concepts ### ๐ŸŽฏ [Hangman](./Java/Hangman/) ๐ŸŽฎ Hangman GUI Game +### ๐ŸŽฏ [LogGame](./Java/LogGame/) +A simple Java Swing application that lets users create and manage a live log through an interactive GUI. + ### ๐ŸŽฏ [MemoryCardGame(GUI)](./Java/MemoryCardGame(GUI)/) ๐ŸŽฎ Memory Card Matching Game (GUI) @@ -28,6 +31,9 @@ A fun game built with core programming concepts ### ๐ŸŽฏ [PongGameGUI](./Java/PongGameGUI/) ๐ŸŽฎ Pong Game GUI +### ๐ŸŽฏ [SnakeGame](./Java/SnakeGame/) +Welcome to the VS Code Java world. Here is a guideline to help you get started to write Java code in Visual Studio Code. + ### ๐ŸŽฏ [TicTacToe](./Java/TicTacToe/) The Number Guessing Game GUI is a simple and interactive game built using Java Swing. @@ -48,6 +54,12 @@ A fun game built with core programming concepts ### ๐ŸŽฏ [Stopwatch App](./Javascript/Stopwatch App/) A simple yet elegant web-based stopwatch application with start, stop, and reset functionality. +### ๐ŸŽฏ [Typing Speed Game](./Javascript/Typing Speed Game/) +A fast-paced browser game built with HTML, CSS, and JavaScript. Words fall from the top of the screen โ€” type them before they hit the bottom! Designed to improve typing speed, accuracy, and reflexes. + +### ๐ŸŽฏ [Weather Site](./Javascript/Weather Site/) +A fun game built with core programming concepts + ## Python Games ### ๐ŸŽฏ [Brick_Breaker](./Python/Brick_Breaker/) @@ -65,6 +77,9 @@ A fun game built with core programming concepts ### ๐ŸŽฏ [Snake_Game](./Python/Snake_Game/) - Language: Python +### ๐ŸŽฏ [snake_game_pygame](./Python/snake_game_pygame/) +๐Ÿ Snake Game โ€“ Pygame Edition + ### ๐ŸŽฏ [Snake_Water_Gun](./Python/Snake_Water_Gun/) By now we have 2 numbers (variables), you and computer From 320f532213be949a849a29a99ed1d2b31cb7a2ca Mon Sep 17 00:00:00 2001 From: Dhanush Date: Sat, 18 Oct 2025 13:03:52 +0530 Subject: [PATCH 2/2] Added Snake Game in JavaScript --- Javascript/Snake Game/README.md | 47 ++++++++++++ Javascript/Snake Game/index.html | 37 +++++++++ Javascript/Snake Game/script.js | 127 +++++++++++++++++++++++++++++++ Javascript/Snake Game/style.css | 86 +++++++++++++++++++++ 4 files changed, 297 insertions(+) create mode 100644 Javascript/Snake Game/README.md create mode 100644 Javascript/Snake Game/index.html create mode 100644 Javascript/Snake Game/script.js create mode 100644 Javascript/Snake Game/style.css diff --git a/Javascript/Snake Game/README.md b/Javascript/Snake Game/README.md new file mode 100644 index 0000000..9ef3ca5 --- /dev/null +++ b/Javascript/Snake Game/README.md @@ -0,0 +1,47 @@ +# ๐Ÿ Classic Retro Snake Game + +A simple **retro-style Snake Game** built using **HTML, CSS, and JavaScript**. +It features a clean pixel grid design inspired by old-school mobile games (like the Nokia Snake), with a welcome screen, pause/resume, and restart functionality. + +--- + +## ๐ŸŽฎ How to Play +- Use the **Arrow Keys** to move the snake: + - โฌ…๏ธ Left + - โžก๏ธ Right + - โฌ†๏ธ Up + - โฌ‡๏ธ Down +- Eat the **red apple** ๐ŸŽ to grow longer and increase your score. +- Avoid running into the walls or your own tail โ€” that ends the game. +- You can **pause** the game anytime using the Pause button. + +--- + +## โœจ Features +- ๐Ÿ•น๏ธ Classic grid-based snake movement +- โธ๏ธ Pause / Resume button +- ๐Ÿงพ Start and Game Over screens +- ๐Ÿ“Š Real-time score display +- ๐ŸŸฉ Retro terminal-style design (green on black) + +--- + +--- + +## ๐Ÿ“ฆ Tech Stack + +- **HTML**: Structure and layout +- **CSS**: Styling and responsive design +- **JavaScript**: Game logic, animation, and input handling + +--- + +## ๐Ÿ› ๏ธ How to Run + +1. Clone the repository: + ```bash + git clone https://github.com/devmalik7/Game_Scripts.git + cd Javascript + cd "Snake Game" + ``` +2. Run **index.html** in your browser. \ No newline at end of file diff --git a/Javascript/Snake Game/index.html b/Javascript/Snake Game/index.html new file mode 100644 index 0000000..955f8ca --- /dev/null +++ b/Javascript/Snake Game/index.html @@ -0,0 +1,37 @@ + + + + + + Snake Game + + + +
+

Welcome to Snake Game

+

+ Use the Arrow Keys to move.
+ Eat the red apples to grow.
+ Avoid hitting the walls or yourself!

+ Click Pause to pause/resume. +

+ +
+ + + + + + + + diff --git a/Javascript/Snake Game/script.js b/Javascript/Snake Game/script.js new file mode 100644 index 0000000..e29c1df --- /dev/null +++ b/Javascript/Snake Game/script.js @@ -0,0 +1,127 @@ +const gridElement = document.getElementById("grid"); +const startBtn = document.getElementById("startbtn"); +const pauseBtn = document.getElementById("pausebtn"); +const restartBtn = document.getElementById("restartbtn"); +const scoreElement = document.getElementById("score"); +const finalscoreElement = document.getElementById("finalscore"); + +const welcomeScreen = document.getElementById("welcomescreen"); +const gameScreen = document.getElementById("gamescreen"); +const gameoverScreen = document.getElementById("gameoverscreen"); + +let squares = []; +let currentSnake = [2, 1, 0]; +let direction = 1; +const width = 10; +let appleIndex = 0; +let score = 0; +let intervalTime = 300; +let speed = 0.9; +let timerId; +let paused = false; +let started = false; + +function createGrid() { + gridElement.innerHTML = ""; + squares = []; + for (let i = 0; i < width * width; i++) { + const square = document.createElement("div"); + square.classList.add("square"); + gridElement.appendChild(square); + squares.push(square); + } +} + +function startGame() { + welcomeScreen.classList.add("hidden"); + gameoverScreen.classList.add("hidden"); + gameScreen.classList.remove("hidden"); + + createGrid(); + currentSnake = [2, 1, 0]; + direction = 1; + score = 0; + intervalTime = 400; + paused = false; + started = true; + scoreElement.textContent = `Score: ${score}`; + pauseBtn.textContent = "Pause"; + + squares.forEach((i) => i.classList.remove("snake", "apple")); + currentSnake.forEach((i) => squares[i].classList.add("snake")); + + generateApple(); + + clearInterval(timerId); + timerId = setInterval(move, intervalTime); +} + +function move() { + if (paused) return; + + if ( + (currentSnake[0] + width >= width * width && direction === width) || + (currentSnake[0] % width === width - 1 && direction === 1) || + (currentSnake[0] % width === 0 && direction === -1) || + (currentSnake[0] - width < 0 && direction === -width) || + squares[currentSnake[0] + direction].classList.contains("snake") + ) { + clearInterval(timerId); + gameOver(); + return; + } + + const tail = currentSnake.pop(); + squares[tail].classList.remove("snake"); + currentSnake.unshift(currentSnake[0] + direction); + + if (squares[currentSnake[0]].classList.contains("apple")) { + squares[currentSnake[0]].classList.remove("apple"); + squares[tail].classList.add("snake"); + currentSnake.push(tail); + generateApple(); + score++; + scoreElement.textContent = `Score: ${score}`; + clearInterval(timerId); + if (intervalTime > 200) { + intervalTime = intervalTime * speed; + } + timerId = setInterval(move, intervalTime); + } + + squares[currentSnake[0]].classList.add("snake"); +} + +function generateApple() { + do { + appleIndex = Math.floor(Math.random() * squares.length); + } while (squares[appleIndex].classList.contains("snake")); + squares[appleIndex].classList.add("apple"); +} + +function control(k) { + if (!started || paused) return; + if (k.key === "ArrowRight" && direction !== -1) direction = 1; + else if (k.key === "ArrowUp" && direction !== width) direction = -width; + else if (k.key === "ArrowLeft" && direction !== 1) direction = -1; + else if (k.key === "ArrowDown" && direction !== -width) direction = +width; +} + +document.addEventListener("keydown", control); + +function stopGame() { + if (!started) return; + paused = !paused; + pauseBtn.textContent = paused ? "Resume" : "Pause"; +} + +function gameOver() { + started = false; + gameScreen.classList.add("hidden"); + gameoverScreen.classList.remove("hidden"); + finalscoreElement.textContent = `Your score: ${score}`; +} + +startBtn.addEventListener("click", startGame); +restartBtn.addEventListener("click", startGame); +pauseBtn.addEventListener("click", stopGame); diff --git a/Javascript/Snake Game/style.css b/Javascript/Snake Game/style.css new file mode 100644 index 0000000..53735e9 --- /dev/null +++ b/Javascript/Snake Game/style.css @@ -0,0 +1,86 @@ +body { + background-color: #000; + color: #0f0; + font-family: "Courier New", monospace; + display: flex; + justify-content: center; + align-items: center; + height: 100vh; + margin: 0; +} + +.screen { + text-align: center; +} + +.hidden { + display: none; +} + +.grid { + width: 400px; + height: 400px; + display: grid; + grid-template-columns: repeat(10, 1fr); + grid-template-rows: repeat(10, 1fr); + background-color: #111; + border: 3px solid #0f0; + margin: 20px auto; + box-shadow: 0 0 0 3px #030, inset 0 0 10px #030; +} + +.snake { + background-color: #0f0; + border: 1px solid #090; + box-sizing: border-box; +} + +.apple { + background-color: #f00; + border: 1px solid #800; + box-sizing: border-box; +} + +.topbar { + display: flex; + justify-content: space-between; + align-items: center; + width: 400px; + margin: 0 auto; + font-size: 16px; + color: #0f0; +} + +button { + background-color: #0f0; + color: #000; + border: 2px solid #090; + font-family: "Courier New", monospace; + font-weight: bold; + padding: 8px 18px; + cursor: pointer; + border-radius: 2px; + transition: background-color 0.1s, color 0.1s; +} + +button:hover { + background-color: #9f9; + color: #000; +} + +h1 { + color: #0f0; + text-shadow: 0 0 8px #090; +} + +p { + color: #8f8; + font-size: 15px; + line-height: 1.4; +} + +#finalscore { + color: #f66; + font-weight: bold; + margin-top: 10px; +}