俄罗斯方块,,,需要高手修改BUG..

到百度贴吧首页
新闻   网页   贴吧   知道   MP3   图片   视频   百科
    吧内搜索 | 帮助
  • 共有29篇贴子

俄罗斯方块,,,需要高手修改BUG..

218.85.57.*

1楼

#include "graphics.h"
#include "stdio.h"
#include "dos.h"
#include "conio.h"
#include "bios.h"
#include "stdlib.h"
#include "math.h"

#ifdef __cplusplus
#define __CPPARGS ...
#else
#define __CPPARGS
#endif

#define VK_LEFT 0x4b00
#define VK_RIGHT 0x4d00
#define VK_DOWN 0x5000
#define VK_UP 0x4800
#define VK_HOME 0x4700
#define VK_END 0x4f00
#define VK_SPACE 0x3920
#define VK_ESC 0x011b
#define VK_ENTER 0x1c0d
#define VK_PGUP 0x4900
#define VK_PGDOWN 0x5100
#define TIMER 0x1c


void drawblock(int,int,int);
void nedr(void);
void fk(int,int,int,int);
void rewr(int,int,int,int);
void rrwf(int,int);
int  is_bd(int,int,int);
int  is_line(void);
void interrupt ( *oldhandler)(__CPPARGS);
void KillTimer(void);
void SetTimer(void interrupt (*IntProc)(__CPPARGS));
void rscore(int);


int fkt[]={0,4,8,12,14,16,18};
int cj[]={0,100,300,900,1500};
long grc[]={0,3000,60000,90000,120000,150000,180000,210000,240000,270000};
int cjb[]={0,0,0,0,0,0,0,0,0,0};
char cjc[]="score:         0";
char grad[]="grade:0";


struct shape
{
short xy[8];
short color;
short next;
};

struct shape shapes[19]=
{
/* {x1,y1,x2,y3,x3,y3,x4,y4,color,next} */
{1,1,2,1,3,1,3,2,LIGHTBLUE,1},  /* □□□□ */
{2,2,3,0,3,1,3,2,LIGHTBLUE,1},  /* □■□□ */
   {1,1,1,2,2,2,3,2,LIGHTBLUE,1},  /* □■□□ */
        {2,0,2,1,2,2,3,0,LIGHTBLUE,-3}, /* □■■□ */

{1,1,1,2,2,1,3,1,LIGHTCYAN,1},  /* □□□□ */
{2,0,3,0,3,1,3,2,LIGHTCYAN,1},  /* □■■□ */
{1,2,2,2,3,1,3,2,LIGHTCYAN,1},  /* □■□□ */
{2,0,2,1,2,2,3,2,LIGHTCYAN,-3}, /* □■□□ */

{2,1,3,0,3,1,3,2,LIGHTRED,1},   /* □□□□ */
{1,2,2,1,2,2,3,2,LIGHTRED,1},   /* □□□□ */
{1,0,1,1,1,2,2,1,LIGHTRED,1},   /* □■□□ */
        {1,0,2,0,2,1,3,0,LIGHTRED,-3},  /* ■■■□ */

{2,1,2,2,3,0,3,1,DARKGRAY,1},   /* □□□□ */
{1,0,2,0,2,1,3,1,DARKGRAY,-1},  /* □□□□ */
              /* □■■□ */
/* ■■□□ */

{2,0,2,1,3,1,3,2,MAGENTA,1},    /* □□□□ */
{1,2,2,1,2,2,3,1,MAGENTA,-1}, /* □□□□ */
/* ■■□□ */
/* □■■□ */

{0,1,1,1,2,1,3,1,BROWN,1}, /* □■□□ */
{1,0,1,1,1,2,1,3,BROWN,-1}, /* □■□□ */
/* □■□□ */
/* □■□□ */

{2,1,2,2,3,1,3,2,YELLOW,0}, /* □□□□ */
/* □□□□ */
/* □■■□ */
/* □■■□ */

};

int stx=5,sty=8,sdx=24,sdy=18,shx=7,shy=22,adx=4,ady=1,nexti,TimerCounter=0,grade=0,end=0;
unsigned long score=0;

short board[25][12]=  /* 方块空间表示,1表示有方块 */
{
{1,1,1,1,1,1,1,1,1,1,1,1},
{1,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,1},  /*  0   */
{1,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,1},  /*  5   */
{1,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,1},  /*  10  */
{1,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,1},

218.85.57.*

2楼

{1,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,1},  /*  15  */
{1,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,1},
{1,1,1,1,1,1,1,1,1,1,1,1},  /*  20  */
};

short colable[25][12]= /* 方块空间颜色,1表示背景色蓝色*/
{
{1,1,1,1,1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1,1,1,1,1},  /*  0   */
{1,1,1,1,1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1,1,1,1,1},  /*  5   */
{1,1,1,1,1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1,1,1,1,1},  /*  10  */
{1,1,1,1,1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1,1,1,1,1},  /*  15  */
{1,1,1,1,1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1,1,1,1,1},
{1,1,1,1,1,1,1,1,1,1,1,1},  /*  20  */
};


