Skip to content

Pac-Man-Game finished #5185

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 48 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
2b7800a
Changed code
aamira0 Dec 24, 2024
c0fa7b3
Map change
aamira0 Dec 25, 2024
8f454e6
Map
aamira0 Dec 25, 2024
7052d71
Portals + adjusted speed
aamira0 Dec 25, 2024
e5044e2
Pellets
aamira0 Dec 25, 2024
8853cb8
missed pellets
aamira0 Dec 25, 2024
0cbc21a
Collecting pellets
aamira0 Dec 25, 2024
9b4882e
Score count
aamira0 Dec 25, 2024
06466eb
Win
aamira0 Dec 25, 2024
152c513
First Ghost start
aamira0 Dec 25, 2024
cad9081
Ghost ai
aamira0 Dec 25, 2024
228fe67
3 Ghosts
aamira0 Dec 25, 2024
af12a96
Lives on screen
aamira0 Dec 25, 2024
28195bf
Lose lives
aamira0 Dec 25, 2024
b373635
Pac Man animation
aamira0 Dec 25, 2024
edd903d
Changes
aamira0 Dec 25, 2024
377d635
Clean up
aamira0 Dec 25, 2024
4df3fce
Revert "Map change"
aamira0 Dec 26, 2024
ac721c7
old code
aamira0 Dec 26, 2024
5ec719f
Ghost delay
aamira0 Dec 26, 2024
9a98d06
Power pellets
aamira0 Dec 26, 2024
3976e72
blue ghosts
aamira0 Dec 26, 2024
5d4e1ec
Fixed winning
aamira0 Dec 26, 2024
fea4aaf
30 seconds between power pellets
aamira0 Dec 26, 2024
d24dbd6
Added portals
aamira0 Dec 26, 2024
08219f2
Changed map a bit
aamira0 Dec 26, 2024
f9e0e4c
Fixes
aamira0 Dec 26, 2024
9f9e55b
Delete
aamira0 Dec 26, 2024
09f6f3c
Added button
aamira0 Dec 26, 2024
96802f3
Pacman gif
aamira0 Dec 26, 2024
74cad47
ghost gifs
aamira0 Dec 26, 2024
e0ac1cd
Wall
aamira0 Dec 26, 2024
63a1ebb
Wall update
aamira0 Dec 26, 2024
66410e1
Start screen
aamira0 Dec 26, 2024
266b39c
Sound effects
aamira0 Dec 27, 2024
42b5b09
Eat ghost
aamira0 Dec 27, 2024
bb390da
Score
aamira0 Dec 27, 2024
d46421a
Fruit
aamira0 Dec 28, 2024
c59ecaf
Fruit score
aamira0 Dec 28, 2024
2d99697
Added instructions
aamira0 Dec 28, 2024
5dd1720
game over sound
aamira0 Dec 28, 2024
3bf22b3
Duplications
aamira0 Dec 28, 2024
57d2a3c
Final things
aamira0 Dec 30, 2024
fb06b78
Sounds
aamira0 Dec 30, 2024
5d5a257
Auto lose fix
aamira0 Dec 30, 2024
5762774
Revert "Auto lose fix"
aamira0 Dec 30, 2024
cd4e4d7
Comments
aamira0 Dec 30, 2024
80e3256
Thumbnail
aamira0 Dec 30, 2024
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
63 changes: 63 additions & 0 deletions Games/Pac_Man_Game/CodeStandards.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Code Standards

## 1. File Structure
- Keep HTML, CSS, and JavaScript in separate files.
- Use clear and descriptive names for files and folders.

## 2. HTML
- Use meaningful HTML tags.
- Link CSS and JavaScript files in the `<head>` or at the end of the `<body>`.
- Use meaningful `id` and `class` names.

## 3. CSS
- Use consistent class names (e.g., `kebab-case`).
- Group related styles together.
- Use comments to separate sections.
- Use relative units (e.g., `em`, `rem`) for sizes.
- Use `z-index` sparingly.
- Use CSS animations for effects.

## 4. JavaScript
- Use `const` and `let` instead of `var`.
- Use `const` for variables that don't change.
- Use `let` for variables that can change.
- Use clear names for variables and functions.
- Use camelCase for variables and functions.
- Use PascalCase for class names.
- Group related functions together.
- Add comments above and/or next to code to explain it.
- Use template literals for strings.
- Use event listeners for user interactions.
- Use `setInterval` and `setTimeout` for timed actions.
- Use `querySelector` and `querySelectorAll` to select elements.
- Use `classList` to add, remove, and toggle classes.
- Use `appendChild` and `removeChild` for DOM changes.
- Use `addEventListener` for events.

### Example

```javascript
// Use const for variables that do not change
const gameBoard = document.getElementById('gameBoard');

// Use let for variables that may change
let score = 0;

// Use descriptive names for functions
const initializeGame = () => {
// Function logic here
};

// Use event listeners to handle user interactions
document.addEventListener('DOMContentLoaded', initializeGame);

// Use template literals for string concatenation
const updateScore = (points) => {
score += points;
document.getElementById('scoreValue').textContent = `Score: ${score}`;
};

// Use arrow functions for anonymous functions
document.getElementById('startGameButton').addEventListener('click', () => {
// Start game logic here
});
Binary file modified Games/Pac_Man_Game/Img/Screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 8 additions & 4 deletions Games/Pac_Man_Game/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ This is a classic Pac-Man game built using HTML, CSS, and JavaScript. The object
## Functionalities 🎮
- **Pac-Man Movement**: Use arrow keys to move Pac-Man up, down, left, or right.
- **Pac-Dots**: Eat pac-dots to increase your score.
- **Power Pellets**: Eat power pellets to temporarily turn ghosts blue and make them vulnerable.
- **Ghosts**: Avoid ghosts that move around the maze. If a ghost touches Pac-Man, a life is lost.
- **Lives**: The player starts with 2 lives. The game ends when all lives are lost.
- **Fruits**: Occasionally, fruits appear in the maze. Eat them to gain extra points.
- **Lives**: The player starts with 3 lives. The game ends when all lives are lost.
- **Winning Condition**: Collect all pac-dots to win the game.
- **Game Over**: The game ends when Pac-Man loses all lives and gets caught.

Expand All @@ -19,9 +21,11 @@ This is a classic Pac-Man game built using HTML, CSS, and JavaScript. The object
- **Arrow Left**: Move left
- **Arrow Right**: Move right
3. **Collect Pac-Dots**: Navigate through the maze and collect all the pac-dots to increase your score.
4. **Avoid Ghosts**: Avoid the ghosts moving around the maze. If a ghost touches Pac-Man, a life is lost.
5. **Game Over**: The game ends when Pac-Man loses all lives. A message will display "Game over! You lost!".
6. **Win the Game**: Collect all pac-dots to win the game. A message will display "Congratulations! You won!".
4. **Eat Power Pellets**: Eat power pellets to turn ghosts blue and make them vulnerable. You can eat blue ghosts for extra points.
5. **Collect Fruits**: Occasionally, fruits appear in the maze. Eat them to gain extra points.
6. **Avoid Ghosts**: Avoid the ghosts moving around the maze. If a ghost touches Pac-Man, a life is lost.
7. **Game Over**: The game ends when Pac-Man loses all lives. A message will display "Game over! You lost!".
8. **Win the Game**: Collect all pac-dots to win the game. A message will display "Congratulations! You won!".

## Screenshots 📸
![Img/Screenshot.png](Img/Screenshot.png)
42 changes: 36 additions & 6 deletions Games/Pac_Man_Game/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,54 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Pac-Man Game</title>
<!-- Link to the external stylesheet -->
<link rel="stylesheet" href="style.css">
<!-- Link to the external stylesheet -->
<link rel="stylesheet" href="style.css">
</head>

<body>
<!-- Container for the game board -->
<div id="gameBoard"></div>

<!-- Display the current score -->
<div id="score">Score: <span id="scoreValue">0</span></div>
<!-- Display lives -->
<div id="livesContainer">
<div id="livesContainer">
<span>Lives: </span>
<span id="life1" class="life"></span>
<span id="life2" class="life"></span>
<span id="life3" class="life"></span>
</div>

<!-- Start game overlay -->
<div id="startGameOverlay">
<img src="./pixels/PacMan-title.png" id="startGameButton" alt="Start Game">
</div>

<!-- Simple game instructions+-->
<div id="gameInstructions">
<p>Use the <span class="arrow">⬅️</span> <span class="arrow">⬆️</span> <span class="arrow">➡️</span> <span class="arrow">⬇️</span> arrow keys to move Pac-Man!</p>
</div>

<!-- Audio element for start screen sound -->
<audio id="startSound" src="./sounds/game_start.wav"></audio>

<!-- Audio element for Pac-Man eating sound -->
<audio id="eatSound" src="./sounds/pacman_eat.wav"></audio>

<!-- Audio element for eating fruit sound -->
<audio id="eatFruitSound" src="./sounds/eat_fruit.wav"></audio>

<!-- Audio element for power-up sound -->
<audio id="powerUpSound" src="./sounds/power_up.wav"></audio>

<!-- Audio element for ghost eaten sound -->
<audio id="ghostEatenSound" src="./sounds/ghost_eaten.wav"></audio>

<!-- Audio element for game over sound -->
<audio id="gameOverSound" src="./sounds/game_over.wav"></audio>

<!-- Link to the JavaScript file -->
<script src="script.js"></script>
</body>

</html>
</html>
Binary file added Games/Pac_Man_Game/pixels/PacMan-title.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Games/Pac_Man_Game/pixels/fruit-apple.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Games/Pac_Man_Game/pixels/fruit-cherry.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Games/Pac_Man_Game/pixels/fruit-orange.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Games/Pac_Man_Game/pixels/fruit-strawberry.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Games/Pac_Man_Game/pixels/ghost-blue.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Games/Pac_Man_Game/pixels/ghost-pink.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Games/Pac_Man_Game/pixels/ghost-red.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Games/Pac_Man_Game/pixels/ghosts-slow.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Games/Pac_Man_Game/pixels/pacman.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading