贪吃蛇.目前修改的最新版本(加入了音效)
1 //Lee. 控制台 贪吃蛇 2 //测试版本1.1 3 //解决几个问题,1.为什么Map[79][24] 地图的横坐标都要用X * 2的形式,, 4 // 而纵坐标的1却表示两个字节。 5 /* (即横坐标1表示一个宽度,但是纵坐标的1表示两个宽度) 6 因为是字符游戏,地图并不是那么重要,只要有个标记能让玩家看清边界就行了. 但是 7 根据我的经验,控制台中的一行的高度大约为一列的宽度的两倍. 换句话说,在控制台中,一 8 个1×1的格子,其实是个长方形,它的高度为宽度的两倍. 因此,为了美观起见,我的横坐标 9 (列值)一律使用双倍值,这样看上去就是一个匀称的方格子. ASCII 字符全都是一个字符宽 10 度的,因此,我在本文接下来的部分中,统一使用中文宽字符来进行布局. 典型的中文布局符 11 号有以下这些: 12 ◆◇□■●●★☆▲△¤◎+┏┛┗┓━┃┫┣┳┻╋ 13 */ 14 // 2. 光标隐藏函数有什么用,好像不需要这个函数也没有影响。 15 // 3. Key()函数 16 下载地址:http://pan.baidu.com/share/link?shareid=405907771&uk=3325080974,包括pcc32库文件和源文件。 17 18 #include<iostream> 19 #include<windows.h> 20 #include<conio.h> 21 #include<time.h> 22 #include<stdlib.h> 23 #include "mmsystem.h" 24 #pragma comment(lib,"winmm.lib") 25 #include"pcc32.h" 26 #pragma comment(lib, "pcc32_vc6.lib") 27 28 using namespace std; 29 30 #define UP 72 //定义上下左右常量 31 #define DOWN 80 32 #define LEFT 75 33 #define RIGHT 77 34 #define ESC 27 35 #define SPACE 32 //空格 36 #define ENTER 13 //回车 37 38 int X, Y;//食物坐标 39 40 int Map[79][24]={{0}}; //地图尺寸,其实有食物记为1 41 int over = 0; //用来标记游戏结束 42 int score = 0; //记录分数 43 int speed = 130; //记录速度 44 int ColoArray[15]={15,1,2,3,4,5,6,7,8,9,10,11,12,13,14}; //自己定义的用来控制颜色的数组 45 struct Snake 46 { 47 int x, y; //坐标 48 int direction; //方向 49 }Snake[100]; //蛇最多100个节点 50 51 int length = 3; //初始化蛇的长度为3 52 int Key_Menu; //开始菜单界面用的零时按键 53 54 void GamePrint(); //游戏开始画面函数 55 void Gameinit(); //游戏初始化函数 56 void Sweep_Screem(); //清屏函数 57 void Gotoxy(int , int); //光标移动函数 58 void Hid_Cursor(); //光标隐藏函数 59 void Snake_Move(); //蛇运动函数 60 int Create_Food(); //食物产生函数 61 void Pwall(); //画墙函数 62 void Key(); //键盘操作和处理函数 63 void Hit_Wall(); //判断是否撞墙 64 void Eat_Itself(); //判断是否咬到自己 65 void Whether_Eat(); //判断蛇是否吃到食物 66 void GameRun(); //游戏运行函数 67 void SurFace(); 68 void GameOver(); 69 void Pause(); //游戏暂停函数 70 void MyCount1(); //提示边栏,用来做一些提示 71 void MyCount2(); //统计边栏,用来做一些统计 72 void Menu( int ); //开始界面 73 void Inti_Data(); //初始化数据 74 75 int main() //主函数 76 { 77 START: 78 Inti_Data(); 79 fixConsoleSize(18,15); 80 Hid_Cursor(); 81 SurFace(); 82 PlaySound(TEXT("m22.wav"), NULL, SND_FILENAME | SND_ASYNC ); 83 fixConsoleSize(105,25); 84 GamePrint(); 85 Gameinit(); 86 GameRun(); 87 while(over) //如果游戏结束了,是否重新开始。按R键为重新开始 88 { 89 int t=getch(); 90 if(t == 'r'||t == 'R') 91 { 92 system("cls"); 93 goto START; 94 } 95 } 96 return 0; 97 } 98 99 100 void GamePrint() //游戏开始画面函数(先是欢迎界面,然后是游戏规则,然后是画墙) 101 { 102 Gotoxy(36,8); 103 printf("┏┅┅┅┅┅┅┅┅┅┅┅┅┅┓"); 104 Gotoxy(36,9); 105 printf("┠ Welcome to RedSnake. ┨"); 106 Gotoxy(36,10); 107 printf("┠ by_Lee. ┨"); 108 Gotoxy(36,11); 109 printf("┗┅┅┅┅┅┅┅┅┅┅┅┅┅┛"); 110 Sleep(2000); 111 Sweep_Screem(); 112 Gotoxy(41, 7); 113 printf("┏┯┯┯┯┯┯┯┓"); 114 Gotoxy(41, 8); 115 printf("┠ Game Tips ┨"); 116 Gotoxy(41, 9); 117 printf("┠ ↑ Up ┨"); 118 Gotoxy(41, 10); 119 printf("┠ ↓ Down ┨"); 120 Gotoxy(41, 11); 121 printf("┠ ← Left ┨"); 122 Gotoxy(41, 12); 123 printf("┠ → Right ┨"); 124 Gotoxy(41, 13); 125 printf("┠ ESC Exit ┨"); 126 Gotoxy(41, 14); 127 printf("┠ SPACE Pause ┨"); 128 Gotoxy(41, 15); 129 printf("┗┷┷┷┷┷┷┷┛"); 130 131 Sleep(2200); 132 Sweep_Screem(); 133 Pwall(); //画墙函数 134 MyCount1(); //画边栏1 135 MyCount2(); //画边栏2 136 Sleep(1100); 137 } 138 139 140 void Gameinit() //游戏初始化 141 { 142 Snake[0].x = 10; // ■■□ 实际上是固定了初始蛇的位置 143 Snake[0].y = 12; 144 Snake[1].x = 8; 145 Snake[1].y = 12; 146 Snake[2].x = 6; 147 Snake[2].y = 12; 148 Snake[0].direction = RIGHT; //默认蛇的初始状态为向右运动 149 Gotoxy(10, 12); //根据蛇的位置跳转,并打印蛇头和蛇身 150 printf("□"); 151 Gotoxy(8, 12); 152 printf("■"); 153 Gotoxy(6, 12); 154 printf("■"); 155 } 156 157 158 void Sweep_Screem()//清屏函数 159 { 160 int i; 161 Gotoxy(0, 0); 162 for(i = 0;i < 25; i++) 163 { 164 printf(" "); 165 } 166 } 167 168 void Gotoxy(int x, int y)//移动光标 169 { 170 COORD coord; 171 coord.X=x; 172 coord.Y=y; 173 SetConsoleCursorPosition( GetStdHandle( STD_OUTPUT_HANDLE ), coord ); 174 } 175 176 void Hid_Cursor() //光标隐藏函数 177 { 178 HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE); 179 CONSOLE_CURSOR_INFO cci; 180 GetConsoleCursorInfo(hOut,&cci); 181 cci.bVisible=0;//赋1为显示,赋0为隐藏 182 SetConsoleCursorInfo(hOut,&cci); 183 } 184 185 186 void Snake_Move() //蛇运动函数 187 { 188 int i; 189 srand(time(NULL)); 190 Gotoxy(Snake[0].x, Snake[0].y); 191 setTextColor(ColoArray[rand()%14]); 192 printf("□"); 193 Gotoxy(Snake[1].x, Snake[1].y); 194 setTextColor(ColoArray[rand()%14]); 195 printf("■"); 196 Whether_Eat(); //检查是否吃到食物,如果吃到食物,蛇头坐标Map[Snake[0].x][Snake[0].y] = 0; 197 setTextColor(ColoArray[rand()%14]); 198 Create_Food(); //重新随机出一个食物,并且蛇的长度增加1,且新的蛇头产生 199 Gotoxy(Snake[length].x, Snake[length].y); 200 printf(" "); //消除原来的蛇尾。 201 //判断蛇是否吃到食物,如果吃到,则再Create一个食物 202 // Gotoxy(0, 0); //有BUG ,不知道怎么回事 203 // printf("■"); //有BUG ,不知道怎么回事 204 205 Eat_Itself(); //判断蛇是否咬到自己 206 for(i = length; i > 0; i--) //移动蛇的坐标 207 Snake[i] = Snake[i-1]; 208 209 Key(); //判断用户的键盘输入并进行处理 210 } 211 212 int Create_Food() //食物产生函数 213 { 214 if(length >= 40 ) 215 return 0; 216 int i; 217 if(Map[X][Y] == 0) 218 { 219 srand((unsigned int)time(0) + X);//等同于srand(time(0))或者srand(time(NULL))或者srand((int)time(0)),因为最终都要被强制转换为unsigned int; 220 X = (rand() % 38 + 1) * 2; 221 //X = rand() % 76 ;错误为什么? 222 223 srand((unsigned int)time(0) + Y + rand()); 224 Y = rand() % 23 + 1; 225 for(i = 0; i < length; i++) 226 if(Snake[i].x == X && Snake[i].y == Y) 227 { 228 i = -1; 229 break; 230 } 231 if(i != -1) 232 { 233 Map[X][Y] = 1; 234 Gotoxy(X, Y); 235 srand(time(NULL)); 236 setTextColor(ColoArray[rand()%14]); 237 printf("■"); 238 } 239 } 240 return 0; 241 } 242 243 void Whether_Eat() //判断蛇是否吃到食物 244 { 245 if(Map[Snake[0].x][Snake[0].y] == 1) 246 { 247 length++; 248 score += 10; 249 if(speed>45) 250 { 251 speed -= length/4; 252 } 253 setTextColor(WHITE); 254 Gotoxy(80,16); 255 printf("┠ Score: %4d ┨", score); 256 Gotoxy(80,15); 257 printf("┠ length: %3d ┨",length); 258 Gotoxy(80,17); 259 printf("┠ Speed: %3d ┨", speed); 260 Map[Snake[0].x][Snake[0].y] = 0; 261 } 262 } 263 264 void Eat_Itself() //判断蛇是否咬到自己 265 { 266 int i; 267 for(i = 3; i < length; i++) 268 { 269 if(Snake[0].x == Snake[i].x && Snake[0].y == Snake[i].y) 270 { 271 over=1; 272 break; 273 } 274 } 275 } 276 277 void Hit_Wall() //判断是否撞墙 278 { 279 if(Snake[0].x == 0) Snake[0].x = 76; 280 if(Snake[0].x == 78) Snake[0].x = 2; 281 if(Snake[0].y == 0) Snake[0].y = 23; 282 if(Snake[0].y == 24) Snake[0].y = 1; 283 } 284 285 286 void Key() 287 { 288 if(_kbhit())//判断是否按键 289 { 290 int ch = _getch(); 291 if(ch == 224)//判断按的是不是方向键 292 { 293 ch = _getch(); 294 if(ch+Snake[0].direction != 152)//判断按键是否是反方向 295 Snake[0].direction = ch;//如果不是就改变蛇头方向 296 } 297 else if(ch == 27)//判断用户是否退出 298 { 299 300 Gotoxy(30,12); 301 setTextColor(WHITE); 302 printf(" Successful Exit!\n "); 303 exit(0); 304 } 305 else if(ch == 32) 306 { 307 Pause(); 308 } 309 } 310 switch(Snake[0].direction) 311 { 312 case 72: Snake[0].y-=1; break; 313 case 80: Snake[0].y+=1; break; 314 case 75: Snake[0].x-=2; break; 315 case 77: Snake[0].x+=2; break; 316 } 317 } 318 319 /*void Key() //同方向将会出现问题 320 { 321 if(kbhit() != 0) 322 { 323 while(kbhit() != 0) 324 { 325 Snake[0].direction = getch(); 326 } 327 } 328 switch(Snake[0].direction) 329 { 330 case 72: Snake[0].y-=1; break; 331 case 80: Snake[0].y+=1; break; 332 case 75: Snake[0].x-=2; break; 333 case 77: Snake[0].x+=2; break; 334 } 335 } 336 */ 337 338 void Pwall() //画墙函数 339 { 340 srand(time(NULL)); 341 int i, j; 342 for(i = 39,j = 0; j < 39; i--, j++) 343 { 344 setTextColor(ColoArray[rand()%14]); 345 Gotoxy(j*2, 0); 346 printf("■"); 347 if(j < 24) 348 { 349 setTextColor(ColoArray[rand()%14]); 350 Gotoxy(78, j); 351 printf("■"); 352 } 353 Gotoxy(i*2, 24); 354 printf("■"); 355 if(i > 15) 356 { 357 setTextColor(ColoArray[rand()%14]); 358 Gotoxy(0, i-15); 359 printf("■"); 360 } 361 Sleep(40); 362 } 363 Gotoxy(52,24); 364 setTextColor(WHITE); 365 printf("RedSnake v1.1 by_Lee"); 366 } 367 368 void GameRun() //游戏运行函数 369 { 370 while(!over) 371 { 372 Snake_Move(); //控制蛇的运动 373 Hit_Wall(); //判断是否撞墙 374 GameOver(); 375 Sleep(speed); //控制身的运动速度 376 377 } 378 } 379 380 void SurFace()//18,15 381 { 382 Menu(1); 383 int keytemp = 0; 384 while(1) 385 { 386 387 int temp1 = getch(); 388 if(temp1 != UP && temp1 != DOWN && temp1 != ENTER) 389 continue; 390 else 391 { 392 if(temp1 == UP) 393 { 394 keytemp -= 1; 395 if(keytemp < 0) 396 keytemp += 4; 397 } 398 else if(temp1 == DOWN) 399 { 400 keytemp += 1; 401 if(keytemp > 3) 402 { 403 keytemp %= 4; 404 } 405 } 406 else if(temp1 == ENTER) 407 { 408 if(keytemp == 0) 409 { 410 system("cls"); 411 break; 412 } 413 if(keytemp == 1) 414 { 415 Menu(5); 416 while(getch() == ENTER) 417 { 418 break; 419 } 420 } 421 if(keytemp == 2) 422 { 423 Menu(6); 424 while(getch() == ENTER) 425 { 426 break; 427 } 428 } 429 if(keytemp == 3) 430 exit(0); 431 } 432 switch (keytemp) 433 { 434 case 0: Menu(1); break; 435 case 1: Menu(2); break; 436 case 2: Menu(3); break; 437 case 3: Menu(4); break; 438 } 439 } 440 } 441 } 442 443 /*void Snake_Auto_Move(char temp) 444 { 445 int i; 446 Gotoxy(Snake[0].x, Snake[0].y); 447 printf("□"); 448 Gotoxy(Snake[1].x, Snake[1].y); 449 printf("■"); 450 Gotoxy(Snake[length].x, Snake[length].y); 451 printf(" "); 452 do 453 { 454 Whether_Eat(); //判断蛇是否吃到食物 455 Eat_Itself(); //判断蛇是否咬到自己 456 for(i = length; i > 0; i--) //移动蛇的坐标 457 Snake[i] = Snake[i-1]; 458 Create_Food(); 459 switch(temp) 460 { 461 case 72: Snake[0].y-=1; break; 462 case 80: Snake[0].y+=1; break; 463 case 75: Snake[0].x-=2; break; 464 case 77: Snake[0].x+=2; break; 465 } 466 }while((!kbhit() )&& (!over)); 467 } 468 */ 469 470 void GameOver() 471 { 472 if(length == 40) 473 { 474 system("cls"); 475 Gotoxy(28, 12); 476 setTextColor(WHITE); 477 PlaySound(TEXT("hali.WAV"), NULL, SND_FILENAME | SND_ASYNC ); 478 Gotoxy(38, 8); 479 printf("┏┯┯┯┯┯┯┯┯┯┯┯┓"); 480 Gotoxy(38, 9); 481 printf("┠ Congratulations. ┨"); 482 Gotoxy(38, 10); 483 printf("┠ You win. ┨"); 484 Gotoxy(38, 11); 485 printf("┠ Enter R to Return ┨"); 486 Gotoxy(38, 12); 487 printf("┗┷┷┷┷┷┷┷┷┷┷┷┛"); 488 over = 1; 489 } 490 else if(over) 491 { 492 system("cls"); 493 PlaySound(TEXT("gameover.wav"), NULL, SND_FILENAME | SND_ASYNC ); 494 setTextColor(WHITE); 495 Gotoxy(38, 8); 496 printf("┏┯┯┯┯┯┯┯┯┯┯┯┓"); 497 Gotoxy(38, 9); 498 printf("┠ Game Over. ┨"); 499 Gotoxy(38, 10); 500 printf("┠ Your score is %4d ┨", score); 501 Gotoxy(38, 11); 502 printf("┠ Enter R to try again ┨"); 503 Gotoxy(38, 12); 504 printf("┗┷┷┷┷┷┷┷┷┷┷┷┛"); 505 } 506 } 507 508 void Pause() //用于暂停的函数 509 { 510 setTextColor(WHITE); 511 Gotoxy(35,12); 512 printf(" Pause. "); 513 while(1) 514 { 515 516 int c = getch(); 517 if(c == 32) 518 { 519 Gotoxy(35,12); 520 printf(" "); 521 break; 522 } 523 } 524 } 525 526 void MyCount1() 527 { 528 setTextColor(WHITE); 529 Gotoxy(80,1); 530 printf("┏┅┅┅┅┅┅┅┅┅┅┓"); 531 Gotoxy(80,2); 532 printf("┠ ┨"); 533 Sleep(25); 534 Gotoxy(80,3); 535 printf("┠ ↑ Up ┨"); 536 Sleep(25); 537 Gotoxy(80,4); 538 printf("┠ ↓ Down ┨"); 539 Sleep(25); 540 Gotoxy(80,5); 541 printf("┠ ← Left ┨"); 542 Sleep(25); 543 Gotoxy(80,6); 544 printf("┠ → Right ┨"); 545 Sleep(25); 546 Gotoxy(80,7); 547 printf("┠ ESC Exit ┨"); 548 Sleep(25); 549 Gotoxy(80,8); 550 printf("┠ SPACE Pause ┨"); 551 Sleep(25); 552 Gotoxy(80,9); 553 printf("┠ R Restart ┨"); 554 Sleep(25); 555 Gotoxy(80,10); 556 printf("┠ ┨"); 557 Gotoxy(80,11); 558 printf("┗┅┅┅┅┅┅┅┅┅┅┛"); 559 560 561 } 562 563 void MyCount2() 564 { 565 setTextColor(WHITE); 566 Gotoxy(80,13); 567 printf("┏┅┅┅┅┅┅┅┅┅┅┓"); 568 Gotoxy(80,14); 569 printf("┠ Statistics ┨"); 570 Sleep(25); 571 Gotoxy(80,15); 572 printf("┠ length: %3d ┨",length); 573 Sleep(25); 574 Gotoxy(80,16); 575 printf("┠ Score: %4d ┨", score); 576 Sleep(25); 577 Gotoxy(80,17); 578 printf("┠ Speed: %3d ┨",speed); 579 Sleep(25); 580 Gotoxy(80,18); 581 printf("┠ Just do it. ┨"); 582 Sleep(25); 583 Gotoxy(80,19); 584 printf("┠ Author : ┨"); 585 Sleep(25); 586 Gotoxy(80,20); 587 printf("┠ China_Lee ┨"); 588 Sleep(25); 589 Gotoxy(80,21); 590 printf("┠ shijie Weng ┨"); 591 Sleep(25); 592 Gotoxy(80,22); 593 printf("┠ ┨"); 594 Gotoxy(80,23); 595 printf("┗┅┅┅┅┅┅┅┅┅┅┛"); 596 } 597 598 void Menu( int n) 599 { 600 if(n==1) 601 { 602 603 system("cls"); 604 Gotoxy(5,0); 605 printf("RedSnake!"); 606 PlaySound(TEXT("m1.wav"), NULL, SND_FILENAME | SND_ASYNC ); 607 Gotoxy(2,2); 608 setTextColor(WHITE); 609 printf("┏┯┯┯┯┯┓"); 610 Gotoxy(2,3); 611 printf("┠ 开始游戏 ┨"); 612 Gotoxy(2,4); 613 printf("┗┷┷┷┷┷┛"); 614 Gotoxy(2,5); 615 setTextColor(DARKGRAY); 616 printf("┌─————┐"); 617 Gotoxy(2,6); 618 printf("├ 帮助 ┤"); 619 Gotoxy(2,7); 620 printf("└—————┘"); 621 Gotoxy(2,8); 622 printf("┌─————┐"); 623 Gotoxy(2,9); 624 printf("├ 关于 ┤"); 625 Gotoxy(2,10); 626 printf("└—————┘"); 627 Gotoxy(2,11); 628 printf("┌─————┐"); 629 Gotoxy(2,12); 630 printf("├ 退出游戏 ┤"); 631 Gotoxy(2,13); 632 printf("└—————┘"); 633 } 634 if(n==2) 635 { 636 system("cls"); 637 PlaySound(TEXT("m1.wav"), NULL, SND_FILENAME | SND_ASYNC ); 638 Gotoxy(5,0); 639 setTextColor(DARKGRAY); 640 printf("RedSnake!"); 641 Gotoxy(2,2); 642 printf("┌─————┐"); 643 Gotoxy(2,3); 644 printf("├ 开始游戏 ┤"); 645 Gotoxy(2,4); 646 printf("└—————┘"); 647 Gotoxy(2,5); 648 setTextColor(WHITE); 649 printf("┏┯┯┯┯┯┓"); 650 Gotoxy(2,6); 651 printf("┠ 帮助 ┨"); 652 Gotoxy(2,7); 653 printf("┗┷┷┷┷┷┛"); 654 Gotoxy(2,8); 655 setTextColor(DARKGRAY); 656 printf("┌─————┐"); 657 Gotoxy(2,9); 658 printf("├ 关于 ┤"); 659 Gotoxy(2,10); 660 printf("└—————┘"); 661 Gotoxy(2,11); 662 printf("┌─————┐"); 663 Gotoxy(2,12); 664 printf("├ 退出游戏 ┤"); 665 Gotoxy(2,13); 666 printf("└—————┘"); 667 } 668 if(n==3) 669 { 670 system("cls"); 671 PlaySound(TEXT("m1.wav"), NULL, SND_FILENAME | SND_ASYNC ); 672 Gotoxy(5,0); 673 setTextColor(DARKGRAY); 674 printf("RedSnake!"); 675 Gotoxy(2,2); 676 printf("┌─————┐"); 677 Gotoxy(2,3); 678 printf("├ 开始游戏 ┤"); 679 Gotoxy(2,4); 680 printf("└—————┘"); 681 Gotoxy(2,5); 682 printf("┌─————┐"); 683 Gotoxy(2,6); 684 printf("├ 帮助 ┤"); 685 Gotoxy(2,7); 686 printf("└—————┘"); 687 Gotoxy(2,8); 688 setTextColor(WHITE); 689 printf("┏┯┯┯┯┯┓"); 690 Gotoxy(2,9); 691 printf("┠ 关于 ┨"); 692 Gotoxy(2,10); 693 printf("┗┷┷┷┷┷┛"); 694 Gotoxy(2,11); 695 setTextColor(DARKGRAY); 696 printf("┌─————┐"); 697 Gotoxy(2,12); 698 printf("├ 退出游戏 ┤"); 699 Gotoxy(2,13); 700 printf("└—————┘"); 701 } 702 if(n==4 ) 703 { 704 system("cls"); 705 PlaySound(TEXT("m1.wav"), NULL, SND_FILENAME | SND_ASYNC ); 706 setTextColor(DARKGRAY); 707 Gotoxy(5,0); 708 printf("RedSnake!"); 709 Gotoxy(2,2); 710 printf("┌─————┐"); 711 Gotoxy(2,3); 712 printf("├ 开始游戏 ┤"); 713 Gotoxy(2,4); 714 printf("└—————┘"); 715 Gotoxy(2,5); 716 printf("┌─————┐"); 717 Gotoxy(2,6); 718 printf("├ 帮助 ┤"); 719 Gotoxy(2,7); 720 printf("└—————┘"); 721 Gotoxy(2,8); 722 printf("┌─————┐"); 723 Gotoxy(2,9); 724 printf("├ 关于 ┤"); 725 Gotoxy(2,10); 726 printf("└—————┘"); 727 Gotoxy(2,11); 728 setTextColor(WHITE); 729 printf("┏┯┯┯┯┯┓"); 730 Gotoxy(2,12); 731 printf("┠ 退出游戏 ┨"); 732 Gotoxy(2,13); 733 printf("┗┷┷┷┷┷┛"); 734 } 735 if(n==5) 736 { 737 system("cls"); 738 PlaySound(TEXT("m1.wav"), NULL, SND_FILENAME | SND_ASYNC ); 739 Gotoxy(1,3); 740 printf("┏┯┯┯┯┯┯┓"); 741 Gotoxy(1,4); 742 printf("┠ Game Tips ┨"); 743 Gotoxy(1,5); 744 printf("┠ ↑ Up ┨"); 745 Gotoxy(1,6); 746 printf("┠ ↓ Down ┨"); 747 Gotoxy(1,7); 748 printf("┠ ← Left ┨"); 749 Gotoxy(1,8); 750 printf("┠ → Right ┨"); 751 Gotoxy(1,9); 752 setTextColor(WHITE); 753 printf("┠ Return ┨"); 754 Gotoxy(1,10); 755 printf("┗┷┷┷┷┷┷┛"); 756 setTextColor(DARKGRAY); 757 } 758 if(n==6) 759 { 760 system("cls"); 761 PlaySound(TEXT("m1.wav"), NULL, SND_FILENAME | SND_ASYNC ); 762 Gotoxy(1,3); 763 printf("┏┯┯┯┯┯┯┓"); 764 Gotoxy(1,4); 765 printf("┠ RedSnake ┨"); 766 Gotoxy(1,5); 767 printf("┠ By Lee. ┨"); 768 Gotoxy(1,6); 769 printf("┠ 版权所有 ┨"); 770 Gotoxy(1,7); 771 printf("┠ 盗版必究 ┨"); 772 Gotoxy(1,8); 773 printf("┠ 版本: ┨"); 774 Gotoxy(1,9); 775 setTextColor(WHITE); 776 printf("┠ 1.1V ┨"); 777 Gotoxy(1,10); 778 printf("┗┷┷┷┷┷┷┛"); 779 setTextColor(DARKGRAY); 780 } 781 } 782 783 void Inti_Data() 784 { 785 over = 0; //初始化over 786 length = 3; //初始化长度 787 speed = 130; //初始化速度 788 score = 0; //初始化分数 789 memset( Map , 0 ,sizeof(Map)); //初始化地图食物 790 }