Doom Style Rendering - Demo & Capx

0 favourites
  • 9 posts
From the Asset Store
Demo Game Multiplayer Online with member registration system
  • Set myself a little challenge to see if I could make something akin to the classic Doom or Wolfenstein rendering systems.

    I accomplished this with a raycast technique. Every tick I have a sprite rotate through the FOV, going up 1 degree of angle per loop iteration. It grows until it touches a wall. At which case it sets one of the vertical "Pixels" to a certain height based on the distance to the wall, and then also a colour.

    Because it uses a while loop to grow until it touches a wall.... The performance lags when the walls are far away (like long corridors). I'm sure there are ways to fix this... increase the growth steps... or some other method of checking the distance.. But it seems to be OK.

    Heres what mine looks like:

    And here is the method code:

    If you want to have a walk around, I have uploaded it to the Scirra Arcade. *NOPE, doesn't work in the arcade, refuses to load*

    You can also get the capx here!

    All in all this took me about 2 hours to create. I'm sure there's much much better ways to do this, but I thought it was a fun wee challenge and I'm pretty happy with how it turned out!

    Lemme know your thoughts, and how you would go about doing this! Always interested in hearing other peoples ideas.

  • I have downloaded caps and from the first view its looks interesting. However the scirra arcade example doesn't work (not for Chrome and not for FireFox)

  • I have downloaded caps and from the first view its looks interesting. However the scirra arcade example doesn't work (not for Chrome and not for FireFox)

    Hmmm, you're right. That's annoying. Works in them all running from the capx.. wonder why it's not working on the Arcade. Ah well, I'll remove it.

  • Awesome! Congrats!

  • Brilliant! Would love to see a polished and performant version of this

    You think your technique allows for textures and npcs?

  • Awesome! Congrats!

    Cheers!

    Brilliant! Would love to see a polished and performant version of this

    You think your technique allows for textures and npcs?

    Sadly this technique doesn't allow for detailed textures. However because each wall block is actually a bunch of repeated sprites, you could deisgn the texture to be horizontally seamless, but you would get limited detailed in that plane. Lines going horizontally along the wall is definitely doable though.

    I'm sure you could get NPC's, but they would have to be rendered with a different pass, essentially use the same technique but a second time.

  • A few thoughts:

    The walls have a curved distortion. You can correct that by multiplying the height of the walls by cos(player.angle-raycast.angle) or something like that.

    You don't need to make the sprites so big. You could make them 32x32 and they would be able to be stretched to any size you want. That would make for a smaller download.

    It possibly may not work when you export the the arcade due to the frames being packed together and the filtering causing the wall slices to not be visible. I don't have any thoughts on correcting that yet.

    Textured walls should be no problem. Take say a 128x128 texture you want to use and import it as spritesheet in the image editor with 128 horizontal parts. You'll then have 128 vertical slices of the texture and you just set that from where you hit the wall.

    The raycasting events can also be changed in many ways:

    One way could be to jump 16 pixels at a time, then when a wall is hit it would back out 8 at a time until not overlapping, then back forward by 4... and so on till it's precise enough for you. It would be more efficient for further distances.

    You could also make the loop stop if the distance got too big so far away stuff just wouldn't be drawn.

    Another approach could be to line intersection math of the ray against the four edges of the walls ( or only some of them that actually face the player). It would be more precise and would make finding where on wall easier for texturing purposes.

    The is also a raycast plugin that could be useful instead of the previous.

    A final idea would be to use what wolf3d actually used, a dda. Basically it would step the ray along the edges of a grid, and supposedly it is very efficient. Most wolf3d tutorials online explain it in more detail.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • R0J0hound .. Thank you! Always good to get such intelligent input!

    Will definitely have to play around with some of those ideas next time I need a break from my main project

  • KeeghanM

    You can look at this old topic for some examples and some links to pages that are good references.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)