Given an array (public int[,] levelMap; // Level layout of cells) that is used to define the cell layout of my screen.
Now, everytime a value changes in levelMap [at a certain location in the array] I need to update an ArrayList (alChangeList) which the coordinates of the changes so that when I redraw I know where.
Currently this means that at every location in my code that I change levelMap I need to also update alChangeList (manually), problem is there are a LOT of places where levelMap can change and I want to centralize the code required to update alChangeList.
So, my idea ... and this is where I need help, a) no clue if this is do-able and b) no clue how to do it...
- Create an EVENT that is triggered when something in the array changes
- In that event's EVENTHANDLER function I could perform the update on the ArrayList alChangeList (hopfully the event would include the location the change was made)
This solves all my problems and makes the code much easier to manage ...
Hopefully something like this can be accomplished, would be much easier then having to account for it all manually, to many places where changes occur... Or if you can think of something else/better?
Any ideas, hints, and help would be greatly appreciated, thanks
One SIDE QUESTION - instead of using an ARRAYLIST (alChangeList) would it be better/more efficient to use a bool array (public bool[,] changesMap) where I would set the location to TRUE if a change was made and have code loop through each location when drawing... OR is it safer to use the ArrayList and just remove each added element (that way I don't need to cycle through the entire array to see if there were any changes, cause there could be none)
Thanks,
Now, everytime a value changes in levelMap [at a certain location in the array] I need to update an ArrayList (alChangeList) which the coordinates of the changes so that when I redraw I know where.
Currently this means that at every location in my code that I change levelMap I need to also update alChangeList (manually), problem is there are a LOT of places where levelMap can change and I want to centralize the code required to update alChangeList.
So, my idea ... and this is where I need help, a) no clue if this is do-able and b) no clue how to do it...
- Create an EVENT that is triggered when something in the array changes
- In that event's EVENTHANDLER function I could perform the update on the ArrayList alChangeList (hopfully the event would include the location the change was made)
This solves all my problems and makes the code much easier to manage ...
Hopefully something like this can be accomplished, would be much easier then having to account for it all manually, to many places where changes occur... Or if you can think of something else/better?
Any ideas, hints, and help would be greatly appreciated, thanks
One SIDE QUESTION - instead of using an ARRAYLIST (alChangeList) would it be better/more efficient to use a bool array (public bool[,] changesMap) where I would set the location to TRUE if a change was made and have code loop through each location when drawing... OR is it safer to use the ArrayList and just remove each added element (that way I don't need to cycle through the entire array to see if there were any changes, cause there could be none)
Thanks,