![]() |
|
Problem creating a bitmap, and a class |
Paul Hoey
Member #7,189
May 2006
|
DATAFILE *data = NULL; !**!BITMAP *bg = NULL; //a function to initalise some resources void init_data() { data = load_datafile("bboy.dat"); bg = (BITMAP*)data[bg].dat; }
The line with the !**! in front of it gives the following error: Same with this code: Any ideas on the problem? |
Jonatan Hedborg
Member #4,886
July 2004
![]() |
Post the whole file. Probably some syntactical error earlier.
|
X-G
Member #856
December 2000
![]() |
ballImage = (BITMAP*)data[ball].dat; ... and you also have a class named "ball". Name conflict. -- |
Paul Hoey
Member #7,189
May 2006
|
Why would there be a conflict if I'm loading it form a data file, though? Here's the whole file:
|
CGamesPlay
Member #2,559
July 2002
![]() |
When you name a datafile object like that, grabber makes a header file like this: #define ball 1 That means that wherever the word "ball" appears in your source code, the compiler changes it to a "1". So, your code looks like this: class 1 { ... Well, obviously that isn't valid. That is why we typically name datafile objects in all capital letters, because we don't name variables and classes in all capital letters. So, the answer is to change the name of the object in the datafile to something like "DATAFILE_BALL" instead of "ball". [append] -- Ryan Patterson - <http://cgamesplay.com/> |
Paul Hoey
Member #7,189
May 2006
|
Ah, okay. Thank you. |
Audric
Member #907
January 2001
|
You can automate half of the changes: allegro manual said: To prevent name conflicts, you can specify a prefix string for these definitions by typing it into the "Prefix:" field in the grabber or using the '-p' option to dat
ie: if you use a prefix like "datafile_item_", the generated header file will automatically be #define datafile_item_ball 1 |
Tobias Dammers
Member #2,604
August 2002
![]() |
Quote: So, the answer is to change the name of the object in the datafile to something like "DATAFILE_BALL" instead of "ball". Another option (which I tend to use) is keeping the file extensions when adding objects to the datafile. The dat tool does this by default, so the following command: dat mydatafile.dat -a foo.bmp -t BMP ...will add a bitmap object called "FOO_BMP" to the datafile (letters are automatically uppercased, and all non-alphanumeric characters are converted to underscores). Since your identifiers don't usually end with _BMP or _PCX or _WAV or whatever extension you use, this works rather well. --- |
ImLeftFooted
Member #3,935
October 2003
![]() |
Now try naming the new entry something besides foo.bmp Ya, ya thats right, you can't do it! |
|