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: 1126
Joined: Sat Mar 31, 2012 5:18 am
Location: Game-Dev. Land
Contact:

Re: Textured Raycaster

Post by Davidobot » Sat Oct 11, 2014 5:47 am

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.
My library:
LovelyMoon

Check out my current project:
Raycaster

Oh hey, I have a website now!

User avatar
Inny
Party member
Posts: 652
Joined: Fri Jan 30, 2009 3:41 am
Location: New York

Re: Textured Raycaster

Post by Inny » Sat Oct 11, 2014 4:57 pm

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: 1126
Joined: Sat Mar 31, 2012 5:18 am
Location: Game-Dev. Land
Contact:

Re: Textured Raycaster [Now with Doors!]

Post by Davidobot » Sun Jan 11, 2015 9:52 am

Massive update! Now has doors and other cool shiz! :crazy:
It's basically complete at this stage, way more advanced that Wolf3D.
My library:
LovelyMoon

Check out my current project:
Raycaster

Oh hey, I have a website now!

User avatar
jjmafiae
Party member
Posts: 1333
Joined: Tue Jul 24, 2012 8:22 am
Location: Denmark
Contact:

Re: Textured Raycaster [Now with Doors!]

Post by jjmafiae » Mon Jan 12, 2015 9:38 pm

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
My Itch.io Games (Not up to date)
My Website

User avatar
Davidobot
Party member
Posts: 1126
Joined: Sat Mar 31, 2012 5:18 am
Location: Game-Dev. Land
Contact:

Re: Textured Raycaster [Now with Doors!]

Post by Davidobot » Thu Jan 15, 2015 4:08 pm

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.
My library:
LovelyMoon

Check out my current project:
Raycaster

Oh hey, I have a website now!

User avatar
whitebear
Citizen
Posts: 86
Joined: Sun Mar 15, 2009 1:50 am

Re: Textured Raycaster [Now with Doors!]

Post by whitebear » Thu Jan 22, 2015 2:39 pm

Broke your game with forward movement towards a corner.

I assume I am not intended to be able to be at my current coordinates
http://imgur.com/q4RLXFz

User avatar
Davidobot
Party member
Posts: 1126
Joined: Sat Mar 31, 2012 5:18 am
Location: Game-Dev. Land
Contact:

Re: Textured Raycaster [Now with Doors!]

Post by Davidobot » Thu Jan 22, 2015 4:05 pm

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
http://imgur.com/q4RLXFz
Were you not able to move?
My library:
LovelyMoon

Check out my current project:
Raycaster

Oh hey, I have a website now!

User avatar
whitebear
Citizen
Posts: 86
Joined: Sun Mar 15, 2009 1:50 am

Re: Textured Raycaster [Now with Doors!]

Post by whitebear » Fri Jan 23, 2015 2:38 pm

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: 1126
Joined: Sat Mar 31, 2012 5:18 am
Location: Game-Dev. Land
Contact:

Re: Textured Raycaster [Now with Doors!]

Post by Davidobot » Thu Aug 27, 2015 10:41 am

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.
My library:
LovelyMoon

Check out my current project:
Raycaster

Oh hey, I have a website now!

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 » Sun Aug 30, 2015 6:14 pm

Wow, this is cool :)

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 6 guests