• Create Account

# Recursive Methods

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

4 replies to this topic

### #1Darren Johnson  Members   -  Reputation: 108

Like
0Likes
Like

Posted 09 March 2012 - 05:07 AM

Hi,

I am currently working on Nick Gravelyn's tile editor but I am stuck on episode 5 (Recursive Methods). Would you be able to point out to me where I am going wrong? I seem to get out of bounds exception errors when I try to use the 'fill' option. The error is quite different than the one he highlights in the video. I cannot progress with these tutorials (which I would like to) until I resolve this.

My project is here, if you wish to take a look at it:
https://skydrive.liv...89BB32BAF8D!134

I would greatly appreciate any help you can give to me. Thanks for taking the time to read this.

Regards,
Darren

### #2Ghosrath  Members   -  Reputation: 123

Like
1Likes
Like

Posted 09 March 2012 - 09:03 AM

Could you be a bit more specific on where you are stuck and why you are stuck..

What error message do you get?

### #3Darren Johnson  Members   -  Reputation: 108

Like
0Likes
Like

Posted 09 March 2012 - 09:28 AM

I am having particular problems with the FillCell method in the Form1.cs in the TileEngine class.

	    public void FillCell(int x, int y, int desiredIndex)
{
int oldIndex = currentLayer.GetCellIndex(x, y);
currentLayer.SetCellIndex(x, y, desiredIndex);
if (x > 0 && currentLayer.GetCellIndex(x - 1, y) == oldIndex)
FillCell(x - 1, y, desiredIndex);
if (x < currentLayer.Width - 1 && currentLayer.GetCellIndex(x + 1, y) == oldIndex)
FillCell(x + 1, y, desiredIndex);
if (y > 0 && currentLayer.GetCellIndex(x, y - 1) == oldIndex)
FillCell(x, y - 1, desiredIndex);
if (y < currentLayer.Height - 1 && currentLayer.GetCellIndex(x, y + 1) == oldIndex)
FillCell(x, y + 1, desiredIndex);
}


It just seems to be finding tiles outside of the array all of the time. Which breaks the program. The fill feature seems to be used again in the next few videos, so I can';t move on until it works.

### #4Ghosrath  Members   -  Reputation: 123

Like
2Likes
Like

Posted 09 March 2012 - 11:10 AM

i watched the next episode of the tutorial. That will explain in detail what type of error you are gettting and how to solve it!

### #5jschmuff  Members   -  Reputation: 2245

Like
1Likes
Like

Posted 09 March 2012 - 11:13 AM

Continue on to pt 2/3

EDIT** Beat to the punch!

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

PARTNERS