Labyrinth 1

Size
2,777 Kb
Views
14,168

How do I make an labyrinth 1?

What is a labyrinth 1? How do you make a labyrinth 1? This script and codes were developed by Andrey Shchekin on 15 November 2022, Tuesday.

Labyrinth 1 Previews

Labyrinth 1 - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Labyrinth 1</title> <style> /* NOTE: The styles were added inline because Prefixfree needs access to your styles and they must be inlined if they are on local disk! */ html, body { margin: 0; padding: 0; width: 100%; height: 100%; background-color: #202a39; overflow: hidden;
} </style> <script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>
</head>
<body> <canvas></canvas> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>

Labyrinth 1 - Script Codes CSS Codes

html, body { margin: 0; padding: 0; width: 100%; height: 100%; background-color: #202a39; overflow: hidden;
}

Labyrinth 1 - Script Codes JS Codes

if (console) console.clear();
$(function() { var $body = $('body'); var $canvas = $('canvas'); var context = $canvas[0].getContext('2d'); var cellSize = 20; var maze; var paintQueue; var history; var indexInHistory; (function resize() { doResize(); //$(window).resize(doResize); function doResize() { $canvas[0].width = $body.width(); $canvas[0].height = $body.height(); maze = []; history = [{x: 0, y: 0, xOffset: 0, yOffset: 0 }]; paintQueue = [history[0]]; indexInHistory = 0; var cellWidth = Math.floor($body.width() / cellSize); var cellHeight = Math.floor($body.height() / cellSize); for (var y = 0; y < cellHeight; y++) { var row = []; row.length = cellWidth; maze.push(row); } maze[0][0] = 1; } })(); (function calculate() { var nextTimer = window.setTimeout(calculate, 0); var last = history[indexInHistory]; var beforeLast = history[indexInHistory - 1]; (function() { var choices = []; reviewChoice(choices, -1, 0); reviewChoice(choices, 1, 0); reviewChoice(choices, 0, -1); reviewChoice(choices, 0, 1); var notLadderChoices = choices.filter(function(c) { return !c.isLadder; }); if (notLadderChoices.length > 0) choices = notLadderChoices; if (choices.length === 0) { indexInHistory -= 1; history.splice(history.length - 1, 1); if (indexInHistory < 0) window.clearTimeout(nextTimer); return; } var choice = choices[Math.floor(Math.random() * choices.length)]; maze[choice.y][choice.x] = 1; history.push(choice); paintQueue.push(choice); indexInHistory += 1; })(); function reviewChoice(choices, xOffset, yOffset) { if (Math.abs(xOffset) + Math.abs(yOffset) !== 1) return; var x = last.x + xOffset; var y = last.y + yOffset; if (y < 0 || y >= maze.length) return; var row = maze[y]; if (x < 0 || x >= row.length) return; for (var xOffsetPlus = -1; xOffsetPlus <= 1; xOffsetPlus++) { for (var yOffsetPlus = -1; yOffsetPlus <= 1; yOffsetPlus++) { if (xOffset === 0 && yOffsetPlus === -yOffset) continue; if (yOffset === 0 && xOffsetPlus === -xOffset) continue; var row = maze[y + yOffsetPlus]; if (!row) continue; if (row[x + xOffsetPlus] === 1) return; } } var isLadder = (Math.abs(last.xOffset) != Math.abs(xOffset)) && beforeLast && (Math.abs(beforeLast.xOffset) != Math.abs(last.xOffset)); choices.push({ x: x, y: y, xOffset: xOffset, yOffset: yOffset, isLadder: isLadder }); } })(); (function paint() { var item; while (item = paintQueue.pop()) { context.beginPath(); context.rect(item.x * cellSize, item.y * cellSize, cellSize, cellSize); context.fillStyle = '#fff'; context.fill(); } window.requestAnimationFrame(paint); })();
});
Labyrinth 1 - Script Codes
Labyrinth 1 - Script Codes
Home Page Home
Developer Andrey Shchekin
Username ashmind
Uploaded November 15, 2022
Rating 3.5
Size 2,777 Kb
Views 14,168
Do you need developer help for Labyrinth 1?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

Andrey Shchekin (ashmind) Script Codes
Create amazing blog posts with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!