ScratchData LogoScratchData
Back to nembence's profile

Labirintus-3 (3D)

NEnembence•Created November 2, 2022
Labirintus-3 (3D)
1118
938
29296 views
View on Scratch

Instructions

This is a triangle-based 3D maze with mirror walls. This is not a real game as there are no goals or exits in the maze. Please don't advertise unrelated things in the comments. Default controls: [WASD]/[Arrow keys] to move [M] to show map Not configurable: [N] to generate a new maze [Space] to render with more reflections (turbo mode renders faster) [G] to show sphere clipping test/demo [K] to show object (a key) clipping + mirror test/demo (but they can't be rotated around the Y axis) Before seeing inside: To reduce lag in the code stop the project before seeing inside, and only scroll the code using the scroll wheel (for scrolling horizontally: Shift+scroll wheel) There are some variables in the Stage to experiment with How it works: Rendering: The maze is divided into triangular cells. Every object and wall in the maze is drawn in a way such that they can be clipped to be between two given X coordinates. The renderer starts with the cell the player is in. Then it recursively draws the neighboring cells first, clipped to the area where they are visible through the current cell, than it draws the current cell too. Instead of a sphere the project actually draws a circle. That's because while the perspective projection of the sphere has an ellipse shape, the formula is complicated and there are edge cases like where the center of the sphere is behind the camera. The shading is drawn using lines that have their top end 1 pixel offset from the bottom end. Some block names are listed here: https://scratch.mit.edu/projects/755138374/#comments-424999018 (reload page after clicking) Maze generator (based on an algorithm I found on the Wikipedia): In the maze first every wall is set to "solid" and every cell is set to "unfinished". Then a random cell is set to "finished". After that, this is repeated while there are unfinished cells: A random walk is started from a random unfinished cell. When it reaches a finished cell, all cells in the random walk are set to finished and every wall the random walk has crossed is set to "non-solid". When all cell has "finished" state, 10 random wall is chosen and set to "non-solid". My triangle coordinates and list indexing: see the costumes of the blank sprite Credits: The project is inspired by a real life mirror maze that I had seen. Maze generation algorithm: Wikipedia (Wilson's algorithm) I made most of this project a few years ago and didn't write down credits so I hope I didn't left out anything important Changelog: 2024 September 28 - added map button (until then map was available with keyboard only) 2024 September 26 - fixed a bug that caused lag when a key was pressed 2024 September 24 - added comments to variables in the Stage 2024 September 21 - added credits section to the description 2024 September 20 - updated control system - added mobile support and custom key binding 2024 September 20 - changed starting position so that the orb is visible at the start

Project Details

Project ID755138374
CreatedNovember 2, 2022
Last ModifiedOctober 10, 2024
SharedSeptember 17, 2024
Visibilityvisible
CommentsAllowed