In a platform game I am working on I have an array to hold the tiles for the board. I also have a Type Player to define the characters that run around the board. The problem is several of the methods in my Player type need to access the array to determine collisions and board interactions. But the array is defined outside the Type so the Type does not compile.
What is the cleanest way to have my Player Type know about the array? I know I could pass the array in as a parameter to my Player methods but I don't like that.
Should I define a pointer field in my Player Type and initialize it to my actual array when I instantiate a player?
I guess what it comes down to is how do I reference a Global variable or object in a Type definition.
What is the cleanest way to have my Player Type know about the array? I know I could pass the array in as a parameter to my Player methods but I don't like that.
Should I define a pointer field in my Player Type and initialize it to my actual array when I instantiate a player?
I guess what it comes down to is how do I reference a Global variable or object in a Type definition.