DIV ARENA FORUMS

Raycasting engine using Mode7?

Hikaru - 21-12-2016 at 05:29 PM

I love the masterpiece that is the Wolfenstein 3D port, done many years ago. So I have a couple of questions- did the coder use a combination of Mode7 and raycasting, or was there some other method used? Unfortunately, the source code wasn't shared for the port, so its secrets are kept tightly wrapped.

The other question is, how would one go about achieving similar results? I can't wrap my head around the various raycasting tutorials for other languages strewn around the 'net as they would compare to DIV. Thanks in advance if anyone can help.

CicTec - 21-12-2016 at 06:13 PM

Hi Hikaru,

Mode7 don't use raycasting, mode8 yes, DIV is open-source now, so you can see how are implemented here: https://github.com/DIVGAMES/DIV-Games-Studio

BreadCaster - 22-12-2016 at 01:33 AM

Hi there Hikaru!! Welcome to DIV-ARENA :D

Okay, well as far as I can tell, Adherbals Wolfenstein 3D remake uses two techniques. One for collisions, another for the walls themselves.

For the walls themselves - they are rows of narrow sprites. This is why they appear jagged at the edges, zig zagging sort of, it's because theyre turning to face the camera when you move, as sprites do :p these sprites are so close together that you can't see between them, this is done in a long row.

And for the collisions with those sprites - I believe it's likely to of been done using a hardness map. So, what this will mean is that the player/camera process will constantly refer to a graphic stored in the memory every frame, and will check what colour is beneath it. This will be sort of like a permissable/non-permissable areas map for the player. If the colour beneath the player is a certain colour, then the player will be reset to their last X and Y coordinate, which is easy enough to do (just put old_x=x; old_y=y; just after the main LOOP in the player/camera process, and then use " if (get_map_pixel(x, y)==whatever the colour is) x=old_x; y=old_y; End " below it.
Then, each one of the sprites in the sprite bar probably places a block of that specific colour on that graphic in the memory.

You could also use the same technique to create areas with water, areas that turn on alarms, or open doors, etc. Hardness maps + mode 7 work really well together :D


Happy coding!!!


/BC

[Edited on 22-12-2016 by BreadCaster]

BreadCaster - 22-12-2016 at 01:34 AM

Oh, also - as Cictec said - Mode 8 DOES use raycasting, mode 7 does not. Mode 7 can just display sprites on a plane :)

If you want to see what can be done in mode 8, go take a look at my Mode 8 tech test in the WIPs forum ;D

Hikaru - 31-12-2016 at 12:57 AM

Quote: Originally posted by CicTec  
Hi Hikaru,

Mode7 don't use raycasting, mode8 yes, DIV is open-source now, so you can see how are implemented here: https://github.com/DIVGAMES/DIV-Games-Studio


Thanks!

Quote: Originally posted by BreadCaster  
Hi there Hikaru!! Welcome to DIV-ARENA :D

Okay, well as far as I can tell, Adherbals Wolfenstein 3D remake uses two techniques. One for collisions, another for the walls themselves.

For the walls themselves - they are rows of narrow sprites. This is why they appear jagged at the edges, zig zagging sort of, it's because theyre turning to face the camera when you move, as sprites do :p these sprites are so close together that you can't see between them, this is done in a long row.

And for the collisions with those sprites - I believe it's likely to of been done using a hardness map. So, what this will mean is that the player/camera process will constantly refer to a graphic stored in the memory every frame, and will check what colour is beneath it. This will be sort of like a permissable/non-permissable areas map for the player. If the colour beneath the player is a certain colour, then the player will be reset to their last X and Y coordinate, which is easy enough to do (just put old_x=x; old_y=y; just after the main LOOP in the player/camera process, and then use " if (get_map_pixel(x, y)==whatever the colour is) x=old_x; y=old_y; End " below it.
Then, each one of the sprites in the sprite bar probably places a block of that specific colour on that graphic in the memory.

You could also use the same technique to create areas with water, areas that turn on alarms, or open doors, etc. Hardness maps + mode 7 work really well together :D


Happy coding!!!


/BC

[Edited on 22-12-2016 by BreadCaster]


Wow. That's a lot to get my head around. I think I'll explore Mode8 a little further instead. However, that's a pretty ingenious method that you've described. Thanks for your comment! :)


[Edited on 31-12-2016 by Hikaru]