急求VC++MFC弹球游戏代码

2025-04-30 07:45:22
推荐回答(3个)
回答1:

引用:
#include "graphics.h"
#include "math.h"
#define LEFT 0x4b00
#define RIGHT 0x4d00
#define ESC 0x011b
int x,y,x1,y1,key,t1,t2,keyx,keylong,keymove,over=0,i,tt=0,fast;
int ballx[9]={53,103,263,120,236,390,410,450,600};
int bally[9]={158,239,120,113,30,313,120,263,231},ballz[9]={0};
float ls;
win()
{float lx,ly,ll;
for(i=0;i<9;i++)
{
if(ballz==1)/*如果球体已经消失就不判断*/
continue;
lx=(float)(ballx-x);
ly=(float)bally-y;
ll=lx*lx+ly*ly;
ls=sqrt(ll);
if((int)ls<17)/*判断两球是否碰到*/
{tt++;/*记录消失几个球*/
fast-=50;/*速度加快*/
if(i%2==0)/*移动加快*/
keymove+=5;
else
{
setcolor(0);
rectangle(keyx,460,keyx+keylong,470);
keylong-=10;/*长条变短*/
setcolor(YELLOW);
rectangle(keyx,460,keyx+keylong,470);
}
ballz=1;
setcolor(0);
circle(ballx,bally,10);
if(yif(x{t1=-1;t2=-1;}
else
{t1=1;t2=-1;}
else
if(x{t1=-1;t2=1;}
else
{t1=1;t2=1;}
}
}
}
fungo()
{ x=100,y=50,keyx=200,keylong=100,keymove=15,fast=600;
for(i=0;i<9;i++)
{
setcolor(i+1);
circle(ballx,bally,10);
}
sleep(1);
t1=t2=1;
while(1)
{
while(!kbhit())
{
setcolor(YELLOW);
rectangle(keyx,460,keyx+keylong,470);
x1=x;
y1=y;
x+=t1;
y+=t2;
setcolor(4);
circle(x,y,6);
delay(fast);
setcolor(0);
circle(x,y,6);
win();
if(tt==9)/*胜利*/
{
cleardevice();
over=1;
setcolor(RED);
settextstyle(0,0,4);
setusercharsize(3,1,3,1);
outtextxy(200,200," YOU WIN! ");
break;
}
if(y>480)/*失败*/
{
cleardevice();
over=1;
setcolor(RED);
settextstyle(0,0,4);
setusercharsize(3,1,3,1);
outtextxy(200,200,"GAME OVER");
break;
}
else if(x==11&&y==11)/*判断碰到东西*/
{t1=1;t2=1;}
else if(x==629&&y==11)
{t1=-1;t2=1;}
else if(x==11)
{
if(y{t1=1;t2=-1;}
else
{t1=1;t2=1;}
}
else if(y==11)
{
if(x{t1=-1;t2=1;}
else
{t1=1;t2=1;}

发不下了```你加我QQ 我告诉你``` 记住加分哦``

回答2:

http://zhidao.baidu.com/question/18873874.html这里有

回答3:

Visual C++ MFC咯?源代码以及可执行文件发你邮箱了!注意查收!