Computer Science Canada

Raycasting (Pseudo-3D) Engine - First Major Program

Author:  Shanethe13 [ Tue May 12, 2009 2:55 pm ]
Post subject:  Raycasting (Pseudo-3D) Engine - First Major Program

Yesterday during programming class I decided that I would start working on my final assignment a bit early, so I started working on what, for lack of creativity on my part, is currently known as "Raycasting Demo." I am nowhere near completing the program, but after an hour or two of tinkering with trigonometry, I have a pretty decent engine working, and all that is left is optimization, gameplay, and a few more features such as shading.

When you start the program, you will see an extremely temporary splash screen with a title, and three buttons; play, level editor, and quit. I've yet to make a level editor, but you can click on play to see what I have working so far. The WASD keys will move you forwards, backwards, and allow rotation of the camera.

Anyways, feel free to offer some criticism, ideas, or even ask a few questions if you ever wanted to make your own raycasting engine, it really isn't too difficult. I would be posting the source code, but at this point the coding isn't my best, and it has very few comments.

This is also my first Turing program that has consisted of more than just a basic pong game, so don't be surprised if you find some major bugs or flaws in the design, I love criticism though, so bash my program to the point that I lose all faith in my talents as a programmer!

Change Log:
-Added a level editor
-Optimized the code slightly
-Fixed various bugs

Author:  Shanethe13 [ Thu May 14, 2009 2:40 pm ]
Post subject:  RE:Raycasting (Pseudo-3D) Engine - First Major Program

I wasn't able to find a list of rules for this section, so I'm not sure whether this form of bumping is allowed or not, but I've uploaded a new version of the program.

The level editor works almost perfectly, save for a bug that occurs if you press more than one button with one mouseclick through dragging over them.

When using the editor, the left mouse button will place the currently selected wall type, the middle button will set the spawn point to the current position, (no visual indicator as of yet) and the right mouse button will delete the currently selected wall.

Author:  andrew. [ Thu May 14, 2009 5:10 pm ]
Post subject:  RE:Raycasting (Pseudo-3D) Engine - First Major Program

This is amazing especially because it's your first attempt at raycasting. Good job!

Author:  Shanethe13 [ Thu May 14, 2009 6:39 pm ]
Post subject:  RE:Raycasting (Pseudo-3D) Engine - First Major Program

Thanks Very Happy It still has a lot of work to go, but once I iron out all the current bugs, it's easy to add in additional features. I'd say the next step would be textures, then floor/ceiling shading.

Author:  corriep [ Thu May 14, 2009 6:39 pm ]
Post subject:  RE:Raycasting (Pseudo-3D) Engine - First Major Program

Quick bug I found, when you make your own level but don't include a wall, the program will error out when you try to go outside the map

Author:  Shanethe13 [ Thu May 14, 2009 6:41 pm ]
Post subject:  Re: RE:Raycasting (Pseudo-3D) Engine - First Major Program

corriep @ Thu May 14, 2009 6:39 pm wrote:
Quick bug I found, when you make your own level but don't include a wall, the program will error out when you try to go outside the map


Yep, that's one of the bugs I was referring to in the post I made at literally the same time you posted. I can't see it taking more than a line or two to fix, I'll take a look at it tomorrow since I'm busy writing an essay on Shakespeare now.

Author:  Homer_simpson [ Thu May 14, 2009 8:03 pm ]
Post subject:  Re: Raycasting (Pseudo-3D) Engine - First Major Program

i like it, i get good frame rate also for turing 20-23 fps

Author:  Shanethe13 [ Fri May 15, 2009 7:08 am ]
Post subject:  Re: Raycasting (Pseudo-3D) Engine - First Major Program

Homer_simpson @ Thu May 14, 2009 8:03 pm wrote:
i like it, i get good frame rate also for turing 20-23 fps

