Maze Runner: SHEEP Quest
Nov 18, 2023
v.0
Navigate through the maze with the letters S, H, E to spell out SHEEP at the exit while collecting points and bonuses. Game Interactive JavaScript Puzzle Maze HTML Game 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">
<title>Maze Runner: SHEEP Quest</title>
<meta name="description" content="Navigate through the maze with the letters S, H, E to spell out SHEEP at the exit while collecting points and bonuses.">
<meta name="keywords" content="maze, game, SHEEP, puzzle, HTML game, interactive, JavaScript">

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<style>
body, html {
height: 100%;
margin: 0;
font-family: 'Press Start 2P', cursive;
}
#maze-container {
position: relative;
width: 100%;
height: 90%;
}
.maze-cell {
position: absolute;
border: 1px solid #000;
box-sizing: border-box;
}
.wall {
background-color: #333;
}
.path, .exit {
background-color: #fff;
}
.letter {
position: absolute;
user-select: none;
font-size: 1rem;
text-align: center;
line-height: 1.5rem;
cursor: pointer;
}
.exit {
background-color: #90ee90;
}
.item-common {
color: #cccccc;
}
.item-uncommon {
color: #00ff00;
}
.item-rare {
color: #0000ff;
}
.item-epic {
color: #800080;
}
.item-mystery {
color: #ff1493;
}
#scoreboard {
padding: 10px;
background: #f0f0f0;
height: 10%;
display: flex;
justify-content: space-between;
align-items: center;
font-size: 1rem;
}
#timer {
font-size: 1.5rem;
}
.hidden {
display: none;
}
</style>
<script>
try {
const levelMultiplier = 0.01;
let currentLevel = 1;
let totalScore = 0;
let levelScore = 0;
let levelStart = null;
let levelInterval = null;
let mazeSize = 10;
let playerPosition = {x: 0, y: 0};
let exitPosition = {x: 0, y: 0};
let collectedLetters = '';
const letters = ['S', 'H', 'E'];
const itemScores = {
'common': 10,
'uncommon': 50,
'rare': 100,
'epic': 500,
'mystery': 1000
};

function createLevel() {
mazeSize += currentLevel * levelMultiplier;
// Generate maze layout, player and exit position, and items. For simplicity, a random approach is used.
// In a real scenario, a more complex algorithm like recursive division would be used.
generateMaze(Math.floor(mazeSize), Math.floor(mazeSize));
placePlayer();
placeExit();
placeItems();
levelStart = new Date();
updateTimer();
levelInterval = setInterval(updateTimer, 1000);
}

function generateMaze(width, height) {
const mazeContainer = $('#maze-container');
mazeContainer.empty();
const cellSize = `${100 / width}%`;
for (let y = 0; y < height; y++) {
for (let x = 0; x < width; x++) {
const cell = $('<div/>').addClass('maze-cell path').css({
top: `${y * cellSize}`,
left: `${x * cellSize}`,
width: cellSize,
height: cellSize
});
if (Math.random() < 0.2) {
cell.addClass('wall').removeClass('path');
}
mazeContainer.append(cell);
}
}
}

function placePlayer() {
playerPosition = {x: 0, y: 0};
$('#maze-container').append($('<div/>').addClass('letter').text('S').css({
top: `${playerPosition.y}%`,
left: `${playerPosition.x}%`
}).attr('id', 'player'));
}

function placeExit() {
exitPosition = {x: mazeSize - 1, y: mazeSize - 1};
const cellSize = `${100 / mazeSize}%`;
$('#maze-container').append($('<div/>').addClass('maze-cell exit').css({
top: `${exitPosition.y * cellSize}`,
left: `${exitPosition.x * cellSize}`,
width: cellSize,
height: cellSize
}).text('EP'));
}

function placeItems() {
// Place items randomly in the maze
const mazeContainer = $('#maze-container');
const itemTypes = ['common', 'uncommon', 'rare', 'epic', 'mystery'];
for (let i = 0; i < mazeSize; i++) {
let itemType = itemTypes[Math.floor(Math.random() * itemTypes.length)];
let pos = {
x: Math.floor(Math.random() * mazeSize),
y: Math.floor(Math.random() * mazeSize)
};
if (pos.x !== playerPosition.x || pos.y !== playerPosition.y) {
mazeContainer.append($('<div/>').addClass(`item-${itemType} letter`).css({
top: `${pos.y * (100 / mazeSize)}%`,
left: `${pos.x * (100 / mazeSize)}%`
}).text(itemType[0].toUpperCase()));
}
}
}

function updateTimer() {
const now = new Date();
const elapsed = now - levelStart;
const seconds = Math.floor(elapsed / 1000);
$('#timer').text(`Time: ${seconds}s`);
}

function collectItem(itemType, element) {
levelScore += itemScores[itemType];
$(element).remove();
updateScore();
}

function updateScore() {
$('#level-score').text(`Level Score: ${levelScore}`);
$('#total-score').text(`Total Score: ${totalScore}`);
}

function checkForExit() {
if (collectedLetters === 'SHE' && playerPosition.x === exitPosition.x && playerPosition.y === exitPosition.y) {
clearInterval(levelInterval);
totalScore += levelScore;
currentLevel++;
createLevel();
}
}

function movePlayer(direction) {
const cellSize = 100 / mazeSize;
const newPosition = {...playerPosition};
if (direction === 'up') newPosition.y--;
if (direction === 'down') newPosition.y++;
if (direction === 'left') newPosition.x--;
if (direction === 'right') newPosition.x++;

// Check for walls
const nextCell = $(`.maze-cell`).filter(function() {
const x = parseInt($(this).css('left')) / cellSize;
const y = parseInt($(this).css('top')) / cellSize;
return x === newPosition.x && y === newPosition.y;
});

if (!nextCell.hasClass('wall') && newPosition.x >= 0 && newPosition.x < mazeSize && newPosition.y >= 0 && newPosition.y < mazeSize) {
playerPosition = newPosition;
$('#player').css({
top: `${playerPosition.y * cellSize}%`,
left: `${playerPosition.x * cellSize}%`
});

const item = nextCell.hasClass('path') ? nextCell.text().toLowerCase() : null;
if (item && itemScores[item]) {
collectItem(item, nextCell);
}

const letter = nextCell.text();
if (letters.includes(letter) && !collectedLetters.includes(letter)) {
collectedLetters += letter;
}

checkForExit();
}
}

$(document).keydown(function(e) {
e.preventDefault();
switch(e.which) {
case 37: movePlayer('left'); break;
case 38: movePlayer('up'); break;
case 39: movePlayer('right'); break;
case 40: movePlayer('down'); break;
}
});

$(document).ready(function() {
createLevel();
});
} catch (error) {
throw error;
}
</script>

<link rel="canonical" href="https://calculator.tools/app/maze-runner-sheep-quest-747/">
<meta charset="utf-8">

</head>
<body>
<div id="scoreboard">
<div id="level-score">Level Score: 0</div>
<div id="timer">Time: 0s</div>
<div id="total-score">Total Score: 0</div>
</div>
<div id="maze-container"></div>
<script type="text/javascript"> var localStoragePrefix = "ct-747"; 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.