Jump to content
  • Advertisement
Sign in to follow this  
Darren Johnson

Recursive Methods

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!