gpt4 book ai didi

c++ - 快板 C++ 库

转载 作者:行者123 更新时间:2023-11-28 08:21:00 25 4
gpt4 key购买 nike

这个问题困扰我好久了。当我编译这部分代码时,它在位图上方显示黑线。可能是什么问题,是否有任何解决方案?

void start()
{
FONT *verdana;
PALETTE palette;
verdana = load_font("verdana.pcx", palette, NULL);
clear_to_color(screen,makecol(0,0,0));
SAMPLE *tac = load_sample("clunk.wav");

topce_bmp=load_bitmap("topce.bmp",NULL);
palki_bmp=load_bitmap("palka.bmp",NULL);

int cred_anim=255;
int cred_anim_fade=0;
SPEED=4;
int timer=0;
while(cred_anim_fade!=255)
{
line( screen, 3, 0, 3, 600, makecol( cred_anim_fade, cred_anim_fade, cred_anim_fade));
line( screen, 797, 0, 797, 600, makecol( cred_anim_fade, cred_anim_fade, cred_anim_fade));
if(key[KEY_ENTER])
{
menu(0,NULL);
}

// BATS


if(y>0&&y<400)
{
y=posy-100;
}
else if(y<=0) y=1;
else if(y>=400) y=399;

draw_sprite( screen,palki_bmp, 20, y);

if(y1>0&&y1<400)
{
y1=posy-100;
}
else if(y1<=0) y1=1;
else if(y1>=400) y1=399;

draw_sprite( screen,palki_bmp, 765, y1);
rest(10);
cred_anim_fade++;
}

while (timer!=1000)
{

if(key[KEY_ENTER])
{
menu(0,NULL);
}

timer++;
acquire_screen();

clear_to_color(screen,makecol(0,0,0));


// BORDERS

line( screen, 3, 0, 3, 600, makecol( 255, 255, 255));
line( screen, 797, 0, 797, 600, makecol( 255, 255, 255));

// BATS


if(y>0&&y<400)
{
y=posy-100;
}
else if(y<=0) y=1;
else if(y>=400) y=399;

draw_sprite( screen,palki_bmp, 20, y);

if(y1>0&&y1<400)
{
y1=posy-100;
}
else if(y1<=0) y1=1;
else if(y1>=400) y1=399;

draw_sprite( screen,palki_bmp, 765, y1);



// COLLISION X-AXIS

if(check_posy==1)
{
if(posy<15)
{
posy=posy+SPEED;
check_posy=1;
}
else if(posy>585)
{
posy=posy-SPEED;
check_posy=2;
}
else posy=posy+SPEED;
}
else if(check_posy==2)
{
if(posy<15)
{
posy=posy+SPEED;
check_posy=1;
}
else if(posx>585)
{
posy=posy-SPEED;
check_posy=2;
}
else posy=posy-SPEED;
}


// COLLISION WITH BATS

if(check_posx==1)
{
if(posx<50&&posy>y&&posy<y+200)
{
SPEED=SPEED+3;
posx=posx+SPEED;
check_posx=1;
play_sample(tac,500, 100, 1000, 0);
}
else if(posx>750&&posy>y1&&posy<y1+200)
{
SPEED=SPEED+3;
posx=posx-SPEED;
check_posx=2;
play_sample(tac,500, 0, 1000, 0);
}
else posx=posx+SPEED;
}
else if(check_posx==2)
{
if(posx<50&&posy>y&&posy<y+200)
{
SPEED=SPEED+3;
posx=posx+SPEED;
check_posx=1;
play_sample(tac,500, 100, 1000, 0);
}
else if(posx>750&&posy>y1&&posy<y1+200)
{
SPEED=SPEED+3;
posx=posx-SPEED;
check_posx=2;
play_sample(tac,500, 0, 1000, 0);
}
else posx=posx-SPEED;
}

draw_sprite( screen,topce_bmp, posx-13, posy-10);

rest(10);
}
clear_to_color(screen,makecol(0,0,0));
textout_centre_ex(screen, verdana, "PONG!",400,320, makecol(cred_anim,0,0),makecol(0,0,0));
textout_centre_ex(screen, verdana, "Vistinska igra.",400, 420, makecol(cred_anim,cred_anim,cred_anim),makecol(0,0,0));
rest(3000);
while(cred_anim!=0)
{
clear_to_color(screen,makecol(0,0,0));
textout_centre_ex(screen, verdana, "PONG!",400,320, makecol(cred_anim,0,0),makecol(0,0,0));
textout_centre_ex(screen, verdana, "Vistinska igra.",400, 420, makecol(cred_anim,cred_anim,cred_anim),makecol(0,0,0));
cred_anim--;
rest(1);
}
}

最佳答案

关于代码的一些想法:

-您调用了 acquire_screen() 但从未调用 release_screen()。这很糟糕,not to mention all the warnings allegro gives you in the documentation for acquire_screen() .

-“黑线”有点模糊(它们出现的时间、地点和程度?)但根据您对 clear_to_color() 看起来如何的评论,直接绘制到屏幕也可能是一个问题导致问题。尝试 double buffering ,可以解决几个问题。

希望这对您有所帮助。即使这些不能解决您的问题,它们也是值得牢记的好东西。

关于c++ - 快板 C++ 库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5843032/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com