⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄

📁 俄罗斯方块 俄罗斯方块 俄罗斯方块
💻
📖 第 1 页 / 共 3 页
字号:
/* cross.c */                                                                    
#include <io.h>                                                                  
#include <time.h>                                                                
#include <dos.h>                                                                 
#include <stdio.h>                                                               
#include <stdlib.h>                                                              
#include <conio.h>                                                               
#include <ctype.h>                                                               
#include <string.h>                                                              
#include <graphics.h>                                                            
#include "cross.h"                                                               
                                                                                 
#define MAXWIDTH 25                                                              
#define MAXHEIGHT 22                                                             
#define MAXNBUG 22                                                               
#define MAXNBBLT 100                                                             
#define MAXNGBLT 20                                                              
#define MAXLEVEL 20                                                              
#define STAGENBUG 5                                                              
                                                                                 
#define SPBUG 11                                                                 
#define SPGUN 5                                                                  
                                                                                 
#define ROADWIDTH 25                                                             
#define BACKCOLOR 8                                                              
#define EDGECOLOR 9                                                              
#define DLGBKCOLOR 1                                                             
#define INFBKCOLOR 8                                                             
#define BLOCKCOLOR1 9                                                            
#define BLOCKCOLOR2 1                                                            
                                                                                 
#define MARKTYPE 1                                                               
#define MARKSIZE 2                                                               
#define MARKCOLOR 2                                                              
                                                                                 
#define BUGCOLOR 2                                                               
#define BBLTCOLOR 12                                                             
#define GBLTCOLOR 13                                                             
#define GUNCOLOR1 12                                                             
#define GUNCOLOR2 4                                                              
                                                                                 
#define DLGTYPE 2                                                                
#define DLGSIZE 6                                                                
#define DLGCOLOR 15                                                              
                                                                                 
#define CHARCOLOR 5                                                              
                                                                                 
#define NUMTYPE 0                                                                
#define NUMSIZE 2                                                                
#define NUMCOLOR 12                                                              
#define WNUM 19                                                                  
#define HNUM 20                                                                  
                                                                                 
#define WCHAR 19                                                                 
#define HCHAR 22                                                                 
                                                                                 
#define X 7                                                                      
#define Y 50                                                                     
#define XB 6                                                                     
#define YB 5                                                                     
#define XDIALOG 2                                                                
#define YDIALOG Y+(3*YB+1)*ROADWIDTH+X                                           
   } BULLET;                                                                     
 typedef struct {                                                                
   int x,y,dx,dy,direction,nextdt,move,lives,nblt,fblt;                          
   } GUNNER;                                                                     
 typedef struct {                                                                
   char name[8];                                                                 
   long score;                                                                   
   } RECORD;                                                                     
 BUG bug[MAXNBUG];                                                               
 BULLET bblt[MAXNBBLT];                                                          
 BULLET gblt[MAXNGBLT];                                                          
 GUNNER gun;                                                                     
 GUNNER sgun[25][4];                                                             
                                                                                 
 int sp[MAXWIDTH][MAXHEIGHT];                                                    
 int initbugxy[MAXNBUG][2];                                                      
 int dt[5][2]={ 0,0,1,0,-1,0,0,1,0,-1 };                                         
 int sdt[4][2]={ 1,0,-1,0,0,1,0,-1 };                                            
 int nblt[MAXLEVEL ={ 1,1,2,2,3,3,4,4,4,5,5,5,6,6,7 };                           
 int sou[88][2]={                                                                
         0,0,180,4,200,3,180,1,150,4,150,4,                                      
       150,3,130,1,150,3,160,1,150,6,  0,2,                                      
       160,4,130,3,180,1,150,6,  0,2,                                            
       130,4,110,3,150,1, 90,6,  0,2,                                            
       130,     10,200,2,180,2,160,2,                                            
       150,2,130,2,150,2,160,2,150,6,  0,2,                                      
       100,4,150,4,150,4,140,2,170,2,                                            
       220,   18,                                                                
       200,1,220,1,200,1,190,1,200,2,130,2,150,2,160,4,                          
         0,1,150,1,160,1,150,1,110,1,220,2,180,2,  0,6,                          
         0,1,110,1,130,1,110,1, 80,1,160,2,150,2,  0,2,130,2,  0,2,              
       120,2,  0,14 };                                                           
 char name[8]="",str[40],stri[3],strin[8];                                       
                                                                                 
 int xb=XB,yb=YB,width=xb*3+1,height=yb*3+1,wr=ROADWIDTH,wb=wr*2,wbr=wb+wr;      
 int nbug=xb+yb*2-3,nbblt=0,ngblt=0;                                             
 int cbug=nbug,initlives=99;                                                     
 long twait=nbug*20000;                                                          
 int bspeed=10,bbspeed=440,gspeed=120;                                           
 int bbltspeed=110,gbltspeed=80,bbltfreq=6500;                                   
 int level=1;                                                                    
 int xinf=2*X+xb*wbr+wr,yinf=2,xhelp=xinf,yhelp=216;                             
 int xs=0,ys=0,xe=xb*wbr+wr-1,ye=yb*wbr+wr-1;                                    
 long oscore=0,cscore=0,ohighscore=0,chighscore=0;                               
                                                                                 
 int i,j,k,x,y,dx,dy,st;                                                         
 int sstep=0,nsou=0,step,num,xm,ym,wm,mm;                                        
 int direction=0,gdirection=0;                                                   
 int key=0,continu=2;                                                            
 int gdriver,gmode,so=1;                                                         
                                                                                 
 FILE *record;                                                                   
 RECORD rec[10];                                                                 
                                                                                 
 randomize();                                                                    
 detectgraph(&gdriver,&gmode);                                                   
 initgraph(&gdriver,&gmode,"d:\\borland\\bc31\\bgi");                            
 cleardevice();                                                                  
 setbkcolor(BACKCOLOR);                                                          
                                                                                 
 if ((record=fopen("e:\\wangjian\\cross\\cross.dat","rt"))==NULL) {              
   dialog("Can't open data file.");                                              
   closegraph();                                                                 
   exit(1);                                                                      
   }                                                                             
 for (i=0;i<10;i++) {                                                            
 setcolor(14);                                                                   
 outtextxy(292,23,"WANGJIAN Corporation Ltd.");                                  
 fill(XDIALOG,YDIALOG,WDIALOG-1,HDIALOG-1,DLGBKCOLOR);                           
                                                                                 
 setcolor(BLOCKCOLOR2);                                                          
 rectangle(X-1,Y-1,xinf-X,YDIALOG-X);                                            
 setcolor(BLOCKCOLOR1);                                                          
 line(     X-2,        Y-2,     2,    Y-X+2);                                    
 line(xinf-X+1,        Y-2,xinf-3,    Y-X+2);                                    
 line(     X-2,YDIALOG-X+1,     2,YDIALOG-3);                                    
 line(xinf-X+1,YDIALOG-X+1,xinf-3,YDIALOG-3);                                    

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -