Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
hey, I'm new to Allgero and am trying to understand how to use datafiles to display a background image stored in one.
I get this error:
`Background' undeclared (first use this function)the only problem is that 'Background' is the name of the file in the datafile which I created using the grabber tool packaged with Allegro.
This is the code I'm trying to use:
#include <allegro.h>
int main()
{
allegro_init();
install_keyboard();
set_color_depth(16);
set_gfx_mode( GFX_AUTODETECT, 640, 480, 0, 0);
DATAFILE *dat = load_datafile_object("bg.dat", "Background");
BITMAP *bmp;if (!dat)
{
/* report an error! */
return 1;
}
blit( ( BITMAP* )dat[ Background ].dat, bmp, 0, 0, 0, 0, 100, 100 );readkey();
unload_datafile(dat);
}
END_OF_MAIN();-----------------
Thanks for any helpdjas

ok I've managed to fiddle a bit and found out some more but I'm still stuck.
I can now compile my program successfully however I am unable to display the bitmap stored in my datafile.
Any suggestions anyone?--------------------
#include <allegro.h>int main()
{
allegro_init();
install_keyboard();
set_color_depth(16);
set_gfx_mode( GFX_AUTODETECT, 640, 480, 0, 0);
BITMAP *bmp;
DATAFILE *dat = load_datafile("bg.dat");
if (!dat)
{
return 1;
}
blit( ( BITMAP* )dat[1].dat, bmp, 0, 0, 0, 0, 640, 480 );readkey();
unload_datafile(dat);
}
END_OF_MAIN();
djas

It seems that in my tinkering I've managed to get this working on my own but just in case anyone is interested this code works:
#include <allegro.h>
int main()
{
allegro_init();
install_keyboard();
set_color_depth(16);
set_gfx_mode( GFX_AUTODETECT, 640, 480, 0, 0);DATAFILE *dat = load_datafile("bg.dat");
if (!dat)
{
return 1;
}
acquire_screen();
draw_sprite( screen, (BITMAP*)dat[0].dat, 0, 0);
release_screen();
readkey();
unload_datafile(dat);
return 0;
}
END_OF_MAIN();djas

![]() |
A problem with batch rena...
|
Copy and rename with a ba...
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |