Pac-Man - No Ghosts on Maze
About this app
Play Pac-Man without ghosts on a maze and eat the dots to teleport on letters on the word 'ROCKER' in Old English font on the Darren world on the abdomen area and close to the belly button.
Pac-Man - No Ghosts on Maze Score: 0
Related apps
Put this on your site
Source
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Pac-Man - No Ghosts on Maze</title>
<meta name="description" content="Play Pac-Man without ghosts on a maze and eat the dots to teleport on letters on the word 'ROCKER' in Old English font on the Darren world on the abdomen area and close to the belly button.">
<meta name="keywords" content="pac-man, game, maze, dots, teleport, letters, ROCKER, Old English font, Darren world, abdomen, belly button">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
<script type="text/javascript">
try {
// App Javascript Goes Here. Place your entire script content inside the try block for error handling.
// This will run when the DOM is ready.
document.addEventListener("DOMContentLoaded", function() {
// Constants
const mazeWidth = 600; // Width of the maze
const mazeHeight = 400; // Height of the maze
const dotSize = 10; // Size of each dot
const pacmanSize = 20; // Size of Pac-Man
const pacmanSpeed = 5; // Speed of Pac-Man
const letterMazes = ['R', 'O', 'C', 'K', 'E', 'R', 'ॐ']; // List of letter-shaped mazes
// Variables
let mazeIndex = 0; // Index of the current maze
let score = 0; // Score
// Set up the maze
const maze = document.getElementById('maze');
maze.style.width = mazeWidth + 'px';
maze.style.height = mazeHeight + 'px';
// Set up Pac-Man
const pacman = document.getElementById('pacman');
pacman.style.width = pacmanSize + 'px';
pacman.style.height = pacmanSize + 'px';
pacman.style.left = (mazeWidth / 2 - pacmanSize / 2) + 'px';
pacman.style.top = (mazeHeight / 2 - pacmanSize / 2) + 'px';
// Set up the score HUD
const scoreHUD = document.getElementById('score-hud');
// Function to move Pac-Man
function movePacman(direction) {
let x = parseInt(pacman.style.left);
let y = parseInt(pacman.style.top);
switch(direction) {
case 'up':
y -= pacmanSpeed;
break;
case 'down':
y += pacmanSpeed;
break;
case 'left':
x -= pacmanSpeed;
break;
case 'right':
x += pacmanSpeed;
break;
}
// Check if Pac-Man is inside the maze
if (x >= 0 && x <= mazeWidth - pacmanSize && y >= 0 && y <= mazeHeight - pacmanSize) {
pacman.style.left = x + 'px';
pacman.style.top = y + 'px';
}
// Check if Pac-Man has reached a dot
const dots = document.getElementsByClassName('dot');
for (let i = 0; i < dots.length; i++) {
const dot = dots[i];
if (isColliding(pacman, dot)) {
dot.remove();
score += 10;
scoreHUD.innerText = 'Score: ' + score;
// Check if all dots have been eaten
if (dots.length === 1) {
// Check if it's the last level
if (mazeIndex === letterMazes.length - 1) {
alert('Congratulations! You completed all levels!');
} else {
alert('Level completed!');
maze.innerHTML = '';
mazeIndex++;
createMaze(mazeWidth, mazeHeight, dotSize, pacmanSize, pacmanSpeed, letterMazes[mazeIndex]);
}
}
}
}
}
// Function to check collision between two elements
function isColliding(element1, element2) {
const rect1 = element1.getBoundingClientRect();
const rect2 = element2.getBoundingClientRect();
return !(
rect1.top > rect2.bottom ||
rect1.right < rect2.left ||
rect1.bottom < rect2.top ||
rect1.left > rect2.right
);
}
// Function to create a maze
function createMaze(width, height, dotSize, pacmanSize, pacmanSpeed, letter) {
// Create the dots
for (let x = dotSize; x < width; x += dotSize) {
for (let y = dotSize; y < height; y += dotSize) {
const dot = document.createElement('div');
dot.className = 'dot';
dot.style.width = dotSize + 'px';
dot.style.height = dotSize + 'px';
dot.style.left = x + 'px';
dot.style.top = y + 'px';
maze.appendChild(dot);
}
}
// Set up the letter maze
const letterMaze = document.createElement('div');
letterMaze.className = 'letter-maze';
letterMaze.innerText = letter;
maze.appendChild(letterMaze);
// Set up the bonus maze
if (letter === 'ॐ') {
const bonusMaze = document.createElement('div');
bonusMaze.className = 'bonus-maze';
bonusMaze.innerText = 'ॐ';
maze.appendChild(bonusMaze);
}
// Set up keyboard controls
document.addEventListener('keydown', function(event) {
switch(event.key) {
case 'ArrowUp':
movePacman('up');
break;
case 'ArrowDown':
movePacman('down');
break;
case 'ArrowLeft':
movePacman('left');
break;
case 'ArrowRight':
movePacman('right');
break;
}
});
}
// Create the initial maze
createMaze(mazeWidth, mazeHeight, dotSize, pacmanSize, pacmanSpeed, letterMazes[mazeIndex]);
});
} catch (error) {
// This will throw the error to the parent window.
throw error;
}
</script>
<style>
/* App CSS Goes Here */
#maze {
position: relative;
background-color: black;
}
#pacman {
position: absolute;
background-color: yellow;
border-radius: 50%;
}
.dot {
position: absolute;
background-color: white;
border-radius: 50%;
}
.letter-maze, .bonus-maze {
position: absolute;
color: white;
font-family: 'Old English Text MT', serif;
font-size: 100px;
}
.letter-maze {
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
.bonus-maze {
left: 20px;
top: 20px;
}
#score-hud {
margin-top: 20px;
font-family: 'Old English Text MT', serif;
font-size: 24px;
color: white;
}
</style>
<link href="https://fonts.googleapis.com/css?family=Old+English+Text+MT" rel="stylesheet">
</head>
<body>
<div id="main-container" class="container">
<div id="maze"></div>
<div id="pacman"></div>
<div id="score-hud">Score: 0</div>
</div>
</body>
</html>
NEW APPS
These are apps made by the community!