Page 1 of 1

PostPosted: Tue Jun 17, 2003 4:47 pm
by Glasswalker
Hello again... I am trying to use imgload in my program to precache all my graphics and then paint them to screen, (some are transparent, some aren't) First I had the problem with the default.dat file, but fixed that...

Now here is my problem: My code loads up 9 tile images, then a test function cycles through them... but nothing is displayed on screen at all... Also, in the log I noticed that the files are all being assigned a handle of 1 no matter what...

Here is the affected code:
(not including all the defines and structs and crap that is not related to it)

main()
{
// struct bug_s bug[NUM_BUGS];
init_game();
main_program_loop();
}

main_program_loop()
{
int i;
puts("Beginning Main Game Loop...\r\n");
puts("===========================================\r\n");
for(i=0;i<num_images;i++)
drawtile(i,0,i);
puts("===========================================\r\n");
puts("Main Loop Complete... \r\n\r\n");

}


init_game()
{
puts("Beginning Game Initialization Sequence...\r\n");
puts("===========================================\r\n");
init_graphics_array();
loadgraphics();
puts("===========================================\r\n");
puts("Initialization Sequence Complete... \r\n\r\n");
}

init_graphics_array()
{
string imagesfolder;
puts("Initializing Graphics Array..."+"\r\n");
cwd = "\\Program Files\\Bugz\\";
puts("CWD is set to: "+cwd+"\r\n");
imagesfolder = cwd+"Images\\";
puts("Images folder is set to: "+imagesfolder+"\r\n");
num_images = 9;
puts("Num_Images set to: "+num_images+"\r\n");
puts("Storing Image Filenames In Array..."+"\r\n");
image_file[0] = imagesfolder+"grass.bmp";
image_file[1] = imagesfolder+"food.bmp";
image_file[2] = imagesfolder+"toxin.bmp";
image_file[3] = imagesfolder+"hazard.bmp";
image_file[4] = imagesfolder+"water.bmp";
image_file[5] = imagesfolder+"bugup.bmp";
image_file[6] = imagesfolder+"bugright.bmp";
image_file[7] = imagesfolder+"bugdown.bmp";
image_file:?: = imagesfolder+"bugleft.bmp";
puts("Image Array Initialized Successfully..."+"\r\n");
}

loadgraphics()
{
int i;
puts("Loading Graphics Data To Memory..."+"\r\n");
puts("==================================="+"\r\n");
for(i=0;i<num_images;i++)
{
image_handle[i] = imgload(image_file[i],100,10,10);
if(image_handle[i]==0)
puts("Error Loading Image File: "+image_file[i]+"\r\n");
if(image_handle[i]!=0)
puts("Successfully loaded image file: "+image_file[i]+" into handle: "+image_handle+"\r\n");
}
puts("==================================="+"\r\n");
puts("Image Data Loaded Successfully..."+"\r\n");
}

drawtile(int tileid,int x,int y)
{
int newx,newy;
newx = (x*10)+50;
newy = (x*10)+100;
if(imgbitblt(image_handle[tileid],newx,newy,10,10,10,10,0)==-1)
puts("Error Drawing Image Handle: "+image_handle[tileid]+"\r\n");
}

and here is the output of the program console log:

Beginning Game Initialization Sequence...
===========================================
Initializing Graphics Array...
CWD is set to: \Program Files\Bugz\
Images folder is set to: \Program Files\Bugz\Images\
Num_Images set to: 9
Storing Image Filenames In Array...
Image Array Initialized Successfully...
Loading Graphics Data To Memory...
===================================
Successfully loaded image file: \Program Files\Bugz\Images\grass.bmp into handle: 1
Successfully loaded image file: \Program Files\Bugz\Images\food.bmp into handle: 1
Successfully loaded image file: \Program Files\Bugz\Images\toxin.bmp into handle: 1
Successfully loaded image file: \Program Files\Bugz\Images\hazard.bmp into handle: 1
Successfully loaded image file: \Program Files\Bugz\Images\water.bmp into handle: 1
Successfully loaded image file: \Program Files\Bugz\Images\bugup.bmp into handle: 1
Successfully loaded image file: \Program Files\Bugz\Images\bugright.bmp into handle: 1
Successfully loaded image file: \Program Files\Bugz\Images\bugdown.bmp into handle: 1
Successfully loaded image file: \Program Files\Bugz\Images\bugleft.bmp into handle: 1
===================================
Image Data Loaded Successfully...
===========================================
Initialization Sequence Complete...

Beginning Main Game Loop...
===========================================
===========================================
Main Loop Complete...



if anyone can help with this one I would really appreciate it :)

PostPosted: Wed Jun 18, 2003 12:05 am
by Mickle
loadgraphics()
puts("..." + image_handle + "...");
but must be puts("..." + image_handle[i] + "...");
1 is value of PocketC pointer image_handle.
.
drawtile().
newx = (x*10)+50;
newy = (x*10)+100; // do you want it ? or newy = (y * 10) + 100; ?
.
It contains your main error:
imgbitblt(image_handle[tileid],newx,newy,10,10,10,10,0)
Look at help\function library\draw\imgbitblt()
Must be:
imgbitblt(image_handle[tileid], newx, newy, 10, 10, 0, 0, 0)
More attention when coding...