Author Topic: Already with the line of sight!  (Read 7118 times)

honey_spider

  • Newcomer
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Already with the line of sight!
« 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
  • [y] == 0, you can see through it.

 
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
« Last Edit: December 03, 2012, 02:23:52 AM by honey_spider »

guest509

  • Guest
Re: Already with the line of sight!
« Reply #1 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. :-)

honey_spider

  • Newcomer
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Re: Already with the line of sight!
« Reply #2 on: December 03, 2012, 06:52:21 AM »
I got it!  Thanks anyways :3

guest509

  • Guest
Re: Already with the line of sight!
« Reply #3 on: December 03, 2012, 07:30:17 AM »
  Were you surprised that it came out so well? Those are the best! :)

honey_spider

  • Newcomer
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Re: Already with the line of sight!
« Reply #4 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.

honey_spider

  • Newcomer
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Re: Already with the line of sight!
« Reply #5 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
 
 :-[