Okay, I have a CTile class holding some info about a map position. I''m declaring the Map as CTile Map[10][10]. Now, I want to pass a pointer to this structure to a function that will draw the map. I can''t get this to work!
See my code below, I know I''m doing it wrong, (CMap ** != CMap[10][10]) but, I don''t know how to do it right.
Any help would be appreciated.
define USE_CONSOLE
#include <allegro.h>
class CTile
{
public:
BITMAP *tile_base;
BITMAP *tile_terrain;
bool passable;
};
PALETTE palette;
BITMAP *buffer;
BITMAP *tile_base_water;
BITMAP *tile_base_grass;
BITMAP *tile_terrain_tree;
void draw_map(CTile** pMap);
int main()
{
allegro_init();
install_keyboard();
set_color_depth(16);
set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0);
//setup Bitmaps
buffer = create_bitmap(SCREEN_W, SCREEN_H);
tile_base_water = load_bitmap("water.bmp", palette);
tile_base_grass = load_bitmap("grass.bmp", palette);
tile_terrain_tree = load_bitmap("tree.bmp", palette);
//Create Map
CTile Map[10][10];
for (int x = 0; x < 10; x++)
{
for (int y = 0; y < 10; y++)
{
Map[x][y].passable = true;
Map[x][y].tile_base = tile_base_grass;
Map[x][y].tile_terrain = NULL;
}
}
Map[2][5].tile_terrain = tile_terrain_tree;
//End Map Creation
while (! key[KEY_ESC] )
{
draw_map(Map);
}
//Destroy Bitmaps & exit
destroy_bitmap(buffer);
destroy_bitmap(tile_base_water);
destroy_bitmap(tile_base_grass);
destroy_bitmap(tile_terrain_tree);
return 0;
}
void draw_map(CTile** pMap)
{
// ...
}
Oh, and the error I''m getting if you need it, is
error C2664: ''draw_map'' : cannot convert parameter 1 from ''class CTile [10][10]'' to ''class CTile ** ''
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Error executing cl.exe.
Thanks!
~~~~~~~~~~~
Chris Vogel
~~~~~~~~~~~