Public Group

# Recursive Methods

This topic is 2467 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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

##### Share on other sites
Could you be a bit more specific on where you are stuck and why you are stuck..

What error message do you get?

##### Share on other sites
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.

##### Share on other sites
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!

##### Share on other sites
Continue on to pt 2/3

EDIT** Beat to the punch!

1. 1
2. 2
3. 3
Rutin
23
4. 4
5. 5
khawk
14

• 9
• 11
• 11
• 23
• 12
• ### Forum Statistics

• Total Topics
633654
• Total Posts
3013168
×