Textured Raycaster [Multiple Levels! Door Covers! Jumping!]

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
Davidobot
Party member
Posts: 1226
Joined: Sat Mar 31, 2012 5:18 am
Location: Oxford, UK
Contact:

Re: Textured Raycaster

Post 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.
PM me on here or elsewhere if you'd like to discuss porting your game to Nintendo Switch via mazette!
personal page and a raycaster
User avatar
Inny
Party member
Posts: 652
Joined: Fri Jan 30, 2009 3:41 am
Location: New York

Re: Textured Raycaster

Post 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.
User avatar
Davidobot
Party member
Posts: 1226
Joined: Sat Mar 31, 2012 5:18 am
Location: Oxford, UK
Contact:

Re: Textured Raycaster [Now with Doors!]

Post by Davidobot »

Massive update! Now has doors and other cool shiz! :crazy:
It's basically complete at this stage, way more advanced that Wolf3D.
PM me on here or elsewhere if you'd like to discuss porting your game to Nintendo Switch via mazette!
personal page and a raycaster
jjmafiae
Party member
Posts: 1331
Joined: Tue Jul 24, 2012 8:22 am

Re: Textured Raycaster [Now with Doors!]

Post 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
User avatar
Davidobot
Party member
Posts: 1226
Joined: Sat Mar 31, 2012 5:18 am
Location: Oxford, UK
Contact:

Re: Textured Raycaster [Now with Doors!]

Post 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.
PM me on here or elsewhere if you'd like to discuss porting your game to Nintendo Switch via mazette!
personal page and a raycaster
User avatar
whitebear
Citizen
Posts: 86
Joined: Sun Mar 15, 2009 1:50 am

Re: Textured Raycaster [Now with Doors!]

Post 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
User avatar
Davidobot
Party member
Posts: 1226
Joined: Sat Mar 31, 2012 5:18 am
Location: Oxford, UK
Contact:

Re: Textured Raycaster [Now with Doors!]

Post 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?
PM me on here or elsewhere if you'd like to discuss porting your game to Nintendo Switch via mazette!
personal page and a raycaster
User avatar
whitebear
Citizen
Posts: 86
Joined: Sun Mar 15, 2009 1:50 am

Re: Textured Raycaster [Now with Doors!]

Post 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.
User avatar
Davidobot
Party member
Posts: 1226
Joined: Sat Mar 31, 2012 5:18 am
Location: Oxford, UK
Contact:

Re: Textured Raycaster [Now with Doors!]

Post 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.
PM me on here or elsewhere if you'd like to discuss porting your game to Nintendo Switch via mazette!
personal page and a raycaster
User avatar
Kasperelo
Party member
Posts: 343
Joined: Fri Apr 13, 2012 1:47 pm
Location: The Milky Way

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

Post by Kasperelo »

Wow, this is cool :)
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest