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.
This is a port of Lode Vandevenne's raycasting tutorial (see: Inny's Raycaster Demo
Inny's Raycaster Demo
- Attachments
-
- innyrpgraycaster.love
- Raycaster Version 3.0
- (6.87 KiB) Downloaded 409 times
-
- innyraycaster.love
- Raycaster Version 2.0 with sprites
- (4.39 KiB) Downloaded 333 times
Last edited by Inny on Thu Dec 20, 2012 12:07 am, edited 1 time in total.
Re: Inny's Raycaster Demo
Minor changes, major AWESOME!
Use the mouse to look around.
Anyways, awesome job inny.
Use the mouse to look around.
Anyways, awesome job inny.
- Attachments
-
- mouselook.love
- Mouselook
- (4.72 KiB) Downloaded 279 times
Re: Inny's Raycaster Demo
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
Re: Inny's Raycaster Demo
I think that that's because I had it move the same amount no matter how much you move the mouse.Inny wrote:The mouse controls feel pretty janky
Re: Inny's Raycaster Demo
Oh yeah, I didn't read the code. Try multiplying by dt.Nsmurf wrote:I think that that's because I had it move the same amount no matter how much you move the mouse.Inny wrote:The mouse controls feel pretty janky
Re: Inny's Raycaster Demo
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.Inny wrote:Oh yeah, I didn't read the code. Try multiplying by dt.Nsmurf wrote:I think that that's because I had it move the same amount no matter how much you move the mouse.Inny wrote:The mouse controls feel pretty janky
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 228 times
Re: Inny's Raycaster Demo
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.
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.
-
- Party member
- Posts: 235
- Joined: Sat Dec 15, 2012 6:54 am
Re: Inny's Raycaster Demo
I'm glad I inspired youInny 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 probably restarting my engine from scratch, so looking at your code (especially for how you handle sprites) should be very useful!
Re: Inny's Raycaster Demo
Please help me with my question in this topic: viewtopic.php?f=5&t=12069&start=20 (3d page)
Who is online
Users browsing this forum: No registered users and 1 guest