![]() |
||||||||||||||||||||||||||||||||||||||||||
Fun with Ray Casting - Printable Version +- QB64 Phoenix Edition (https://qb64phoenix.com/forum) +-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1) +--- Forum: Prolific Programmers (https://qb64phoenix.com/forum/forumdisplay.php?fid=26) +---- Forum: a740g (https://qb64phoenix.com/forum/forumdisplay.php?fid=56) +---- Thread: Fun with Ray Casting (/showthread.php?tid=3372) Pages:
1
2
|
||||||||||||||||||||||||||||||||||||||||||
Fun with Ray Casting - a740g - 01-13-2025 It all started with this post. This is an implementation of the Voxel Space ray casting in QB64-PE. The algorithm is explained here. You'll need QB64-PE v4 to compile and tinker. This is just a demo, not a complete game. At best, it can be called a walking simulator. ![]() The demo is configured to best perform for my Ryzen 5600x system. If you see low FPS, tweak the RENDER_DISTANCE and RENDER_DELTA_Z_INCREMENT constants at the top of the source code. Code: (Select All) CONTROLS: Mouselook may be broken on Linux because of how _MOUSEMOVEMENTX/Y is implemented in QB64. We'll fix this soon™. Have fun. Cheers! ![]() Adding my original solid-wall RayCaster here for completeness. I'll keep posting other ray-casting-related stuff in this thread in the future. ![]() RE: Fun with Ray Casting - Bhsdfa - 01-13-2025 Code: (Select All)
I didn't know that making a type variable as a type was even possible :o RE: Fun with Ray Casting - a740g - 01-15-2025 (01-13-2025, 01:45 AM)Bhsdfa Wrote: Yes, it is. What's strange is that this is allowed in a case-insensitive language. This isn't new to QB64, but rather something that has been possible since the days of QuickBASIC (even older I think). I simply adjust the variable name and type name case to make it look a bit nicer. RE: Fun with Ray Casting - SierraKen - 01-15-2025 WOW!!!!!! I remember years ago someone made something similar to this, but there were over 1000 lines, maybe many 1000. Thanks for showing me this. I did notice that the Esc key doesn't work for some reason. You might want to use LOOP until inkey$=chr$(27) or .... chr$(27) is Esc on IBM compatibles. I don't know if I can use this code, but it sure amazes me, I'm just not to that level of programming. But I know others here are I'm sure. Thanks for posting this. RE: Fun with Ray Casting - NakedApe - 01-15-2025 Killer!! That's like Mindcraft in 400 lines. Very impressive. I can't wait for more enhancements... ![]() RE: Fun with Ray Casting - Petr - 01-15-2025 Thanks for sharing. I don't understand the GetHertz function at all, SUB RenderFrame is very interesting and the placement of the heightmap and surface map in the form of a three-dimensional array is simply brilliant. Thanks for sharing. I also found a few new commands there that I might not have known about. It's a very nice job. RE: Fun with Ray Casting - a740g - 01-16-2025 (01-15-2025, 07:45 PM)NakedApe Wrote: Killer!! That's like Mindcraft in 400 lines. Very impressive. I can't wait for more enhancements...Thanks! ![]() Minecraft is way more advanced. Aaditya and Petr did some awesome work: https://qb64phoenix.com/forum/showthread.php?tid=2875 https://qb64phoenix.com/forum/showthread.php?tid=1565 RE: Fun with Ray Casting - a740g - 01-16-2025 (01-15-2025, 08:02 PM)Petr Wrote: Thanks for sharing. I don't understand the GetHertz function at all, SUB RenderFrame is very interesting and the placement of the heightmap and surface map in the form of a three-dimensional array is simply brilliant. Thanks for sharing. I also found a few new commands there that I might not have known about. It's a very nice job. Thanks! Maybe the GetHertz function name is misleading. It calculates the number of times it is called in a second when called repeatedly inside a loop. In this case, we get the FPS. In the latest version, I made some optimizations, added auto-LOD, and integrated the FPS calculation. I'll update the zip after work. In the meantime, it can be found here: https://github.com/a740g/QB64-PE-Museum/tree/main/a740g/VoxelSpace RE: Fun with Ray Casting - MasterGy - 01-16-2025 OMG!! I tried it! This is incredible!! Such a short code and such a beautiful 3d drawing...congratulations! I really like it! RE: Fun with Ray Casting - MasterGy - 01-16-2025 Sorry, I don't want to trash your code ![]() If you rewrite this in 'Renderframe', the landscape will darken proportionally to the distance and improve the 3d experience a bit. The bigger the ".001", the bigger the effect. At ".01" it's like walking at night with a flashlight. Code: (Select All)
|