Page 3 of 8

Re: Textured Raycaster

Posted: Sat Oct 11, 2014 5:47 am
by Davidobot
Rukiri wrote:whenever I run into a wall I seem to get this error.
Error
floor.lua.54: bad argument #2 to 'draw' (Quad expected, got nil)

Traceback
[c]: in function 'draw'
floor.lua.54: in function 'drawfloor'
main.lua.92: in function 'draw'
[c]: in function 'xpcall'
I finally got around to fixing this, plus added ceilings.

Re: Textured Raycaster

Posted: Sat Oct 11, 2014 4:57 pm
by Inny
If you haven't also read this then do so: http://www.permadi.com/tutorial/raycast/index.html

There are two tricks you can use with raycasters of this type to give the illusion of height and Z-looking.

The Z-Looking is easy, the middle row vertically, or the vanishing point, you change which line on the screen that is. Or, if you calculate the top line of the wall texture as being half the screen minus half the projected size of the strip, that "half of the screen" is the variable for looking up and down.

The Z-Height is a bit more difficult, but it's also part of calculating the top of the wall. "Height" gets divided by distance to the wall and then added to where the Z-Looking line is. Walls closer get drawn proportionally lower or higher than the further walls are.

So, for a bit of math here from my own raycaster (zHeight and zLook are the two variables):

Code: Select all

    local fovratio = 1.0 / (math.pi/2)
    local vheight = 180
    local eyeLine = ((walls.size*0.5) - zHeight) * fovratio
    local topOfWall = (zLook + floor(vheight * 0.5)) - (size*0.5) - (eyeLine/dist)
Not sure how that'll affect drawing floors and ceiling.

Re: Textured Raycaster [Now with Doors!]

Posted: Sun Jan 11, 2015 9:52 am
by Davidobot
Massive update! Now has doors and other cool shiz! :crazy:
It's basically complete at this stage, way more advanced that Wolf3D.

Re: Textured Raycaster [Now with Doors!]

Posted: Mon Jan 12, 2015 9:38 pm
by jjmafiae
Davidobot wrote:Massive update! Now has doors and other cool shiz! :crazy:
It's basically complete at this stage, way more advanced that Wolf3D.
My mind is blown ;_; can you fix it? xD

Re: Textured Raycaster [Now with Doors!]

Posted: Thu Jan 15, 2015 4:08 pm
by Davidobot
jjmafiae wrote:
Davidobot wrote:Massive update! Now has doors and other cool shiz! :crazy:
It's basically complete at this stage, way more advanced that Wolf3D.
My mind is blown ;_; can you fix it? xD
*patpat* It's okay, I just redid the floors so everything should be okay.

Re: Textured Raycaster [Now with Doors!]

Posted: Thu Jan 22, 2015 2:39 pm
by whitebear
Broke your game with forward movement towards a corner.

I assume I am not intended to be able to be at my current coordinates
https://love2d.org/imgmirrur/q4RLXFz.png

Re: Textured Raycaster [Now with Doors!]

Posted: Thu Jan 22, 2015 4:05 pm
by Davidobot
whitebear wrote:Broke your game with forward movement towards a corner.

I assume I am not intended to be able to be at my current coordinates
https://love2d.org/imgmirrur/q4RLXFz.png
Were you not able to move?

Re: Textured Raycaster [Now with Doors!]

Posted: Fri Jan 23, 2015 2:38 pm
by whitebear
Nah, could bug my self out same way I came.
I think the issue is with movement diagonally into space where there is room to move to. even if two walls should "block" you.

Re: Textured Raycaster [Now with Doors!]

Posted: Thu Aug 27, 2015 10:41 am
by Davidobot
I decided to release the v6 of this raycaster to the public (v5 was not released).
This version has been floating around the forum for a while and I thought it was time to release it. Maybe someone will find it useful.
Change-log in the OP.

Re: Textured Raycaster [Multiple Levels! Door Covers! Jumpin

Posted: Sun Aug 30, 2015 6:14 pm
by Kasperelo
Wow, this is cool :)