This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2011-08-26 21:32:48

spuspu
Scratcher
Registered: 2011-02-10
Posts: 26

basics of raycasters

I am interested in creating a raycaster project, so I've been looking at the scripts of some, but I can not understand the scripts.  can anyone give me an explanation on how to make a raycaster?

Offline

 

#2 2011-08-28 13:46:00

AtomicBawm3
Scratcher
Registered: 2009-06-27
Posts: 1000+

Re: basics of raycasters

It depends on the type of raycaster you're building.  S65 for example, makes his completely virtual, which is harder to do, but provides more speed and accuracy.

Most people use a sprite that is shaped like an overhead view of the area the player is in.  Then, they have a sprite that goes to where the player would be if he were standing in that overhead view.

Using lists, that sprite points in directions (usually the direction desired by the player + or - 0 to 30).  It then moves at a rate of speed that is desired.  As soon as the sprite touches the walls of the overhead view, it finds it's distance from where the player is standing, and adds it to a list (or replaces an item on that list).

When the entire list is full, that is, the sprite has scanned in all the wanted directions, a sprite is told to draw everything.  This part is a little weird, because it x is determined by the direction is was pointing when if found that specific distance.  It's two y positions are determined by finding the inverse of the distance (1/distance) and multiplying by a number that would draw the wall a specific height that makes sense for that distance.  That number has to remain constant through out the whole drawing process though.

This is a rather broad coverage of raycasters, I'm hoping to make a project sometime that can explain them better.


http://i50.tinypic.com/j0yw0p.jpg

Offline

 

#3 2011-08-28 20:27:21

spuspu
Scratcher
Registered: 2011-02-10
Posts: 26

Re: basics of raycasters

thanks!  let me know when you are done with the project

Offline

 

#4 2011-08-28 21:05:32

AtomicBawm3
Scratcher
Registered: 2009-06-27
Posts: 1000+

Re: basics of raycasters

spuspu wrote:

thanks!  let me know when you are done with the project

It probably won't be for a while since I'm in school and such...I don't plan to be posting anything until around Christmas, but I'll see if I can slip it in somewhere.


http://i50.tinypic.com/j0yw0p.jpg

Offline

 

#5 2011-08-29 13:39:28

spuspu
Scratcher
Registered: 2011-02-10
Posts: 26

Offline

 

#6 2011-08-31 20:47:42

spuspu
Scratcher
Registered: 2011-02-10
Posts: 26

Re: basics of raycasters

is trigonometry a must-know for raycasters?

Offline

 

#7 2011-09-05 08:44:38

cygene
Scratcher
Registered: 2011-05-31
Posts: 100+

Re: basics of raycasters

spuspu wrote:

is trigonometry a must-know for raycasters?

Depends. If you're making a basic, visual map based raycaster, no. But, if you want to make a raycaster that is based on an array (virtual) you definitely need trig and other math. I could help you a bit, as right now, I'm working on a first-person shooter based off a raycaster engine ( http://scratch.mit.edu/projects/cygene/2004759 . )

Also, if you need a raycaster that's fast (for a game) I suggest making the map virtual. It's a whole lot faster, but harder to do.


http://cygene.wikispaces.com/file/view/clip2.gif/242526033/clip2.gif

Offline

 

#8 2011-09-05 09:17:35

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: basics of raycasters

cygene wrote:

spuspu wrote:

is trigonometry a must-know for raycasters?

Depends. If you're making a basic, visual map based raycaster, no. But, if you want to make a raycaster that is based on an array (virtual) you definitely need trig and other math. I could help you a bit, as right now, I'm working on a first-person shooter based off a raycaster engine ( http://scratch.mit.edu/projects/cygene/2004759 . )

Also, if you need a raycaster that's fast (for a game) I suggest making the map virtual. It's a whole lot faster, but harder to do.

Hey cygene, would you like apply for a Scratch Wiki account and help improve the Raycaster article?

Offline

 

#9 2011-09-05 09:21:40

cygene
Scratcher
Registered: 2011-05-31
Posts: 100+

Re: basics of raycasters

scimonster wrote:

cygene wrote:

spuspu wrote:

is trigonometry a must-know for raycasters?

Depends. If you're making a basic, visual map based raycaster, no. But, if you want to make a raycaster that is based on an array (virtual) you definitely need trig and other math. I could help you a bit, as right now, I'm working on a first-person shooter based off a raycaster engine ( http://scratch.mit.edu/projects/cygene/2004759 . )

Also, if you need a raycaster that's fast (for a game) I suggest making the map virtual. It's a whole lot faster, but harder to do.

Hey cygene, would you like apply for a Scratch Wiki account and help improve the Raycaster article?

Sure  smile  How do you apply, though?


http://cygene.wikispaces.com/file/view/clip2.gif/242526033/clip2.gif

Offline

 

#10 2011-09-05 09:34:58

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: basics of raycasters

cygene wrote:

scimonster wrote:

cygene wrote:


Depends. If you're making a basic, visual map based raycaster, no. But, if you want to make a raycaster that is based on an array (virtual) you definitely need trig and other math. I could help you a bit, as right now, I'm working on a first-person shooter based off a raycaster engine ( http://scratch.mit.edu/projects/cygene/2004759 . )

Also, if you need a raycaster that's fast (for a game) I suggest making the map virtual. It's a whole lot faster, but harder to do.

Hey cygene, would you like apply for a Scratch Wiki account and help improve the Raycaster article?

Sure  smile  How do you apply, though?

Read.

Offline

 

#11 2011-09-06 20:13:02

spuspu
Scratcher
Registered: 2011-02-10
Posts: 26

Offline

 

#12 2011-09-06 21:43:17

AtomicBawm3
Scratcher
Registered: 2009-06-27
Posts: 1000+

Re: basics of raycasters

spuspu wrote:

can u tell me what went wrong? http://scratch.mit.edu/projects/spuspu/2016488

What do you mean what went wrong? Seems fine to me.


http://i50.tinypic.com/j0yw0p.jpg

Offline

 

Board footer