nightingale
Well-known member
Thanks for the advice everyone! I'll try some things out tonight and see if I can isolate the problem.
I think you're right about junk ending up in the mapTile array, because I had the problem before with the stop icon when I accidentally wrote beyond the limits of another array and it overwrote that part of memory. I guess I was confused that it only happens on some computers with some operating systems. Is it possible that something outside my program is writing to that part of memory that my program is expecting to be used for that variable?
The reason I've defined my arrays as much larger than needed for this 16x16 map is that the various levels will have various map sizes, and I want to make sure my array is large enough regardless of which level I load. Is it important that I fill the entire array with some value, even if it's not currently used, so that it takes up the expected area of memory? I've read a few books now that talk about how the Macintosh handles memory for applications, but I'll admit that this is one area I still don't fully understand.
Another thing that I am aware of is that I haven't implemented any error handling yet, so when something goes wrong, the program either crashes or I get junk in my variables, so doing a check to see if the variable has an expected value is also a good tip I will try.
Most of the problems I've encountered to date are the result of human error. For example, in the code I posted, you can see I'm manually setting the values for each mapTile value. This is just because I haven't implemented the routines to open one of my map files and read the values from there yet, so doing it manually has often lead to strange results if I get one value wrong. Taking that human factor out of the equation also might help me eliminate some of the gremlins, so perhaps that another thing to prioritize.
Thanks again everyone, and I'll post an update tonight when I have a chance to try some things out!
I think you're right about junk ending up in the mapTile array, because I had the problem before with the stop icon when I accidentally wrote beyond the limits of another array and it overwrote that part of memory. I guess I was confused that it only happens on some computers with some operating systems. Is it possible that something outside my program is writing to that part of memory that my program is expecting to be used for that variable?
The reason I've defined my arrays as much larger than needed for this 16x16 map is that the various levels will have various map sizes, and I want to make sure my array is large enough regardless of which level I load. Is it important that I fill the entire array with some value, even if it's not currently used, so that it takes up the expected area of memory? I've read a few books now that talk about how the Macintosh handles memory for applications, but I'll admit that this is one area I still don't fully understand.
Another thing that I am aware of is that I haven't implemented any error handling yet, so when something goes wrong, the program either crashes or I get junk in my variables, so doing a check to see if the variable has an expected value is also a good tip I will try.
Most of the problems I've encountered to date are the result of human error. For example, in the code I posted, you can see I'm manually setting the values for each mapTile value. This is just because I haven't implemented the routines to open one of my map files and read the values from there yet, so doing it manually has often lead to strange results if I get one value wrong. Taking that human factor out of the equation also might help me eliminate some of the gremlins, so perhaps that another thing to prioritize.
Thanks again everyone, and I'll post an update tonight when I have a chance to try some things out!