So, I'm pretty much stuck with this for quite a while now
I'm trying to put all my images in a .dat file but grabber doesn't work in Vista, so I got dat for linux and put all the images in a .dat file using linux. The only problem is that I can't get the images to be loaded in the game. It compiles fine, but the images don't show up on the screen.
My code for loading the images is pretty much this:
Is something wrong with my code?
I've a feeling it would help if you showed more code.
Also, there should be a ';' on the last statement but I guess you cut and pasted a bit inaccurately missing the last character.
I don't think anyone can diagnose your problem from the code you posted because it all seems okay.
What else would you like to see? I've attached my main file just in case
Sorry moodle.
I can tell by your code that you know more about it all than me. You need someone else to help.
Just wondered if you'd called allegro_init() before loading the datafile.
EDIT : something tells me you're problem is because you made the dat file on linux though.
This is what I've seen some do:
It may not be the way your dat file is set up, but it may help.
@OnlineCop
Since I'm using global compression, the load_datafile_object will be slow, and I'll only try this after I think there's no more chance of figuring this out.
I mean, my problem doesn't seem to be with loading the file. I've added an if statement to print something if I wasn't able to load it, and it didn't print anything. So I have no idea of wtf is going on..
I was more referring to line 18...
I dunno; you only sent main.cpp, and we need
@William
I've tried doing this....and the game runs just the same, without printing or exiting..
@OnlineCop
I can send the other files, but I don't think they're important..They have the classes I wrote(and there are quite a few
) and dat.h is the header created when I used dat on linux. I've attached it, and if you want I could attach my classes later.
EDIT: Ok, nevermind it...I guess the problem was when I created the .dat file in linux. Thanks anyways
What about if you try :-
...right after you load it.
Again I'm probably underestimating your abilities but I wondered if there might be some other error in your code which would mean the bitmap's getting drawn somewhere off-screen.
@William
Nah, I've managed to make the image appear properly
Now, since my images will be loaded by many different classes in different files, I was trying to put my DATAFILE as a global variable, but my compiler is complaining(probably about the packfile_password()- not 100% sure about this.
I declared my DATAFILE as an extern variable on my gamebasics.h file, and I'm doing this in the .cpp:
And the error I get is: error:
expected constructor, destructor, or type conversion before '(' token
This error pops up on the 2 lines where I'm using packfile_password..Any clues?
If you want DATAFILE* data to be global, shouldn't this work fine?
DATAFILE* data = NULL; ... void that_function(void) { ... packfile_password("password"); data = load_datafile("data.dat"); ... }
Yes, it should 
But it isn't 
Some of the images appear just fine, and others are completely screwed up. And now the game stops working all of a sudden..
I think I'll go to bed now, and try to fix this tomorrow
If the grabber won't work you can use the dat.exe command line tool to add files to a dat file.
Also, i ran into the same problem. Is this a C program or C++ program? I just wrote a game in C and put all my images into a dat file and ran into the same thing. To fix it i had to load all the images for all the sprites before i setup the sprite data like x, y, etc. This is assuming the BITMAP images for the sprites are separate from the other sprite data. It isn't as organized but its the only thing i found to fix it. If you are using C like i did, i used malloc to create the sprites, my only guess is somehow calling this before loading an image was somehow messing it up. So by loading all the images first and then using malloc to create the sprites fixed it.
I'm trying to put all my images in a .dat file but grabber doesn't work in Vista
Grabber runs just fine with Vista.