Thanks, but I'm thinking the frame rate is high because I haven't added textures or anything in yet. Judging from the other raycasting programs I've seen made in Turing, the program runs fine until you add textures.

Author:  DanTheMan [ Fri May 15, 2009 8:43 am ]
Post subject:  RE:Raycasting (Pseudo-3D) Engine - First Major Program

I would love it if you would post the source code, but I'm not in any sort of mood to ruch you.

Author:  SNIPERDUDE [ Fri May 15, 2009 9:55 am ]
Post subject:  RE:Raycasting (Pseudo-3D) Engine - First Major Program

I rather enjoyed how you sepparated each wall using shades based off of whether it was vertical or horrizontal.

For mine I originally had the shade based off the distance, which is a little too much for Turing's speed. This is a great alternative.

+15 bits

Author:  Shanethe13 [ Fri May 15, 2009 2:18 pm ]
Post subject:  Re: RE:Raycasting (Pseudo-3D) Engine - First Major Program

SNIPERDUDE @ Fri May 15, 2009 9:55 am wrote:
I rather enjoyed how you sepparated each wall using shades based off of whether it was vertical or horrizontal.

For mine I originally had the shade based off the distance, which is a little too much for Turing's speed. This is a great alternative.

+15 bits


I had actually originally done it based off of distance, but then a friend of mine suggested doing it based on wall orientation. I believe that is also how it was done on Wolfenstein, but I'm not positive.

Either way, thanks for the bits Very Happy

Author:  Homer_simpson [ Fri May 15, 2009 3:26 pm ]
Post subject:  Re: Raycasting (Pseudo-3D) Engine - First Major Program

turing is definitly too slow for texturing, i would suggest you move on to a more powerful programming language

Author:  Shanethe13 [ Fri May 15, 2009 4:28 pm ]
Post subject:  Re: Raycasting (Pseudo-3D) Engine - First Major Program

Homer_simpson @ Fri May 15, 2009 3:26 pm wrote:
turing is definitly too slow for texturing, i would suggest you move on to a more powerful programming language


Well I actually have a bit of experience in C++, and lots in C#. I'm just using Turing since I'm in the grade 10 computer science course right now.

Author:  Dan [ Fri May 15, 2009 4:59 pm ]
Post subject:  Re: Raycasting (Pseudo-3D) Engine - First Major Program

Homer_simpson @ 15th May 2009, 3:26 pm wrote:
turing is definitly too slow for texturing, i would suggest you move on to a more powerful programming language


I have seen raycasting texturing done in turing before so it deftaly is posible to do and having running at a resnobale rate.

Author:  Kharybdis [ Fri May 15, 2009 7:20 pm ]
Post subject:  RE:Raycasting (Pseudo-3D) Engine - First Major Program

Impressive engine, for a first try. I would have loved to be in your grade 10 class, sounds like fun.

Author:  Homer_simpson [ Sat May 16, 2009 2:17 am ]
Post subject:  Re: Raycasting (Pseudo-3D) Engine - First Major Program

Dan @ Fri May 15, 2009 4:59 pm wrote:
Homer_simpson @ 15th May 2009, 3:26 pm wrote:
turing is definitly too slow for texturing, i would suggest you move on to a more powerful programming language


I have seen raycasting texturing done in turing before so it deftaly is posible to do and having running at a resnobale rate.


you're right http://compsci.ca/v3/viewtopic.php?t=16174&highlight=raycast
i forgot about this one. the quality of texture isn't too crazy tho. but it's impressive.

Author:  Shanethe13 [ Thu May 28, 2009 6:19 pm ]
Post subject:  Re: Raycasting (Pseudo-3D) Engine - First Major Program

Thanks for the comments Very Happy
I was away all last week, so I wasn't able to make any changes until the past few days. I did manage to add in some textures, but the frame rate drop was too big for it to be worth it. Either way, here is a newer version with a few changes;

Guns, shooting, and rudimentary reloading
A few images
Joystick support
Bug fixes


: