Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions INDEX.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)

Expand All @@ -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.

Expand All @@ -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/)
Expand All @@ -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

Expand Down
47 changes: 47 additions & 0 deletions Javascript/Snake Game/README.md
Original file line number Diff line number Diff line change
@@ -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.
37 changes: 37 additions & 0 deletions Javascript/Snake Game/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Snake Game</title>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<div id="welcomescreen" class="screen">
<h1>Welcome to Snake Game</h1>
<p>
Use the <b>Arrow Keys</b> to move.<br />
Eat the red apples to grow.<br />
Avoid hitting the walls or yourself!<br /><br />
Click <b>Pause</b> to pause/resume.
</p>
<button id="startbtn">Start Game</button>
</div>

<div id="gamescreen" class="screen hidden">
<div class="topbar">
<span id="score">Score: 0</span>
<button id="pausebtn">Pause</button>
</div>
<div class="grid" id="grid"></div>
</div>

<div id="gameoverscreen" class="screen hidden">
<h1>Game Over</h1>
<p id="finalscore">Your score: 0</p>
<button id="restartbtn">Restart</button>
</div>

<script src="script.js"></script>
</body>
</html>
127 changes: 127 additions & 0 deletions Javascript/Snake Game/script.js
Original file line number Diff line number Diff line change
@@ -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);
86 changes: 86 additions & 0 deletions Javascript/Snake Game/style.css
Original file line number Diff line number Diff line change
@@ -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;
}
Loading