Temple of The Roguelike Forums

Development => Programming => Topic started by: honey_spider on December 03, 2012, 01:50:12 AM

Title: Already with the line of sight!
Post by: honey_spider on December 03, 2012, 01:50:12 AM
So far, I have the ray casting ...and it works.
 
https://gist.github.com/4192017
 
FYI, wallsGFX[][] contains the wall data.  If wallsGFX
 
rays[][] contains the current ray, and it is re-initialised to 0 at the start of each iteration of the loop.
 
lineOfSight[][] is where I want to store a '1' for tiles that can be seen, and a '0' for tiles that cannot.
 
How would you go about transferring this information?
 
Have I been clear?
 
I will try to post a little example
 
wallsGFX[][]
 
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 1 1 1 1 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0

rays[][]

0 0 0 1 0 0 0 0
0 0 0 1 0 0 0 0
0 0 0 1 0 0 0 0
0 0 0 0 1 0 0 0
0 0 0 0 1 0 0 0
0 0 0 0 1 0 0 0
0 0 0 0 0 1 0 0
 
what lineOfSight[][] should show after this one iteration
 
0 0 0 1 0 0 0 0
0 0 0 1 0 0 0 0
0 0 0 1 0 0 0 0
0 0 0 0 1 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
Title: Re: Already with the line of sight!
Post by: guest509 on December 03, 2012, 04:24:04 AM
  Yay!

  People love that stuff. It's a huge topic of convo, a pretty hard programming problem too.

  I'm going with straight circle sight. :-)
Title: Re: Already with the line of sight!
Post by: honey_spider on December 03, 2012, 06:52:21 AM
I got it!  Thanks anyways :3
Title: Re: Already with the line of sight!
Post by: guest509 on December 03, 2012, 07:30:17 AM
  Were you surprised that it came out so well? Those are the best! :)
Title: Re: Already with the line of sight!
Post by: honey_spider on December 03, 2012, 08:14:24 AM
Suprised and impressed!  ...although not I have to figure out how to draw it properly which is doing my head in.
 
At uni we program data base queries and binary trees.  Roguelikes are something else.
Title: Re: Already with the line of sight!
Post by: honey_spider on December 03, 2012, 10:40:13 AM
Ah crap.  It doesn't work.
 
Revised code is here https://gist.github.com/4194013
 
Result is here http://imgur.com/r12lg
 
 :-[