#pragma once
const int MapTileSize = 32;
const int MapX = 256;
const int MapY = 256;
const int BackgroundX = (MapX / 2) + (SCREEN_WIDTH / MapTileSize);
const int BackgroundY = (MapY / 2) + (SCREEN_HEIGHT / MapTileSize);
const int BackdropX = SCREEN_WIDTH / MapTileSize;
const int BackdropY = SCREEN_HEIGHT / MapTileSize;
const int GridlineTile = 10;
namespace Map
{
// The Map
struct MapTile
{
BYTE Graphic; // the column of the tile graphic
};
MapTile Map[MapX][MapY];
BYTE Background[BackgroundX][BackgroundY];
BYTE Backdrop[BackdropX][BackdropY];
// Viewpoint Stuff
int ViewpointX = 0;
int ViewpointY = 0;
// Misc Stuff
RECT CurrentTile;
RECT DestRect;
//CLinkedList<CUnit> UnitList; // CUnit isn''t finished yet, so ignore it
// Functions
void Scroll();
bool Load(char *Filename);
void Draw();
void DrawBackground();
}
The Problem: Take a look at the Background and Backdrop declarations... Everything looks fine, right (it worked just yesterday!)? Think again. The compiler says it expected a constant expression on both of those lines. As an expirement, I changed the declaration of BackgroundX and BackgroundY to be MapX and MapY. Then I only had a problem with the Backdrop! I changed the Background constants so that there was no mention of SCREEN_WIDTH or SCREEN_HEIGHT and it worked! SCREEN_HEIGHT and SCREEN_WIDTH are defined as extern const int in Engine.h, and actually defined in Game.cpp, along with other engine-required but user-supplied constants. Everything worked until I took everything out of my headers and put it into cpp files and headers (I should have done that before I started). Everything else made the transition perfectly. It seems to me that BackgroundX and BackgroundY are defined as const, but really aren''t.............. (insert spooky music here)
--------------------You are not a real programmer until you end all your sentences with semicolons; (c) 2000 ROAD Programming
You are unique. Just like everybody else.
Visit the ROAD Programming Website for more programming help.