Thread: Doors in a raycasting engine

  1. #1
    Registered User
    Join Date
    Dec 2003

    Doors in a raycasting engine

    I was wondering if someone knew how to correctly handle doors in a raycasting engine. In Wolf3d they have the doors set back and are able to animate them so it looks as though they are being opened.

    I don't know exactly how to do the animation/setting back of the doors... I was thinking that I could have a sprite in the middle of a cell and make it look set back in, but in Wolf3d it seems as though the doors are a part of the walls, not the sprites.

  2. #2
    "The Oldest Member Here" Xterria's Avatar
    Join Date
    Sep 2001
    Buffalo, NY
    it never mattered whether or not it was part of the wall, every wolf3d map consisted of same-sized square blocks. look in the wolf3d source code, i forgot which file, it simply looks at the data after it decrypts it from the resource file and makes 500x500 map with 100x100 pixel tiles. (or somthing like those dimensions)

  3. #3
    The doors in wolfy are just another type of wall. I think the way it "opens" the door is by simply sliding it through the walls next to it. When the engine has confirmed that the door is open, the solid flag is unset. If you really want to know, wolfy's source code is available for free download. I used to mod it out quite a bit.

    edit: As for the setting back part, it may just draw the door with a little bit of an offset.

  4. #4
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Cells that have doors are simply offset by a certain factor giving them the sunk-in look. For more information check out Peroxide programming tutorials PXDTUT7 and PXDTUT8 over at

    To create non-sliding doors you have several options:

    1. Create another non-ortho raycaster for just the doors. This would be very simple since there won't be lots of doors in view at any one time. For information on non-orthogonal raycasting check out articlels and resources section or google for advanced raycasting techniques. Both will lead you to the article.

    2. Actually render the doors with a 3D render and they then become textured quads. Combining the 2D and 3D worlds might pose some problems but it is not impossible.

    Also to render things like windows and doors with windows do this:

    1. Raycast the entire scene.

    2. When you hit a 'see-through' object store the current screen column and the current Y value -> in other words compute the height of the would be door but don't draw it.

    3. When you are done raycasting the scene go back to your stored values and simply do a transparentcy blit over the existing screen image. This will allow you to create windows that you can see beyond and doors with windows in them. The illusion is very cool when done right. Note that on this pass you should probably also render all of your characters so that your entire scene is done in 2 passes.

    In actuality your doors and windows and characters simply become sprite images and/or sprite cutouts that are copied onto the rendered scene.

    As you can see once the engine is up and running adding more functions to actually make it a game is pretty simple.

    If you would like to know how to do floor and ceiling mapping (texturing) as well either post in this thread or consult the second peroxide tutorial concerning raycasting - he covers it in there.

    You can figure out floor/sky mapping by yourself if you know basic trigonometry.
    Last edited by VirtualAce; 06-10-2004 at 12:06 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. In a game Engine...
    By Shamino in forum Game Programming
    Replies: 28
    Last Post: 02-19-2006, 11:30 AM
  2. Game Engine Link Prob
    By swgh in forum Game Programming
    Replies: 2
    Last Post: 01-26-2006, 12:14 AM
  3. Ultra chess engine contest
    By yodacpp in forum Projects and Job Recruitment
    Replies: 8
    Last Post: 11-21-2004, 07:58 AM
  4. Updated sound engine code
    By VirtualAce in forum Game Programming
    Replies: 8
    Last Post: 11-18-2004, 12:38 PM
  5. Game structure, any thoughts?
    By Vorok in forum Game Programming
    Replies: 2
    Last Post: 06-07-2003, 01:47 PM