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.

AppGameKit Classic Chat / Raycasting for Dummies like me

Author
Message
chafari
Valued Member
18
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 16th Jun 2019 21:13 Edited at: 16th Jun 2019 21:17
I always wondered how the heck the raycasting worked . I read a lot of tutorials here and there but the question is that the more I read, the more confused I was. I have been watching the permadi tutorials...Vandevenne , GarBenjamin, Cliff Mellangard and so many others. Even try to convert some codes to Dbpro or Agk without any success . All the examples were about throwing a beam from the player's coordinates to the walls if that makes any sense to me .
In the end I ended up thinking about how an object would travel in space simply by increasing its coordinates according to an angle where it points. I was able to get the raycasting working quite good ...only the walls at the moment.
The first attempts were in Dbpro since it has more 2D commands and they are much more speed . I've got the minimun functional code working in Dbpro at more than 650 FPS and in Agk in the best case I've got 60 FPS that are quite reasonable if it doesn't go down too much.

In Dbpro we have the command point (x, y) to get the screen color value .To do that in Agk we have to create an Array which makes it incredibly slower than the command point (x, y)....even worse if we have to create an image for every movement we make So I thought that instead of looking for a color on the screen I should check if we were inside an area.

You can see in this example how we collide with the zones and we have nearly 60 FPS




With this other example, we can see better the ray but the FPS goes down a lot.




I get just 7 FPS in my old chunk





Next Step of tutorial in my Chafari's trick thread


I'm not a grumpy grandpa

Attachments

Login to view attachments
chafari
Valued Member
18
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 17th Jun 2019 13:44 Edited at: 17th Jun 2019 13:44
Hi there . Adding moving blocks . I will post pieces of code in my Chafari tricks thread .

I'm not a grumpy grandpa

Attachments

Login to view attachments
chafari
Valued Member
18
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 18th Jun 2019 10:09 Edited at: 18th Jun 2019 10:10
Adding some lights effect ....could be good for scary games
I'm not a grumpy grandpa

Attachments

Login to view attachments
chafari
Valued Member
18
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 19th Jun 2019 10:52 Edited at: 19th Jun 2019 10:53
Moving lights ...
I'm not a grumpy grandpa

Attachments

Login to view attachments
chafari
Valued Member
18
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 20th Jun 2019 11:04 Edited at: 20th Jun 2019 11:04
Projecting lights on walls ...
I'm not a grumpy grandpa

Attachments

Login to view attachments
chafari
Valued Member
18
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 21st Jun 2019 22:59 Edited at: 21st Jun 2019 22:59
Hi there . I know that most raycasting are with squares but I did some tests with cylinders ... don't look bad

I'm not a grumpy grandpa

Attachments

Login to view attachments
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 22nd Jun 2019 16:07
If you've managed to do all this, then I wouldn't say you're a raycasting dummy.
Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
chafari
Valued Member
18
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 22nd Jun 2019 19:33
Thanks Phaelax for your feedback . I had try lot of times and always gave up..this is my last serious attempt to achive raycasting...I start understanding raycasting exactly with this examples. In just one month I've got it working more or less ok for my pueposes . Shortly I will add sprites an textures.

Cheers.
I'm not a grumpy grandpa
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 22nd Jun 2019 19:45
Wasn't sure exactly what you were asking in the beginning.
I believed you just wanted a more deep analyses but what
you have got working looks great to me

Perhaps the recreation of a retro classic is coming
fubarpk
fubarpk on Itch...………...https://fubarpk.itch.io/
fubarpk on googleplay..https://play.google.com/store/apps/developer?id=fubarpk
chafari
Valued Member
18
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 22nd Jun 2019 22:53
Thanks fubarpk ...yeah ...I love old 90's retro games ...I'm trying to do the same Cliff Mellangard and others did . I think that finally I will use real 3D to the final project, but raycasting was something I wanted to achive just for the heck of it .
I'm not a grumpy grandpa
Xaby
FPSC Reloaded TGC Backer
17
Years of Service
User Offline
Joined: 17th Apr 2007
Location: Berlin
Posted: 23rd Jun 2019 08:09
@chafari
I like the lighting very much
chafari
Valued Member
18
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 23rd Jun 2019 11:21 Edited at: 23rd Jun 2019 12:36
Thaks Xaby . Coming from a great programmer like you, it's a nice compliment .
Here's the lihgting trick ... of course here's not all the code but just a bit to show how I did it. This snippet is a part of the code that I use in Dbpro and runs at more than 650 or 700 FPS . I have to find out how to acelerate this in Agk . It's supposed that Agk is faster than Dbpro, but not in 2D commands.




