Allegro extreme problem

hello ive been using allegro for maybe a week now and ive noticed when i load to many BITMAPS my program starts to not respond. Well how am i supposed to have items and such if im only aloud like 2 BITMAP images. i will paste my code and maybe i made a mistake. pls help, im using dev c++ with all allegro installed, libraries and everything

#include <allegro.h>

BITMAP *buffer;
BITMAP *grass;
BITMAP *stick;
BITMAP *left;
BITMAP *right;
BITMAP *up;
BITMAP *down;

int PX;
int PY;
int pspeed;
int dir;

void draw()
{
draw_sprite(buffer,grass,0,-10);
draw_sprite(buffer,stick,250,80);

if(dir == 180)
{
draw_sprite(buffer,left,PX,PY);
}
else if(dir == 0)
{
draw_sprite(buffer,right,PX,PY);
}
else if(dir == 90)
{
draw_sprite(buffer,up,PX,PY);
}
else if(dir == 270)
{
draw_sprite(buffer,down,PX,PY);
}
blit(buffer,screen,0,0,0,0,640,470);


}
END_OF_FUNCTION()


void player()
{
if(key[KEY_A])
{
PX -= pspeed;
dir = 180;
}else if(key[KEY_D])
{
PX += pspeed;
dir = 0;

}else if(key[KEY_S])
{
PY += pspeed;
dir = 270;

}else if(key[KEY_W])
{
PY -= pspeed;
dir = 90;

}
draw();

}
END_OF_FUNCTION()


int main()
{
allegro_init();
install_keyboard();
PX = 250;
PY = 250;
pspeed = 3;
set_color_depth(32);
set_gfx_mode(GFX_AUTODETECT_WINDOWED,640,470,0,0);
dir = 270;

down = load_bitmap("C:/Allegro/AB/wa/SA/down1.bmp", NULL);
left = load_bitmap("C:/Allegro/AB/wa/SA/left1.bmp", NULL);
right = load_bitmap("C:/Allegro/AB/wa/SA/right.bmp", NULL);
up = load_bitmap("C:/Allegro/AB/wa/SA/right.bmp", NULL);

grass = load_bitmap("C:/Allegro/AG/grass.bmp", NULL);
stick = load_bitmap("C:/Allegro/AG/stick.bmp", NULL);
buffer = create_bitmap(640,470);


while(!key[KEY_ESC])
{
player();
draw();


}
destroy_bitmap(grass);
destroy_bitmap(stick);
destroy_bitmap(buffer);
destroy_bitmap(left);
destroy_bitmap(right);
destroy_bitmap(up);
destroy_bitmap(down);
allegro_exit();


}
END_OF_MAIN()



Please help its appriciated.

you can also email me at coke905@hotmail.com


Last edited on
Topic archived. No new replies allowed.