Log In  

Cart #rat_maze-3 | 2024-04-15 | Embed ▽ | License: CC4-BY-NC-SA
4

Okay, somebody has to do it. I'm going to try making a version of the 3D Maze. No rats yet. Sorry.

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?

The interactive debugging I've thrown together is kind of fun, so I thought I'd share. Up/down keys to go forward/backward, left/right keys to turn, z/x keys to strafe. Press Enter to toggle map view and raycast render.

Changelog

  • 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.

    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.

P#145537 2024-04-03 03:28 ( Edited 2024-04-15 01:24)

> "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.

P#145542 2024-04-03 04:18

@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?)

P#145644 2024-04-04 04:27

@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
P#145647 2024-04-04 05:35

@Kaius Strange! Thanks for checking.

P#145649 2024-04-04 06:58

no need for userdata per-se, look at sspr to draw a slice of the sprite, with scaling support.

P#146682 2024-04-15 07:38

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-04-15 11:58:39 | 0.069s | Q:20