Skip to main content
GameDev.net gamedev.net
🔒 Locked

Recursive Methods

Started by Darren Johnson Mar 9, 2012 at 11:07 AM 3 replies 1.5k views
Original Post
Darren Johnson
Darren Johnson
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
DennisterBeest
DennisterBeest
Could you be a bit more specific on where you are stuck and why you are stuck..

What error message do you get?
Darren Johnson
Darren Johnson
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.
DennisterBeest
DennisterBeest
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!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.