I'm not a grumpy grandpa

Attachments

Login to view attachments
chafari
Valued Member
18
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 23rd Jun 2019 21:05 Edited at: 23rd Jun 2019 21:06
Sliding doors....

I'm not a grumpy grandpa

Attachments

Login to view attachments
Rick Nasher
7
Years of Service
User Offline
Joined: 25th Jul 2017
Location: Amsterdam
Posted: 25th Jun 2019 23:14
Nice progression.
chafari
Valued Member
18
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 26th Jun 2019 11:13 Edited at: 26th Jun 2019 13:52
@Rick Nasher Thanks mate...I'm on it
Adding texture to the floor of my raycasting project, I discovered that the famous mode7 works in the same way . so we can make the 90's retro races. It needs many adjustments, but I think I'm on the right track .

I'm not a grumpy grandpa

Attachments

Login to view attachments
Carharttguy
8
Years of Service
User Offline
Joined: 8th Jul 2016
Location: Belgium
Posted: 27th Jun 2019 22:17
Very nice Chafari. I'm a little bit too young for those retro games, but they have a nice 'feel'!
chafari
Valued Member
18
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 27th Jun 2019 23:18 Edited at: 28th Jun 2019 09:55
@Carharttguy thanks for your comment. This moving boxes is none special but the tecnic raycating use to show the boxes like in a laberint. Nowaday everyone can make a scenario made of boxes with a better look than raycasting but when we get the raycasting working like old programmers did back in the 90's games it is a great feeling that make you feel you have done the work.


Someone could think that mode7 is a plain on the floor with an image on it . Mode7 works with an array image that we project stripe by stripe giving the appearance of perspective .

I'm not a grumpy grandpa

Attachments

Login to view attachments
Xaby
FPSC Reloaded TGC Backer
17
Years of Service
User Offline
Joined: 17th Apr 2007
Location: Berlin
Posted: 3rd Jul 2019 15:41 Edited at: 3rd Jul 2019 15:49
chafari
Valued Member
18
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 3rd Jul 2019 18:11
@Xaby nice examples. When we know how it works, we can even do it in child's program. Just for fun, I have made the raycasting in:
Smallbasic
Coolbasic
Freebasic
Purebasic
Qb64
Dbpro
Agk
All of them are faster than Agk....does it have any sense?
In purebasic the final exe is less than 60kb without textures... in Agk more than 5Mb
I'm not a grumpy grandpa
chafari
Valued Member
18
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 15th Jul 2019 17:57 Edited at: 15th Jul 2019 17:57
Hi there.
Create a raycasting with 3D objects is somewhat redundant but since the Agk 2D commands are too slow we can use 3D objects instead to create the strips . That is made only for fun ... to show how it really works. In my old junk it runs at 20 FPS with drawing commands and with 3D objects it runs 10 times faster .

No media needed .



I'm not a grumpy grandpa

Attachments

Login to view attachments
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 15th Jul 2019 18:33
Works well Chafari and looks very retro
fubarpk
fubarpk on Itch...………...https://fubarpk.itch.io/
fubarpk on googleplay..https://play.google.com/store/apps/developer?id=fubarpk
chafari
Valued Member
18
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 15th Jul 2019 20:53 Edited at: 15th Jul 2019 20:54
Thanks fubarpk . I've got it working with textures, but I like it much more with single colours .

I'm not a grumpy grandpa

Attachments

Login to view attachments

Login to post a reply

Server time is: 2024-11-22 21:44:33
Your offset time is: 2024-11-22 21:44:33