void interrupt newhandler(__CPPARGS)   /* 新的时钟中断处理函数 */
{
TimerCounter++;
oldhandler();
}

void SetTimer(void interrupt (*IntProc)(__CPPARGS))    /* 设置新的时钟中断 */
{
oldhandler=getvect(TIMER);
disable();
setvect(TIMER,IntProc);
enable();
}

void KillTimer()    /* 恢复原有的时钟中断处理过程 */
{
disable();
setvect(TIMER,oldhandler);
enable();
}


void rscore(int line)   /* 成绩更新函数 */
{
int i,j,k=1;
unsigned long s,f;
score+=cj[line];
setfillstyle(1,GREEN);
bar(0,5,150,30);
s=score;
if(s>=grc[grade])
{
grade++;
grad[6]=grade+48;
bar(180,5,300,30);
moveto(200,20);
outtext(grad);
}

for(i=9;i>0;i--)
{
f=pow(10,i);
j=s/f;s=s%f;
if((!j)&&k);
else k=0,cjc[15-i]=j+48;
}
moveto(10,20);
outtext(cjc);
}


int is_bd(int x1,int y1,int i)    /* 判断是否有方块 */
{
int j,x2,y2;
for(j=0;j<4;j++)
{
x2=shapes[i].xy[2*j];
y2=shapes[i].xy[2*j+1];
if(board[x1+x2+adx][y1+y2+ady])return 0;
}
return 1;
}

void fk(int re,int x1,int y1,int i)     /* 方块的擦除、重写,并判断是否结束 有问题 */
{
int j,x2,y2,color;
for(j=0;j<4;j++)
{
x2=shapes[i].xy[2*j];
y2=shapes[i].xy[2*j+1];
if(!re) color=getbkcolor();
else color=shapes[i].color;
if(re==2)
{
if((x1+x2)<=-1)
{
printf("Game is OVER!");
getch();
end=1;
}
break;
}
else
{
if((x1+x2)<=-1)
continue;
}
board[x1+x2+adx][y1+y2+ady]=re;
colable[x1+x2+adx][y1+y2+ady]=color;
drawblock(stx+x1+x2,sty+y1+y2,color);
}
/* getch();   */

}

void drawblock(int x,int y,int color)   /* 写1个相对单位点的函数 */
{
int i,j;
for(i=0;i<16;i++)
for(j=0;j<16;j++)
putpixel(y*16+j,x*16+i,color);
}

void nedr(void)   /* 产生并写下一个方块的函数 */
{
int j,x2,y2,i,color;
setfillstyle(1,GREEN);
nexti=i=random(19);
    bar(shy*16,shx*16,(shy+4)*16,(shx+4)*16);
for(j=0;j<4;j++)
{
x2=shapes[i].xy[2*j];
y2=shapes[i].xy[2*j+1];

218.85.57.*

3楼

color=shapes[i].color;
drawblock(shx+x2,shy+y2,color);
}
}

int is_line(void)   /* 判断是否成行 有问题 */
{
int i,j,k=0;
for(i=23;i>4;i--)
{
for(j=1;j<11;j++)
if(!board[i][j])break;
if((j!=11)&&!k)continue;
if(j==11){k++;continue;}
rrwf(i,k);
k=0;
}
return k;
}

void rrwf(int line,int k)  /* 成行后的处理 有问题 */
{
int i,j;
rscore(k);
for(i=line+k;i>4;i--)
for(j=1;j<12;j++)
colable[i][j]=colable[i-k][j],board[i][j]=board[i-k][j];
setfillstyle(1,BLUE);
bar(sty*16,stx*16,(sdy)*16-1,(sdx+1)*16-1);
for(i=5;i<24;i++)
for(j=1;j<11;j++)
if(board[i][j])drawblock(stx+i-4,sty+j-1,colable[i][j]);
}


