short wrote:yeah... but you need to post more details... maybe some code.. something more then what you did
It happens EVERY time set_color_depth is set to 16. Here is some code that lags:
Code: Select all
#include "dude.h"
int main()
{
allegro_init();
install_keyboard();
set_gfx_mode(GFX_AUTODETECT,640,480,0,0);
set_color_depth(16); //LAGGGGGGGGGGGGG
BITMAP* sprite;
sprite=load_bitmap("sprite.bmp",NULL);
BITMAP* buffer=create_bitmap(SCREEN_W,SCREEN_H);
enemy test;
test.setup(sprite,SCREEN_W/2,SCREEN_H/2,200,200);
int x=100;
int y=100;
int w=0;
int h=0;
int xtl=0;
int ytl=0;
int xlr=0;
int ylr=0;
int v=5;
blit(sprite,buffer,0,0,x,y,SCREEN_W,SCREEN_H);
blit(buffer,screen,0,0,0,0,SCREEN_W,SCREEN_H);
while(!key[KEY_ESC])
{
get_clip_rect(sprite,&xtl,&ytl,&xlr,&ylr);
w=xlr;
h=ylr;
clear(buffer);
if(key[KEY_UP])
{
outcheck(&x,&y,w,h,v);
y-=v;
}
if(key[KEY_DOWN])
{
outcheck(&x,&y,w,h,v);
y+=v;
}
if(key[KEY_RIGHT])
{
outcheck(&x,&y,w,h,v);
x+=v;
}
if(key[KEY_LEFT])
{
outcheck(&x,&y,w,h,v);
x-=v;
}
vsync();
acquire_screen();
test.move(buffer);
blit(sprite,buffer,0,0,x,y,SCREEN_W,SCREEN_H);
blit(buffer,screen,0,0,0,0,SCREEN_W,SCREEN_H);
release_screen();
}
destroy_bitmap(sprite);
destroy_bitmap(buffer);
return 0;
}
END_OF_MAIN();
here is the dude.h file:
Code: Select all
#define USE_CONSOLE
#include "allegro.h"
#include <iostream>
void outcheck(int* x, int* y,int w,int h,int v)
{
if(*x+1>=SCREEN_W-w)
{
*x-=v;
}
if(*x-1<=0)
{
*x+=v;
}
if(*y+1>=SCREEN_H-h)
{
*y-=v;
}
if(*y-1<=0)
{
*y+=v;
}
}
class enemy
{
public:
enemy();
void setup(BITMAP* sprite,int x,int y,int u,int d);
void move(BITMAP* buffer);
void reset();
private:
int x;
int y;
BITMAP* image;
int up;
int down;
int u;
int d;
};
enemy::enemy()
{
u=0;
d=0;
}
void enemy::setup(BITMAP *sprite, int xx, int yy, int u, int d)
{
image=sprite;
x=xx;
y=yy;
up=u;
down=d;
}
void enemy::reset()
{
u=0;
d=0;
}
void enemy::move(BITMAP* buffer)
{
if(u<=up)
{
y-=1;
u+=1;
}
else if(d<=down)
{
y+=1;
d+=1;
}
else
{
reset();
}
blit(image,buffer,0,0,x,y,SCREEN_W,SCREEN_H);
}
I think it has something to do with blitting images to the screen because i can print shapes on the screen SUPER fast in 16 and even 32 bit modes.