![]() |
|
Black screen of DOOM |
SkaxCo
Member #8,323
February 2007
|
Whenever I try to draw from a datafile, nothing happens. Just nothing- the screen stays black. However, it worked in a test file. This is the relevant code: #include "ZomOn.h" DATAFILE *zombo = load_datafile("ZomOn.dat"); int main(){ //init stuff here blit((BITMAP*)zombo[hud_back].dat, screen, 0, 0, 0, 480, 480, 60); } This doesn't work. It just stays black (the screen). Why? |
gnolam
Member #2,030
March 2002
![]() |
You can't load datafiles in the global scope. You don't error check. Oh, and your example omits a hell of a lot of code of interest, making it impossible to say for certain what your problem is. In the future, please show actual problem code, instead of made-up or completely gutted examples. [EDIT] -- |
SkaxCo
Member #8,323
February 2007
|
The rest is ALL game logic. All of it. I pretty much cut the program down to those few lines. |
gnolam
Member #2,030
March 2002
![]() |
No, it's not. -- |
SkaxCo
Member #8,323
February 2007
|
The init stuff is fine. The game worked fine until I started using the datafile. I started out using all bmps, I just added the dat and replaced all of the blit stuff. But here: //there was the code here but I took it out.
EDIT: Thanks for the datafile info, its now locally made. Now I just need to work out a few kinks. EDIT2: If you can't have a global datafile, what is the best way to draw a bmp from the file in a function? |
gnolam
Member #2,030
March 2002
![]() |
You can have a global datafile. You just can't load it in the global scope. DATAFILE *foo; void bar(void) { foo = load_datafile("fnord.dat"); if (!foo) die_horrible_death(); }
-- |
SkaxCo
Member #8,323
February 2007
|
Oh, like bitmaps. |
Kris Asick
Member #1,424
July 2001
|
You can have a global datafile, you just can't initialize globally. The reason why you can't is because when load_datafile() is processed at program startup, you still have yet to call allegro_init(), thus load_datafile() doesn't work properly. Before you use ANY Allegro commands, you should always call allegro_init() first, which means any global pointers to Allegro objects cannot be initialized at global scope. --- Kris Asick (Gemini) --- Kris Asick (Gemini) |
Jonatan Hedborg
Member #4,886
July 2004
![]() |
You should probably brush up on your C/C++ a bit :/
|
SkaxCo
Member #8,323
February 2007
|
Quote: You should probably brush up on your C/C++ a bit :/ Yeah, I do...I started C++ like...5 months ago? |
|