Doom Style Rendering - Demo & Capx

Show us your completed creations made in Construct 2

Post » Sun Sep 10, 2017 2:19 pm

Set myself a little challenge to see if I could make something akin to the classic Doom or Wolfenstein rendering systems.Image

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:
Image

And here is the method code:
Image

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.
Last edited by KeeghanM on Mon Sep 11, 2017 4:37 pm, edited 1 time in total.
Image
Keeghan McGarry | Managing Director
Facebook-Website
B
14
S
3
Posts: 77
Reputation: 1,081

Post » Mon Sep 11, 2017 3:54 pm

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)
ImageImageImage
B
47
S
18
G
3
Posts: 164
Reputation: 5,336

Post » Mon Sep 11, 2017 4:36 pm

Nagval333 wrote: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.
Image
Keeghan McGarry | Managing Director
Facebook-Website
B
14
S
3
Posts: 77
Reputation: 1,081

Post » Thu Sep 14, 2017 2:22 pm

Awesome! Congrats!
B
39
S
9
G
3
Posts: 261
Reputation: 4,361

Post » Thu Sep 14, 2017 8:25 pm

Brilliant! Would love to see a polished and performant version of this :)
You think your technique allows for textures and npcs?
B
15
S
6
Posts: 232
Reputation: 1,931

Post » Fri Sep 15, 2017 6:11 am

lukezero wrote:Awesome! Congrats!

Cheers!

facecrime wrote: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.
Image
Keeghan McGarry | Managing Director
Facebook-Website
B
14
S
3
Posts: 77
Reputation: 1,081

Post » Fri Sep 15, 2017 5:51 pm

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.
B
94
S
33
G
114
Posts: 5,357
Reputation: 73,775

Post » Sat Sep 16, 2017 9:20 am

@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
Image
Keeghan McGarry | Managing Director
Facebook-Website
B
14
S
3
Posts: 77
Reputation: 1,081

Post » Sun Sep 17, 2017 10:29 pm

@KeeghanM
You can look at this old topic for some examples and some links to pages that are good references.
pseudo-3d_p591377?#p591377
B
94
S
33
G
114
Posts: 5,357
Reputation: 73,775


Return to Completed Creations

Who is online

Users browsing this forum: No registered users and 2 guests