Letter Maze Adventure
Nov 18, 2023
v.0
Navigate through a maze as the letters S, H, and E to spell SHEEP and collect points! Game Maze Adventure Points Levels SHEEP

Versions  

Bugs  
None!

Get This App On Your Website

1. Copy the code above with the iframe and link.
2. Paste the code into your website.
3. Resize the iframe to fit your website.

Javascript, HTML, CSS Code

                
<!DOCTYPE html>
<html lang="en">
<head>
<script type="text/javascript"> window.addEventListener('error', function(event) { var message = JSON.parse(JSON.stringify(event.message)); var source = event.filename; var lineno = event.lineno; var colno = event.colno; var error = event.error; window.parent.postMessage({ type: 'iframeError', details: { message: message, source: source, lineno: lineno, colno: colno, error: error ? error.stack : '' } }, '*'); }); window.addEventListener('unhandledrejection', function(event) { window.parent.postMessage({ type: 'iframePromiseRejection', details: { reason: event.reason } }, '*'); }); </script>

<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Letter Maze Adventure</title>
<meta name="description" content="Navigate through a maze as the letters S, H, and E to spell SHEEP and collect points!">
<meta name="keywords" content="maze, game, adventure, SHEEP, points, levels">

<style>
body, html {
height: 100%;
margin: 0;
font-family: 'Press Start 2P', cursive;
display: flex;
justify-content: center;
align-items: center;
background: #7ec8e3;
}
#game-container {
position: relative;
display: grid;
grid-template-columns: repeat(10, 1fr);
grid-gap: 2px;
background: #8FD694;
padding: 10px;
border-radius: 10px;
}
.cell {
width: 30px;
height: 30px;
background: #FFF;
border-radius: 4px;
}
.wall {
background: #555;
}
.player {
background: #FCD34D;
display: flex;
justify-content: center;
align-items: center;
font-weight: bold;
color: #000;
}
.exit {
background: #4ADE80;
}
.point-item {
display: flex;
justify-content: center;
align-items: center;
font-weight: bold;
color: #000;
}
.common { color: #60A5FA; }
.uncommon { color: #A78BFA; }
.rare { color: #FB7185; }
.epic { color: #FBBF24; }
.mystery { color: #ECFCCB; }
#scoreboard {
position: absolute;
top: 10px;
right: 10px;
background: #FFF;
padding: 10px;
border-radius: 10px;
}
#timer {
position: absolute;
top: 10px;
left: 10px;
background: #FFF;
padding: 10px;
border-radius: 10px;
}
@keyframes blink {
50% { background: #FEF3C7; }
}
.exit.blink {
animation: blink 1s infinite;
}
</style>

<link rel="canonical" href="https://calculator.tools/app/letter-maze-adventure-745/">
<meta charset="utf-8">

</head>
<body>

<div id="game-container"></div>
<div id="scoreboard">Score: <span id="score">0</span></div>
<div id="timer">Time: <span id="time">0.00</span>s</div>

<script>
let mazeSize = 10;
let currentLevel = 1;
let totalScore = 0;
let levelTime = 0;
let interval;
let player = { letter: 'S', x: 0, y: 0, score: 0 };

const gameContainer = document.getElementById('game-container');
const scoreSpan = document.getElementById('score');
const timerSpan = document.getElementById('time');

function initializeGame() {
resetTimer();
generateMaze(mazeSize);
placePlayer();
placePointItems();
placeExit();
startTimer();
listenForMovement();
}

function generateMaze(size) {
gameContainer.innerHTML = '';
gameContainer.style.gridTemplateColumns = `repeat(${size}, 1fr)`;
for (let i = 0; i < size * size; i++) {
const cell = document.createElement('div');
cell.className = 'cell' + (Math.random() < 0.2 ? ' wall' : '');
gameContainer.appendChild(cell);
}
}

function placePlayer() {
const cells = Array.from(document.getElementsByClassName('cell'));
let cell;
do {
cell = cells[Math.floor(Math.random() * cells.length)];
} while (cell.classList.contains('wall'));
cell.classList.add('player');
cell.textContent = player.letter;
player.x = cell.cellIndex % mazeSize;
player.y = Math.floor(cell.cellIndex / mazeSize);
}

function placePointItems() {
const pointClasses = ['common', 'uncommon', 'rare', 'epic', 'mystery'];
const cells = Array.from(document.getElementsByClassName('cell'));
cells.forEach(cell => {
if (!cell.classList.contains('wall') && !cell.classList.contains('player')) {
const rarity = Math.random();
if (rarity < 0.5) {
cell.classList.add('point-item', pointClasses[0]);
cell.textContent = '🌱';
} else if (rarity < 0.75) {
cell.classList.add('point-item', pointClasses[1]);
cell.textContent = '🍀';
} else if (rarity < 0.9) {
cell.classList.add('point-item', pointClasses[2]);
cell.textContent = '🌟';
} else if (rarity < 0.98) {
cell.classList.add('point-item', pointClasses[3]);
cell.textContent = '💎';
} else {
cell.classList.add('point-item', pointClasses[4]);
cell.textContent = '❓';
}
}
});
}

function placeExit() {
const cells = Array.from(document.getElementsByClassName('cell'));
let cell;
do {
cell = cells[Math.floor(Math.random() * cells.length)];
} while (cell.classList.contains('wall') || cell.classList.contains('player') || cell.classList.contains('point-item'));
cell.classList.add('exit', 'blink');
cell.textContent = 'EP';
}

function listenForMovement() {
document.addEventListener('keydown', (e) => {
const key = e.key;
const directions = {
'ArrowUp': { x: 0, y: -1 },
'ArrowDown': { x: 0, y: 1 },
'ArrowLeft': { x: -1, y: 0 },
'ArrowRight': { x: 1, y: 0 }
};

if (directions[key]) {
movePlayer(directions[key].x, directions[key].y);
}
});
}

function movePlayer(dx, dy) {
const newX = player.x + dx;
const newY = player.y + dy;
const newCellIndex = newY * mazeSize + newX;
const newCell = gameContainer.children[newCellIndex];

if (newCell && !newCell.classList.contains('wall')) {
const currentCell = gameContainer.children[player.y * mazeSize + player.x];
if (newCell.classList.contains('point-item')) {
collectPoints(newCell);
}
if (newCell.classList.contains('exit')) {
completeLevel();
return;
}
currentCell.classList.remove('player');
currentCell.textContent = '';
newCell.classList.add('player');
newCell.textContent = player.letter;
player.x = newX;
player.y = newY;
}
}

function collectPoints(cell) {
const points = {
'common': 10,
'uncommon': 25,
'rare': 50,
'epic': 100,
'mystery': Math.floor(Math.random() * 201) // 0 to 200 points
};
for (const [key, value] of Object.entries(points)) {
if (cell.classList.contains(key)) {
player.score += value;
break;
}
}
cell.classList.remove('point-item', ...Object.keys(points));
cell.textContent = '';
updateScore();
}

function completeLevel() {
stopTimer();
totalScore += player.score;
if (currentLevel < 200) {
currentLevel++;
mazeSize = Math.floor(mazeSize * 1.01); // Increase by 1%
initializeGame();
} else {
alert(`Congratulations! You've completed all levels with a score of ${totalScore}`);
}
}

function updateScore() {
scoreSpan.textContent = player.score;
}

function startTimer() {
interval = setInterval(() => {
levelTime += 0.01;
timerSpan.textContent = levelTime.toFixed(2);
}, 10);
}

function resetTimer() {
clearInterval(interval);
levelTime = 0;
timerSpan.textContent = '0.00';
}

function stopTimer() {
clearInterval(interval);
}

initializeGame();
</script>

<script type="text/javascript"> var localStoragePrefix = "ct-745"; var lastSave = 0; function saveLocal(data) { if (Date.now() - lastSave < 1000) { return; } let cookie = localStoragePrefix + "=" + JSON.stringify(data) + "; path=" + window.location.pathname + "'; SameSite=Strict"; cookie += "; expires=" + new Date(Date.now() + 1000 * 60 * 60 * 24 * 365 * 1000).toUTCString(); document.cookie = cookie; lastSave = Date.now(); } function loadLocal() { var cookiePrefix = localStoragePrefix + "="; var cookieStart = document.cookie.indexOf(cookiePrefix); if (cookieStart > -1) { let cookieEnd = document.cookie.indexOf(";", cookieStart); if (cookieEnd == -1) { cookieEnd = document.cookie.length; } var cookieData = document.cookie.substring(cookieStart + cookiePrefix.length, cookieEnd); return JSON.parse(cookieData); } } </script>
<script type="text/javascript"> window.addEventListener('load', function() { var observer = new MutationObserver(function() { window.parent.postMessage({height: document.documentElement.scrollHeight || document.body.scrollHeight},"*"); }); observer.observe(document.body, {attributes: true, childList: true, subtree: true}); window.parent.postMessage({height: document.documentElement.scrollHeight || document.body.scrollHeight},"*"); }); </script>
</body>
</html>

NEW APPS

These are apps made by the community!

FAQ

What is Calculator Tools?

Calculator Tools allows you to instantly create and generate any simple one page web app for free and immediately have it online to use and share. This means anything! Mini apps, calculators, trackers, tools, games, puzzles, screensavers... anything you can think of that the AI can handle.

The AI uses Javacript, HTML, and CSS programming to code your app up in moments. This currently uses GPT-4 the latest and most powerful version of the OpenAI GPT language model.

What Do You Mean Make An App?

Have you ever just wanted a simple app but didn't want to learn programming or pay someone to make it for you? Calculator Tools is the solution! Just type in your prompt and the AI will generate a simple app for you in seconds. You can then customize it to your liking and share it with your friends.

AI has become so powerful it is that simple these days.

Does This Use ChatGPT?

It uses GPT-4 which is the most powerful model for ChatGPT.

Calculator Tools does not remember things from prompt to prompt, each image is a unique image that does not reference any of the images or prompts previously supplied.