Temple of The Roguelike Forums
Development => Programming => Topic started 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- [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
-
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. :-)
-
I got it! Thanks anyways :3
-
Were you surprised that it came out so well? Those are the best! :)
-
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.
-
Ah crap. It doesn't work.
Revised code is here https://gist.github.com/4194013
Result is here http://imgur.com/r12lg
:-[