Okay, somebody has to do it. I'm going to try making a version of the 3D Maze. No rats yet. Sorry.
Update: This is usable as a screensaver now! There are more features from the original to implement, but I think it's already pretty fun as-is.
- Press
a
to toggle automatic mode (on by default). - Out of automatic mode: Up/down keys to go forward/backward, left/right keys to turn, z/x keys to strafe.
- In either mode: Press
m
to toggle map view and raycast render. Presss
to display CPU and RAM usage.
Warning: CPU usage is about 100%. The raycasting is expensive and I haven't felt like optimizing it yet because this project is for fun and that isn't where the fun is right now. I think it runs plenty smooth (60fps is overrated), but if your fantasy computer tends to overheat or you have big computations running in the background that you don't want your screensaver slowing down, watch out! :)
Changelog
-
v1.2 Performance improvements from like 120% to 100%. Mostly moving some things out of loops and caching repeated calculations. Also turned the player's position into a vector. This was a slightly anti-performance improvement, but non-raycasting CPU is at 5% so the code clarity is very worth it.
-
v1.1 Added random maze generation! Using a plain old backtracking algorithm. (Let me know if you have any idea what algorithm the original rat maze used.) Fixed a bug where you got stuck in an infinite spin if initially facing the wall in a left-to-right hallway. You now start in a random position in the maze. Press "s" to pull up CPU and RAM stats. Press "m" to switch to an overhead view (was previously "enter").
-
v1.0 Changed textures and floor/ceiling to match the real screensaver. Added an automatic mode, which is on by default. This is the screensaver mode, where the player automatically follows the right wall in the maze. Added a maze, but it's always the same. Randomly generated mazes will come in a future update.
-
v0.5 Textured walls now pick their texture based on the map data.
-
v0.4 Implemented textured walls. It is very slow, but I haven't done any optimization yet so there's still hope. Changed movement to feel more natural in first-person mode.
Currently drawing pixel by pixel because I need to learn how to draw only a vertical slice of a sprite (userdata). Does anyone know how? The userdata docs are a little over my head.
-
v0.3.1 Fixed an off-by-one bug that was causing some walls to be studded with spikes. What a relief.
-
v0.3 Calculate which wall is closer (vertical or horizontal). Add raycast view (press Enter to switch to it). I'm getting a weird spike artifact in the render. Colored vertical and horizontal walls differently, revealing that the incorrect wall is identified as "closer" during the spikes. I don't know what's causing that to happen. Finished Part 9 (drawing walls) of Permadi tutorial.
-
v0.2 First public version. Finished Part 7 (finding wall intersections) of Permadi tutorial.
I'm going to start by working through Permadi's 1996 Ray Casting Tutorial. It's really cool to be implementing such an old graphics tutorial. Anyone know of any other gems out there?
Question for those with more PICO8 experience than me: Is it worth using bit shift operations instead of multiplication/division by a power of two? I'm keeping it as-is for now for readability reasons, but after the raycasting logic is finished, it might be fun to see if it speeds it up.
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
![](/media/65920/8_Red Mushroom Avatar.jpg)
> "Question for those with more PICO8 experience than me: Is it worth using bit shift operations instead of multiplication/division by a power of two? I'm keeping it as-is for now for readability reasons, but after the raycasting logic is finished, it might be fun to see if it speeds it up."
I just tested it, and the answer is no, there is no difference between x=1<<1
and x=1*2
in terms of performance.
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
![](https://www.lexaloffle.com/bimg/pi/pi1.png)
@Kaius Hmm, interesting. Could that be an edge case? (As in, could they be the same, but x = 1 << 4
be faster than x = 1 * 16
?)
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
![](/media/65920/8_Red Mushroom Avatar.jpg)
@Snail_God ...Nope, still no performance difference found between any of:
x=1<<4
x=1*16
x=3<<3
x=3*8
x=12<<5
x=12*32
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
![](https://www.lexaloffle.com/bbs/files/25532/icon.png)
no need for userdata per-se, look at sspr to draw a slice of the sprite, with scaling support.
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
![](https://www.lexaloffle.com/bimg/pi/pi1.png)
@freds72 oh!! I completely misremembered what sspr was for, yeah that's exactly what I need. thank you for saving my life :')
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
![](https://www.lexaloffle.com/bimg/pi/pi1.png)
@Pickelrye Thank you! Happy to hear you're enjoying it. I just put out a new release with random maze generation :)
[Please log in to post a comment]