« on: June 21, 2016, 09:47:42 AM »
Let's say there is an array class with methods for drawing ellipses, rectangles etc. These routines access unsigned char (or some other simple type) of the array. Now, I've wondered if it's possible to make generic routines in case where you change the array to have items of more complex structs with some member variable of that struct that needs an ellipse routine. How do you write a routine to accept those types? Is it even possible without template/macro madness?
This is a real issue I'm having with Teemu, which has for now used simple arrays for each type of map data (light, fov, etc.) But I've started to combine these into more logical tiles that have a struct with members for that data. Then I noticed I have to write ellipse etc. routines for all different maps and if I have more than one variable it has to be written in the algorithm to choose what variable is changed by that algorithm.
Edit: well, one idea I just had is change the routines to create a list of coordinates (in a shape) which then are processed as a list retrieved from an ellipse routine. It's slower, but... it could work.