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)?
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
...
}
}