void main(void)
{
int drive,mode,i,j=0,k,x1,y1,key,re=1;

SetTimer(newhandler);

drive=DETECT;mode=DETECT;
initgraph(&drive,&mode,"");

rscore(0);

setbkcolor(BLUE);
x1=-4;y1=3;i=fkt[j];
setfillstyle(1,GREEN);
bar(shy*16,shx*16,(shy+4)*16,(shx+4)*16);
bar((sty)*16-6,(shx-2)*16-6,(sdy)*16+5,(sdx+1)*16+5);
setfillstyle(1,BLUE);
bar(sty*16,stx*16,(sdy)*16-1,(sdx+1)*16-1);
nedr();
fk(re,x1,y1,i);
for(key=0;;key=bioskey(1))
{
if(key)bioskey(0);
if(key==VK_UP)
{
fk(0,x1,y1,i);
if(is_bd((k=x1-1),y1,i))fk(re,x1=k,y1,i);
else fk(re,x1,y1,i);
}
if(key==VK_LEFT)
{
fk(0,x1,y1,i);
if(is_bd(x1,(k=y1-1),i))fk(re,x1,y1=k,i);
else fk(re,x1,y1,i);
}
if(key==VK_RIGHT)
{
fk(0,x1,y1,i);
if(is_bd(x1,(k=y1+1),i))fk(re,x1,y1=k,i);
else fk(re,x1,y1,i);
}
if(key==VK_SPACE)
{
fk(0,x1,y1,i);
if(is_bd(x1,y1,(k=i+shapes[i].next)))fk(re,x1,y1,i=k);
else fk(re,x1,y1,i);
}
if(key==VK_PGUP)
{
fk(0,x1,y1,i);
if(is_bd(x1,y1,k=fkt[++j%7]))fk(re,x1,y1,i=k);
else fk(re,x1,y1,i);}
if(key==VK_PGDOWN)
{
fk(0,x1,y1,i);
if(is_bd(x1,y1,k=fkt[(j+=6)%7]))fk(re,x1,y1,i=k);
else fk(re,x1,y1,i);
}
if(key==VK_ESC)
break;

if((key==VK_DOWN)||(TimerCounter>9))
{
if(TimerCounter>9)TimerCounter=0;
fk(0,x1,y1,i);
if(is_bd((k=x1+1),y1,i))
fk(re,x1=k,y1,i);
else
{
fk(re,x1,y1,i);
is_line();
fk(2,x1,y1,i);
if(end)break;
i=nexti;x1=-4;y1=3;
fk(re,x1,y1,i);
nedr();
}
}
}

KillTimer();

}

218.85.57.*

4楼

急需高手。。。期末考的。。。。。

5楼

这没什么BUG啊?!可以用。
210.21.122.*

6楼

完全可以运行的,只要你把中间的" 
 作者: 218.85.57.* 2005-5-12 15:50   回复此发言 
 
--------------------------------------------------------------------------------
 
3 俄罗斯方块,,,需要高手修改BUG.. "这个地方删掉就可以了,这些在里面是非法的

218.1.127.*

7楼

--------------------Configuration: sds - Win32 Debug--------------------
Compiling...
ww.cpp
c:\program files\microsoft visual studio\myprojects\sds\ww.cpp(1) : fatal error C1083: Cannot open include file: 'graphics.h': No such file or directory
Error executing cl.exe.

sds.exe - 1 error(s), 0 warning(s)

210.77.8.*

8楼

环境变量没有设好

9楼

晕,你是不是用VC运行的呀,
VC不能载入'graphics.h'
要用TC2.0

10楼

可以正常运行呀,
要改什么BUg呀
说清楚点

11楼

找bug是程序编写者必要的技能,自己写的东西自己最清楚,最易找出来

12楼

为什么方快可以自由上下 还可以按上 有意思

13楼

这个俄罗斯方块安逸 还可以向上。。。

15楼

写程序为什么不在写的时候就写好注释啊!!!!
方便他人,也方便以后修改啊!
虽说我还是新手,但还是要批评你几句.

16楼

还没BUG啊!都可以网上飞还没BUG
60.20.135.*

17楼

bar(x-9,y+1,x-1,y+9);Mark[(y-90)/10][(x-100)/10]=1;Mark[(y-90)/10][12]++;
这是俄罗斯方块的一个坐标  什么意思啊  求助   谢谢

61.167.60.*

18楼

看不懂?只要大家实际操作运行以下,什么疑问不都清楚了吗?非得要胡搅蛮缠,瞎说一片!注释是一定要写清楚地。这可是一个良好的风格问题!

19楼

改BUG比重写一个更难吧。

20楼

我才学到指针…不要吓我…
221.212.129.*

21楼

我来了,我在学习呢,呵呵,相信动手胜于白话.
我要试试!!!!!!!!

218.194.53.*

22楼

多些注释吧~

23楼

同7楼的。

24楼

我用VC6咋有一个错误啊 ! 我再试试有可能我打错了!!
218.94.137.*

25楼

怎么不可以改变左右方向啊?这样只能它出来什么样式就是什么样式了,一会就死了!
218.88.248.*

26楼

为什么我的VC每次都显示
fatal error C1083: Cannot open include file: 'graphics.h': No such file or directory.
请高手指点下迷津.

27楼

高手啊 强就一个字 向你学习
61.146.237.*

28楼

“Cannot open ”不就是不能打开的意思吗?
218.75.123.*

29楼

Vc不能打开'graphics.h'得用TC
222.134.125.*

31楼

强,我试过,BUG是可以往上飞。不过还是相当崇拜楼主

发表回复

内 容:
用户名:
  
©2010 Baidu 贴吧协议  意见反馈