Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Globalize my own class objects...

This topic is 5426 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, Been playing around more with my first bomberman game engine. I noticed that when I want to globally (putting it just a little below the header includes with the DirectDraw stuff) declare some objects of classes that I created I can''t and get this error: Compiling... engine.cpp engine.cpp(45) : error C2143: syntax error : missing '';'' before ''.'' engine.cpp(45) : error C2501: ''g_map'' : missing storage-class or type specifiers engine.cpp(45) : error C2371: ''g_map'' : redefinition; different basic types engine.cpp(44) : see declaration of ''g_map'' engine.cpp(45) : error C2143: syntax error : missing '';'' before ''.'' Error executing cl.exe. Engine.exe - 4 error(s), 0 warning(s) Basically, this error will be gone if I decide to declare my map objects within a function, such as the main loop. But this doesn''t make sense because I don''t want a new map on every loop right? I have a Constructor that takes the map width and height, a destructor which properly deletes allocated memory and a copy constructor that can do deep copies defined (2d arrays). What am I doing wrong? Thanks!

Share this post

Link to post
Share on other sites
Sorry bout that hehe

// Bitmap surfaces used for blitting
// Map bitmaps
CSurface *g_WallBit = NULL; // Wall tile bitmap
CSurface *g_PathBit = NULL; // Path tile bitmap
CSurface *g_BlockBit = NULL; // Block tile bitmap

// Player bitmaps
CSurface *g_UpBit = NULL; // Up bitmap
CSurface *g_DownBit = NULL; // Down bitmap
CSurface *g_RightBit = NULL; // Right bitmap
CSurface *g_LeftBit = NULL; // Left bitmap
CSurface *g_DudeBit = NULL;// Dude bitmap

<============== this first part to let you see where I placed my global game elements, right below directdraw stuff

// Global game elements
int g_mapSize = 7;
static BomberMap g_map = BomberMap(g_mapSize,g_mapSize); // Create a 7x7 map grid
g_map.GenerateStandardMap(); // Set tiles in there
int g_tileSpace = 64; // Tile spacing value used to draw tiles properly

Share this post

Link to post
Share on other sites
static BomberMap g_map = BomberMap(g_mapSize, g_mapSize);


static BomberMap g_map(g_mapSize, g_mapSize);

Share this post

Link to post
Share on other sites
Thanks for your reply. For some reason pointers did the trick. I tried your method and it worked but for some reason the default zero data was initialized in there. Must be something wrong wth my copy constructor. Hmmmm.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!