Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - DavidD

Pages: [1]
1
Programming / Re: Recursive shadowcasting wrong in wiki?
« on: January 08, 2012, 11:58:18 AM »
Code: [Select]
RecursiveScan(playerPosition, depth + 1, octant, startSlope, endSlope, playerPosition.X, playerPosition.Y));
Are you sure about that? The method looks like this:

Code: [Select]
public static void RecursiveScan(Point playerPosition, int depth, int octant, double startSlope, double endSlope)
Here's another call earlier

Code: [Select]
RecursiveScan(playerPosition, depth + 1, octant, startSlope, GetSlope(x - 0.5, y + 0.5, playerPosition.X, playerPosition.Y));
Should I use the same slope as earlier in the code?

2
Programming / Re: Recursive shadowcasting wrong in wiki?
« on: January 06, 2012, 01:49:23 PM »
yeah I like your tiles too. I've never had the guts to try, it sure beats having a game that looks like someone elses.

Oh? Really? I think they're really ugly... I just filled it with a dark gray, then I painted with some brighter gray, added noise and voilĂ ! Same with the wall.

3
Programming / Re: Recursive shadowcasting wrong in wiki?
« on: January 06, 2012, 11:41:50 AM »
It should be faster in general than a similar implementation done recursively.  ... Sorry for rambling on at such length, lol.

I do just that! No worries. We're using SVN so I just commit before making any big changes and then I can just revert if the shit hits the fan. Thanks for the tips though!

4
Programming / Re: Recursive shadowcasting wrong in wiki?
« on: January 05, 2012, 10:50:44 AM »
Thank you Leaf! It's very nice of you to provide a code sample! Is it as fast as the recursive method?

Yes corremn, I made those. They're more of a placeholder until we can get a better graphics artist,  though this is a school project so they don't really have to be top-notch. I'm not really a great artist but I wanted to try it out since I'll have to make my own because I don't know anyone who can draw. Practice makes perfect, eh?

5
Programming / Recursive shadowcasting wrong in wiki?
« on: January 04, 2012, 08:46:55 PM »
Hey there! I just registered so I'd like to say hey to the roguelike community!

Anyway, I read this article on the wiki. However, it seems that there's a bug in there somewhere. If you look at this picture I'm sure you'd understand:

http://imgur.com/okvVB

In the top picture, the algorithm works as expected, but when 2 tiles are added like in the second picture (the vertical wall doesn't matter, i exaggerated it) it acts weird and that's not at all the way I'd like it to look.

It's the same on all 4 sides. So it's the code posted in my link that's a bit faulty as a whole.

Is there an updated version or is it just like that?

This is my first octant just to show my syntax, all the other ones are the same except for a few other values

Code: [Select]
           int x = 0;
            int y = 0;

            switch (octant)
            {
                case 1:
                    y = playerPosition.Y - depth;
                    x = (int)Math.Round(playerPosition.X - startSlope * depth);

                    if (x < 0)
                        break;
                    if (x >= mapDimensions.X)
                        break;
                    if (y < 0)
                        break;
                    if (y >= mapDimensions.Y)
                        break;
                    
                    while (GetSlope(x, y, playerPosition.X, playerPosition.Y) >= endSlope)
                    {
                        if (IsWithinVisualRange(playerPosition.X, playerPosition.Y, x, y))
                        {
                            if (map[y][x].BlocksVision)
                            {
                                //if (TestCell(x - 1, y, playerPosition.X, playerPosition.Y, false, depth))
                                if(!map[y][x - 1].BlocksVision)
                                    RecursiveScan(playerPosition, depth + 1, octant, startSlope, GetSlope(x - 0.5, y + 0.5, playerPosition.X, playerPosition.Y));

                                lightMap[y][x] = 1;
                                visitedMap[y][x] = true;
                            }
                            else
                            {
                                //if (TestCell(x - 1, y, playerPosition.X, playerPosition.Y, true, depth))
                                if(map[y][x - 1].BlocksVision)
                                    startSlope = GetSlope(x - 0.5, y - 0.5, playerPosition.X, playerPosition.Y);

                                lightMap[y][x] = 1;
                                visitedMap[y][x] = true;
                            }
                        }
                        x++;
                    }
                    x--;

Pages: [1]