wolfenstein 3D (How To)

Started by
7 comments, last by !Null 11 years, 6 months ago
So I'm trying to explore more methods of making games for experience.

And a friend of mine can make raycasting games quite well (Like Wolfenstein).

However He tried to explain how the code works and he just failed. Also I've checked a few places Online but theory doesn't work with me unless I see the code explained.

Can any of you wonderful GameDev people Help me out.

Maybe with some pointers (not 0x00000000) or some pseudo code examples to explain to me how to get at least a floor and ceiling done.

I hope someone can help.

:D
/********************************************************************************\
/**********************He Who Dares, Wins**********************************\
/********************************************************************************\
Advertisement
With old raycasting engines used in games like Wolfenstein, Doom, etc... the world is actually two-dimensional. This is the origin for the "Z = Up/Down" standard that iD Software uses as the world was originally plotted on X/Y coordinates before they expanded upon it for their 3D engines.

You would have a map consisting of lines drawn out that describe a top-down view of the level and from the player's position, you would cast rays forward. Each ray will describe a vertical strip of pixels which will be a section of what's drawn to the screen. The number of rays you cast will affect the resolution of the sections.

The distance each ray travels until it hits a wall also determines how tall the section that ray creates will be. Typically you would set a threshold for the maximum height of a wall (64 units or w/e feels right). Parts of a wall that are closer will create a shorter ray which will result in a taller strip of pixels.

In the older raycasting engines the view was generally locked on an axis so you couldn't look up or down. The ceiling and floor was created by flooding the pixels that weren't defining a wall section with a solid color. You could do this by filling half the screen with 'floor color' and the other half with 'ceiling color' then draw the walls over that.

Take a look at this series of articles on raycasting for some sample code and excellent descriptions on how ray-casting works. You'll get your own ray-caster up and running in no time ;)
What rendering API are you targeting? If you are rendering in software (pixel by pixel), then you will want to proper raycasting like the old games did. There's many tutorials on how raycasting was done for wolf-3d style engines.

However, I would recommend you put a modern spin on it and draw with a hardware accelerated API. There are many advantages:

  • When you are raycasting, you aren't drawing, you are just building a list of walls or floors that are visible to the player. You can then sort these by texture/material or whatever and just draw it.
  • You can rotate on other axes for 'free'; just mess with the modelview matrix.
  • Texturing walls and floors are easy; you don't have to deal with constant-z texture mapping
  • You can use 3d models for characters instead of sprites
  • If you're clever, a bump or displacement-mapped wolf3d level might look pretty good. You will be stuck in a 2.5D maze, but that doesn't mean the brick wall can't look bumpy and metal surfaces can't be environment mapped.
  • When the engine gets advanced enough that you want to move on from raycasting to something else (like portals & sectors), you will have a bunch of code you can reuse.
You will need a basic understanding of tile maps or you can use a tile map engine to build the maps which in this case would be the hardest part in my eyes. You also need to research the games layout, NPC stats, monsters etc. Its very important in remakes you try to replicate them best you can but add your own flavor in as well. Hope that helps.
caldiar I just wanted to say thanks for the quick detailed reply.

:)
/********************************************************************************\
/**********************He Who Dares, Wins**********************************\
/********************************************************************************\
you can check my post with some references and a sample for raycasting written in C# using XNA.

However, I would recommend you put a modern spin on it and draw with a hardware accelerated API. There are many advantages:

  • When you are raycasting, you aren't drawing, you are just building a list of walls or floors that are visible to the player. You can then sort these by texture/material or whatever and just draw it.
  • You can rotate on other axes for 'free'; just mess with the modelview matrix.
  • Texturing walls and floors are easy; you don't have to deal with constant-z texture mapping
  • You can use 3d models for characters instead of sprites
  • If you're clever, a bump or displacement-mapped wolf3d level might look pretty good. You will be stuck in a 2.5D maze, but that doesn't mean the brick wall can't look bumpy and metal surfaces can't be environment mapped.
  • When the engine gets advanced enough that you want to move on from raycasting to something else (like portals & sectors), you will have a bunch of code you can reuse.



I don't need to start a new project... I don't need to start a new project... I don't need to start a new project... Gaah!

caldiar I just wanted to say thanks for the quick detailed reply.

smile.png


Not a problem :) Ray-casters are always fun projects to work on. They're a very interesting piece of history. It's amazing to me, even today, the results you can get with the relatively simple code and basic trigonometry.

I'm really itching to put together a ray-caster now...
Not a problem Ray-casters are always fun projects to work on. They're a very interesting piece of history. It's amazing to me, even today, the results you can get with the relatively simple code and basic trigonometry.
I'm really itching to put together a ray-caster now...[/quote]

you totally should man, I like trying old things because it's good to get a sense of how things evolved.

If you wanna see the code then let me know :)
/********************************************************************************\
/**********************He Who Dares, Wins**********************************\
/********************************************************************************\

This topic is closed to new replies.

Advertisement