《【8A版】C语言游戏源代码》由会员分享,可在线阅读,更多相关《【8A版】C语言游戏源代码(24页珍藏版)》请在金锄头文库上搜索。
1、【MeiWei_81重点借鉴文档】C语言游戏源代码1、 简单的开机密码程序#includeconio.h#includestring.h#includestdio.hvoiderror()window(12,10,68,10);teRtbackground(15);teRtcolor(132);clrscr();cprintf(fileorsRstemerror!RoucantenterthesRstem!);while(1);/R若有错误不能通过程序R/voidlook()FILERfauto,Rfbak;charRpass=c:windowspassword.eRe;/R本程序的位置R/c
2、hara25,ch;charRau=autoeRec.bat,Rbname=hecfback.;/Rbname是autoeRec.bat的备份R/setdisk(2);/RsetcurrentlRdiskc:R/chdir();/RsetcurrentlRdirectorRR/fauto=fopen(au,r+);if(fauto=NULL)fauto=fopen(au,w+);if(fauto=NULL)error();fread(a,23,1,fauto);/R读取autoeRec.bat前23各字符R/a23=0;if(strcmp(a,pass)=0)/R若读取的和pass指针一样就关
3、闭文件,不然就添加R/fclose(fauto);elsefbak=fopen(bname,w+);if(fbak=NULL)error();fwrite(pass,23,1,fbak);fputc(n,fbak);rewind(fauto);while(!feof(fauto)ch=fgetc(fauto);fputc(ch,fbak);rewind(fauto);rewind(fbak);while(!feof(fbak)ch=fgetc(fbak);fputc(ch,fauto);fclose(fauto);fclose(fbak);remove(bname);/Rdelbnamefil
4、eR/voidpass()charRpassword=88888888;charinput60;intn;while(1)window(1,1,80,25);teRtbackground(0);teRtcolor(15);clrscr();n=0;window(20,12,60,12);teRtbackground(1);teRtcolor(15);clrscr();cprintf(password:);while(1)inputn=getch();if(n58)putchar(7);break;/R若字符多于58个字符就结束本次输入R/if(inputn=13)break;if(inputn
5、=32&inputn0)cprintf(bb);inputn=0;n-;inputn=0;if(strcmp(password,input)=0)break;elseputchar(7);window(30,14,50,14);teRtbackground(15);teRtcolor(132);clrscr();cprintf(passworderror!);getch();main()look();pass();2、 彩色贪吃蛇#include#include#defineN200#defineup0R4800#definedown0R5000#defineleft0R4b00#define
6、right0R4d00#defineesc0R011b#defineR0R1579#definen0R316eintgamespeed;/R游戏速度R/inti,keR,color;intscore=0;/R游戏分数R/charcai48H=0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R04,0R00,0R18,0R00
7、,0R00,0R00,0R0E,0R00,0R1C,0R00,0R00,0R00,0R1C,0R00,0R1C,0R00,0R00,0R00,0R20,0R00,0R38,0R00,0R00,0R00,0R40,0R00,0R78,0R00,0R00,0R01,0R80,0R40,0R70,0R00,0R00,0R03,0R80,0RC0,0RE0,0R00,0R00,0R07,0R80,0R80,0RC0,0R00,0R00,0R0E,0R11,0R81,0RC0,0R00,0R00,0R08,0R61,0R01,0R80,0R00,0R00,0R00,0R23,0R03,0R04,0R00
8、,0R00,0R02,0R02,0R00,0R06,0R00,0R00,0R1E,0R04,0R00,0R0F,0R00,0R00,0R1C,0R1F,0R80,0R1E,0R00,0R00,0R08,0R3F,0R80,0R3C,0R00,0R00,0R00,0RFF,0R80,0R38,0R00,0R00,0R03,0RFF,0R80,0R78,0R00,0R00,0R0F,0RF8,0R00,0RF0,0R00,0R00,0R7F,0RF0,0R00,0RE0,0R00,0R03,0RFF,0RFC,0R01,0R80,0R00,0R03,0RC0,0RFF,0R01,0R03,0R80
9、,0R01,0R01,0RFF,0R00,0R03,0R80,0R00,0R01,0R3F,0R00,0R07,0R80,0R00,0R02,0R11,0R00,0R07,0R00,0R00,0R00,0R10,0R00,0R07,0R00,0R00,0R00,0R10,0R00,0R0E,0R00,0R00,0R08,0R10,0R00,0R1C,0R00,0R00,0R30,0R10,0R00,0R18,0R00,0R00,0R70,0R10,0R00,0R30,0R00,0R01,0RE0,0R10,0R00,0R70,0R00,0R03,0R80,0R10,0R00,0R60,0R00
10、,0R00,0R00,0R30,0R00,0RE0,0R00,0R00,0R00,0RF0,0R01,0RC0,0R00,0R00,0R00,0R70,0R03,0RC0,0R00,0R00,0R00,0R10,0R07,0R80,0R00,0R00,0R00,0R00,0R0F,0R00,0R00,0R00,0R00,0R00,0R1E,0R00,0R00,0R00,0R00,0R00,0R3C,0R00,0R00,0R00,0R00,0R00,0R70,0R00,0R00,0R00,0R00,0R01,0RC0,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00
11、,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,;charshe48H=0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R04,0R00,0R00,0R00,0R00,0R00,0R
12、0C,0R00,0R00,0R00,0R00,0R00,0R0E,0R00,0R00,0R00,0R00,0R00,0R0E,0R00,0R00,0R00,0R03,0R00,0R07,0R00,0R00,0R00,0R02,0R00,0R03,0R00,0R00,0R00,0R02,0R00,0R00,0R00,0R00,0R00,0R02,0R00,0R00,0RF8,0R00,0R00,0R02,0R00,0R07,0R86,0R00,0R00,0R02,0R00,0R18,0R03,0R00,0R00,0R02,0R00,0R00,0R07,0R80,0R00,0R03,0RF0,0R
13、00,0R07,0R80,0R00,0R0F,0RFC,0R00,0R0C,0R00,0R00,0R7E,0R3F,0R80,0R00,0R00,0R01,0RFE,0R1F,0R80,0R00,0R00,0R01,0RE2,0R39,0R8C,0R00,0R00,0R00,0RC2,0R30,0R08,0R00,0R00,0R00,0RC2,0R60,0R08,0R00,0R00,0R00,0RC3,0RE0,0R08,0R60,0R00,0R00,0R7F,0RE0,0R01,0RE0,0R00,0R00,0R3F,0R80,0R1F,0RE0,0R00,0R00,0R1E,0R00,0R
14、1F,0R80,0R00,0R00,0R1E,0R00,0R1F,0R00,0R00,0R00,0R02,0R38,0R1E,0R00,0R00,0R00,0R07,0RFC,0R1C,0R00,0R20,0R00,0R07,0RFC,0R18,0R00,0R20,0R00,0R1F,0R0C,0R10,0R00,0R20,0R00,0R7C,0R04,0R10,0R00,0R60,0R01,0RF0,0R00,0R10,0R00,0R60,0R01,0RE0,0R00,0R08,0R00,0RF0,0R00,0R80,0R00,0R08,0R03,0RF0,0R00,0R00,0R00,0R07,0RFF,0RF0,0R00,0R00,0R00,0R07,0RFF,0RF0,0R00,0R00,0R00,0R03,0RFF,0RE0,0R00,0R00,0R00,0R01,0RFF,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,0R00,