Labyrinth 1
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 - 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); })();
});
Developer | Andrey Shchekin |
Username | ashmind |
Uploaded | November 15, 2022 |
Rating | 3.5 |
Size | 2,777 Kb |
Views | 14,168 |
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!
Name | Size |
A Pen by Andrey Shchekin | 2,336 Kb |
JQuery visiblechange event | 3,129 Kb |
Wait what | 3,977 Kb |
Simple CORS test UI | 4,033 Kb |
Code Loader | 2,153 Kb |
TV Fall | 3,293 Kb |
Text Effect 1 | 3,585 Kb |
CSS | 2,419 Kb |
Hexagons | 4,360 Kb |
Text Effect 2.1 | 4,363 Kb |
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!
Name | Username | Size |
JQuery Validate checkbox group | Lunaman | 2,466 Kb |
Cant get enough icecream in pure css3 | Melawire | 4,322 Kb |
RSW | JordanC | 3,726 Kb |
The Fly | GianlucaGuarini | 3,405 Kb |
Client-side Email Validation | Collizo4sky | 1,538 Kb |
Twitch.tv API | Ryzokuken | 2,618 Kb |
Mesmerizing octopus | Jllodra | 3,549 Kb |
A Pen by Paul Sullivan | Pwsm50 | 2,349 Kb |
Pattern lab logo | TimPietrusky | 3,666 Kb |
CSS Social Media Icon | TychoBlender | 3,871 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!