Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers AppGameKit Corner / Simple Raycasting Demo Full AGK2 Source Code

Author
Message
GarBenjamin
AGK Developer
7
Years of Service
User Offline
Joined: 30th Nov 2016
Location: USA
Posted: 31st Dec 2016 04:03 Edited at: 31st Dec 2016 04:47
Hello.

So the past few days or so I found myself increasingly interested in exploring ray casting to create an old school 3D game.

I finally got around to it today. I looked at several different tutorials online and checked out source code for a few different implementations.

Finally, I found the source code for a very simple ray casting engine written in Blitz.

So I ported it over to AGK2. Then I made some improvements to the engine such as removing the "fish eye" problem and structuring the code to be cleaner.
I also added a lot of comments to the code to make it easier to follow.



What I found out is using the DrawLine command in AGK2 is not the way to do this. lol

Although it is fast enough on desktop to be used as the basis for a game when exported to HTML5 it is extremely slow.

I think for AGK2 we'd need to use sprites for all of the slices. The work involved in that however makes me think why not just use 3D to begin with? I think it would make more sense.

What could be done however is something I did long ago on the C64 where I had created a series of simple tiles and the player can move from block to block and the whole thing is quickly drawn.
I might try that for my next experiment.

Source code is attached to this post. It's very simple and should be very straightforward to follow especially with all of the comments I added.
TI/994a (BASIC) -> C64 (BASIC/PASCAL/ASM/Others) -> Amiga (AMOS/BLITZ/ASM/C/Gamesmith) -> DOS (C/C++/Allegro) -> Windows (C++/C#/Monkey X/GL Basic/Unity/Others)

Attachments

Login to view attachments
tboy
11
Years of Service
User Offline
Joined: 1st Jan 2013
Location: UK
Posted: 31st Dec 2016 08:36 Edited at: 31st Dec 2016 08:37
Nice effort! I love the idea behind Raycasting, however, if you're thinking of continuing your effort, look at Raphaƫl Marandet's engine in Javascript,
I have followed his work for sometime and it always impresses me! http://www.laboralphy.org/labo/?p=games

I must find the time to continue work on my own raycaster! Thanks for posting!
GarBenjamin
AGK Developer
7
Years of Service
User Offline
Joined: 30th Nov 2016
Location: USA
Posted: 31st Dec 2016 16:47 Edited at: 31st Dec 2016 16:51
@tboy it was fun to do and I also greatly appreciate raycasting in concept and games made using it. I miss the communities of old where people seemed to share work more than they do these days (especially the biggest game engine communities there seems to be more talking about random game-related subjects... usually about how to do gee whiz HD graphics... than anything else). So I just figure I will share my work fairly often and someone might find it interesting at the worst and helpful at the best. Maybe even build on it.

Thanks for telling me about that website! The whiteroom demo is very close to the kind of game I am interesting in making. All keyboard control like the very first 3D games. Explore an area, collect the loot and battle with enemies. That is a great core. Of course, then add some secrets to find and other things that can be interacted with.

I stumbled upon something called the Raycasting Game Maker but haven't checked it out yet. I checked out NaaLaa 6 and I think it looks to be about the best option for making raycasting games because it comes with support for building the levels as well as a raycasting engine built in!

I thought about suggesting adding raycasting level editor and raycasting engine to AGK2 in the thread asking for feedback/suggestions. It would be incredibly cool if AGK2 had it built in.

Right now I am back to having no active project again. Not sure what I will do next. Might try a 3D-ish game using pre-rendered sections that are assembled with player limited to 90-degree turns. Maybe play around 3D in AGK2 because the kind of game I have in mind really only needs solid color planes or cubes.
TI/994a (BASIC) -> C64 (BASIC/PASCAL/ASM/Others) -> Amiga (AMOS/BLITZ/ASM/C/Gamesmith) -> DOS (C/C++/Allegro) -> Windows (C++/C#/Monkey X/GL Basic/Unity/Others)
tboy
11
Years of Service
User Offline
Joined: 1st Jan 2013
Location: UK
Posted: 31st Dec 2016 18:12
I appreciate work that is shared as there is always something new to learn!

NaaLaa6 is pretty cool, I have used it in the past, it actually seems quite solid, hopefully they will work on a Javascript version via
emscripten.

If you decide to work on a raycasting engine I believe you'll be surprised at how much interest you will attract particularly for
mobile development.
Stab in the Dark software
Valued Member
21
Years of Service
User Offline
Joined: 12th Dec 2002
Playing: Badges, I don't need no stinkin badges
Posted: 1st Jan 2017 17:01
Well if you are going to do it in 3D you could use the built in physics.
Here are the examples.

https://forum.thegamecreators.com/thread/216683

The coffee is lovely dark and deep,and I have code to write before I sleep.

Login to post a reply

Server time is: 2024-11-21 21:54:05
Your offset time is: 2024-11-21 21:54:05