Multi-dimensional functions?

Hello,

I am a C++ newbie, and i'd like to know whether one can use arrays to define a multidimensional function (really, a multidimensional procedure).

To give an example, let's say that for a game I want to draw a "level map". I define a function:

void generateMap()
{
//generate the level map by drawing shapes
}

Now, as the player progresses through the game levels, i want different "maps" to be generated whilst keeping all other processes constant (such as collision detection algorithms, etc).

Instead of having many different "generateMap" functions for each level (e.g. generateMap1(), generateMap2(), etc), is it possible for "generateMap()" to be a single multidimensional function, e.g. "generateMap[i]()", so that in main(), i can loop through generateMap[i] (where i is incremented when the level is complete)?

Thanks
It looks like you can't. I tried this silly code void fun[](){}; and there was an error.
But this is what I would do:
1
2
3
4
5
6
7
8
9
void generateMap(int map){
     switch (map)
            {
            case 0: {/*map0*/} break;
            case 1: {/*map1*/} break;
            case 2: {/*map2*/} break;
            case 3: {/*map3*/} break;
            }
     };

map argument is for level choose
Uh, not quite. You can just do something like this though
1
2
3
4
5
6
7
8
9
10
void drawMap(int level)
{
     switch(level)
{
	case 1: //Generate map for level one
	case 2: //Generate map for level two
	case 3: //Generate map for level three
	...
}
}
Thanks. I'll try the switch functionality- this seems to be the tidiest way of doing it.

Ah I ninja'd!
Topic archived. No new replies allowed.