Inny's Raycaster Demo

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
User avatar
Inny
Party member
Posts: 652
Joined: Fri Jan 30, 2009 3:41 am
Location: New York

Inny's Raycaster Demo

Post by Inny »

UWsYG.png
UWsYG.png (9.62 KiB) Viewed 392 times
This is a port of Lode Vandevenne's raycasting tutorial (see: http://lodev.org/cgtutor/raycasting.html ), and I cleaned it up to be kind of reusable code. With all the raycasters floating around on these forums, it felt like a good way to waste a few of my free hours this weekend. One of the interesting features of this raycaster and why I picked Lode's code as the base for my implementation, is that it separates the view from a single angle into two vectors, and then moves between integer ticks on the X and Y plane.

Of course, without sprites or floor/ceiling textures, this is very far from being usable in a game. But it should be good for learning. Enjoy!

Edit: Because Lode's tutorials are simple enough, I added Sprites as well. This makes my raycaster's TimeToCrate score a solid zero. Also easy to add was "looking" up and down. It's not really looking up or down, it's just changing the virtual center of the screen.

2nd Edit: Added my most recent version, innyrpgraycaster.love, separately.
Attachments
innyrpgraycaster.love
Raycaster Version 3.0
(6.87 KiB) Downloaded 403 times
innyraycaster.love
Raycaster Version 2.0 with sprites
(4.39 KiB) Downloaded 324 times
Last edited by Inny on Thu Dec 20, 2012 12:07 am, edited 1 time in total.
User avatar
Nsmurf
Party member
Posts: 191
Joined: Fri Jul 27, 2012 1:58 am
Location: West coast.

Re: Inny's Raycaster Demo

Post by Nsmurf »

Minor changes, major AWESOME!

Use the mouse to look around.

Anyways, awesome job inny.
Attachments
mouselook.love
Mouselook
(4.72 KiB) Downloaded 272 times
OBEY!!!
My Blog
UE0gbWUgd2l0aCB0aGUgd29yZCAnSE1TRycgYXMgdGhlIHN1YmplY3Q=
User avatar
Inny
Party member
Posts: 652
Joined: Fri Jan 30, 2009 3:41 am
Location: New York

Re: Inny's Raycaster Demo

Post by Inny »

The mouse controls feel pretty janky, but I see what you're getting at. I'm debating doing stuff like ceiling/floor textures and variable height walls, but I'm not sure how to tackle it. I remember seeing a Ludum Dare that did this stuff and their postmortem said the per-pixel texture rendering is what killed their performance. But yeah, feel free to grab my code and do whatever you want with it going forward. Protip: I did everything in radians, not degrees. 180==math.pi
User avatar
Nsmurf
Party member
Posts: 191
Joined: Fri Jul 27, 2012 1:58 am
Location: West coast.

Re: Inny's Raycaster Demo

Post by Nsmurf »

Inny wrote:The mouse controls feel pretty janky
I think that that's because I had it move the same amount no matter how much you move the mouse.
OBEY!!!
My Blog
UE0gbWUgd2l0aCB0aGUgd29yZCAnSE1TRycgYXMgdGhlIHN1YmplY3Q=
User avatar
Inny
Party member
Posts: 652
Joined: Fri Jan 30, 2009 3:41 am
Location: New York

Re: Inny's Raycaster Demo

Post by Inny »

Nsmurf wrote:
Inny wrote:The mouse controls feel pretty janky
I think that that's because I had it move the same amount no matter how much you move the mouse.
Oh yeah, I didn't read the code. Try multiplying by dt.
User avatar
Nsmurf
Party member
Posts: 191
Joined: Fri Jul 27, 2012 1:58 am
Location: West coast.

Re: Inny's Raycaster Demo

Post by Nsmurf »

Inny wrote:
Nsmurf wrote:
Inny wrote:The mouse controls feel pretty janky
I think that that's because I had it move the same amount no matter how much you move the mouse.
Oh yeah, I didn't read the code. Try multiplying by dt.
I do multiply by dt, but the camera rotates the same amount if you move the mouse 1 pixel as if you moved the mouse 10 pixels, making it feel kinda laggy.

Here, I fixed it, kinda. It still feels off to me, but at this point, it would need a sensitivity variable.
Attachments
mouselook.love
Mouselook, kinnda-fixedish.
(4.74 KiB) Downloaded 223 times
OBEY!!!
My Blog
UE0gbWUgd2l0aCB0aGUgd29yZCAnSE1TRycgYXMgdGhlIHN1YmplY3Q=
User avatar
Inny
Party member
Posts: 652
Joined: Fri Jan 30, 2009 3:41 am
Location: New York

Re: Inny's Raycaster Demo

Post by Inny »

I'm bumping this thread, in light of scutheotaku's thread ( viewtopic.php?f=5&t=12069 ). This is the most recent version of my code, and has support for changing the height of the eyes, as well as scaling sprites, or sticking them to the ceiling. This isn't to steal some of his thunder, but rather to help him out with his engine with some more code examples. (good luck dude!) For anyone else reading the code, looking for the techniques, they're contained within raycaster.lua

The keyboard controls are separated out into controls.lua because I was doing some experimenting with an rpg style movement around the map. PageUp/PageDown can be used for "Looking", Home/End can be used for "Flying", and Alt+Left/Right for strafing. I didn't include nsmurf's mouse controls, since they don't make sense in this scheme.
scutheotaku
Party member
Posts: 235
Joined: Sat Dec 15, 2012 6:54 am

Re: Inny's Raycaster Demo

Post by scutheotaku »

Inny wrote:I'm bumping this thread, in light of scutheotaku's thread ( viewtopic.php?f=5&t=12069 ). This is the most recent version of my code, and has support for changing the height of the eyes, as well as scaling sprites, or sticking them to the ceiling. This isn't to steal some of his thunder, but rather to help him out with his engine with some more code examples. (good luck dude!) For anyone else reading the code, looking for the techniques, they're contained within raycaster.lua

The keyboard controls are separated out into controls.lua because I was doing some experimenting with an rpg style movement around the map. PageUp/PageDown can be used for "Looking", Home/End can be used for "Flying", and Alt+Left/Right for strafing. I didn't include nsmurf's mouse controls, since they don't make sense in this scheme.
I'm glad I inspired you :D

I'm probably restarting my engine from scratch, so looking at your code (especially for how you handle sprites) should be very useful!
User avatar
IndieKid
Citizen
Posts: 80
Joined: Sat Dec 22, 2012 7:05 pm
Contact:

Re: Inny's Raycaster Demo

Post by IndieKid »

Please help me with my question in this topic: viewtopic.php?f=5&t=12069&start=20 (3d page)
Post Reply

Who is online

Users browsing this forum: No registered users and 53 guests