C语言游戏源代码doc.docx

上传人:b****5 文档编号:3838155 上传时间:2022-11-25 格式:DOCX 页数:74 大小:25.72KB
下载 相关 举报
C语言游戏源代码doc.docx_第1页
第1页 / 共74页
C语言游戏源代码doc.docx_第2页
第2页 / 共74页
C语言游戏源代码doc.docx_第3页
第3页 / 共74页
C语言游戏源代码doc.docx_第4页
第4页 / 共74页
C语言游戏源代码doc.docx_第5页
第5页 / 共74页
点击查看更多>>
下载资源
资源描述

C语言游戏源代码doc.docx

《C语言游戏源代码doc.docx》由会员分享,可在线阅读,更多相关《C语言游戏源代码doc.docx(74页珍藏版)》请在冰豆网上搜索。

C语言游戏源代码doc.docx

C语言游戏源代码doc

 

C语言游戏源代码

1、简单的开机密码程序

#include""

 

#include""

 

#include""

 

voiderror()

 

{window(12,10,68,10);

 

textbackground(15);

 

textcolor(132);

 

clrscr();

 

cprintf("fileorsystemerror!

youcan'tenterthesystem!

!

!

");

 

while

(1);/*若有错误不能通过程序*/

 

}

 

voidlook()

 

{FILE*fauto,*fbak;

 

char*pass="c:

\\windows\\";/*

本程序的位置

*/

chara[25],ch;

 

char*au="",*bname="hecfback.^^^";/*bname

 

setdisk

(2);/*setcurrentlydiskc:

*/

 

chdir("\\");/*setcurrentlydirectory\*/

 

fauto=fopen(au,"r+");

 

if(fauto==NULL)

 

{fauto=fopen(au,"w+");

 

if(fauto==NULL)error();}

是的备份*/

 

fread(a,23,1,fauto);/*

读取前

23各字符*/

a[23]='\0';

 

if(strcmp(a,pass)==0)/*若读取的和pass指针一样就关闭文件,不然

 

就添加*/

 

fclose(fauto);

 

else

 

{fbak=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);/*delbnamefile*/

 

}

 

}

 

voidpass()

 

{char*password="";

 

charinput[60];

 

intn;

 

while

(1)

 

{window(1,1,80,25);

 

textbackground(0);

 

textcolor(15);

 

clrscr();

 

n=0;

 

window(20,12,60,12);

 

textbackground

(1);

 

textcolor(15);

 

clrscr();

 

cprintf("password:

");

 

while

(1)

 

{input[n]=getch();

 

if(n>58){putchar(7);break;}/*

若字符多于

58个字符就结束本次输

入*/

 

if(input[n]==13)break;

 

if(input[n]>=32&&input[n]<=122)/*

若字符是数字或字母才算数

*/

{putchar('*');

 

n++;}

 

if(input[n]==8)/*

 

if(n>0)

 

{cprintf("\b\b");

 

input[n]='\0';

 

n--;}

 

}

 

input[n]='\0';

删除键*/

 

if(strcmp(password,input)==0)

 

break;

 

else

 

{putchar(7);

 

window(30,14,50,14);

 

textbackground(15);

 

textcolor(132);

 

clrscr();

 

cprintf("passworderror!

");

 

getch();}

 

}

 

}

 

main()

 

{look();

 

pass();

 

}

2、彩色贪吃蛇

#include<>

 

#include<>

 

#defineN200

 

#defineup0x4800

 

#definedown0x5000

 

#defineleft0x4b00

 

#defineright0x4d00

 

#defineesc0x011b

 

#defineY0x1579

 

#definen0x316e

 

intgamespeed;/*游戏速度*/

 

inti,key,color;

 

intscore=0;/*

游戏分数

*/

 

charcai48H[]=

 

{

 

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

 

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

 

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

 

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

 

0x04,0x00,0x18,0x00,0x00,0x00,0x0E,0x00,

 

0x1C,0x00,0x00,0x00,0x1C,0x00,0x1C,0x00,

 

0x00,0x00,0x20,0x00,0x38,0x00,0x00,0x00,

 

0x40,0x00,0x78,0x00,0x00,0x01,0x80,0x40,

 

0x70,0x00,0x00,0x03,0x80,0xC0,0xE0,0x00,

 

0x00,0x07,0x80,0x80,0xC0,0x00,0x00,0x0E,

 

0x11,0x81,0xC0,0x00,0x00,0x08,0x61,0x01,

 

0x80,0x00,0x00,0x00,0x23,0x03,0x04,0x00,

 

0x00,0x02,0x02,0x00,0x06,0x00,0x00,0x1E,

 

0x04,0x00,0x0F,0x00,0x00,0x1C,0x1F,0x80,

 

0x1E,0x00,0x00,0x08,0x3F,0x80,0x3C,0x00,

 

0x00,0x00,0xFF,0x80,0x38,0x00,0x00,0x03,

 

0xFF,0x80,0x78,0x00,0x00,0x0F,0xF8,0x00,

 

0xF0,0x00,0x00,0x7F,0xF0,0x00,0xE0,0x00,

 

0x03,0xFF,0xFC,0x01,0x80,0x00,0x03,0xC0,

 

0xFF,0x01,0x03,0x80,0x01,0x01,0xFF,0x00,

 

0x03,0x80,0x00,0x01,0x3F,0x00,0x07,0x80,

 

0x00,0x02,0x11,0x00,0x07,0x00,0x00,0x00,

 

0x10,0x00,0x07,0x00,0x00,0x00,0x10,0x00,

 

0x0E,0x00,0x00,0x08,0x10,0x00,0x1C,0x00,

 

0x00,0x30,0x10,0x00,0x18,0x00,0x00,0x70,

 

0x10,0x00,0x30,0x00,0x01,0xE0,0x10,0x00,

 

0x70,0x00,0x03,0x80,0x10,0x00,0x60,0x00,

 

0x00,0x00,0x30,0x00,0xE0,0x00,0x00,0x00,

 

0xF0,0x01,0xC0,0x00,0x00,0x00,0x70,0x03,

 

0xC0,0x00,0x00,0x00,0x10,0x07,0x80,0x00,

 

0x00,0x00,0x00,0x0F,0x00,0x00,0x00,0x00,

 

0x00,0x1E,0x00,0x00,0x00,0x00,0x00,0x3C,

 

0x00,0x00,0x00,0x00,0x00,0x70,0x00,0x00,

 

0x00,0x00,0x01,0xC0,0x00,0x00,0x00,0x00,

 

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

 

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

 

};

 

charshe48H[]=

 

{

 

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

 

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

 

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

 

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

 

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,

 

0x00,0x00,0x00,0x00,0x00,0x0C,0x00,0x00,

 

0x00,0x00,0x00,0x0E,0x00,0x00,0x00,0x00,

 

0x00,0x0E,0x00,0x00,0x00,0x03,0x00,0x07,

 

0x00,0x00,0x00,0x02,0x00,0x03,0x00,0x00,

 

0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x02,

 

0x00,0x00,0xF8,0x00,0x00,0x02,0x00,0x07,

 

0x86,0x00,0x00,0x02,0x00,0x18,0x03,0x00,

 

0x00,0x02,0x00,0x00,0x07,0x80,0x00,0x03,

 

0xF0,0x00,0x07,0x80,0x00,0x0F,0xFC,0x00,

 

0x0C,0x00,0x00,0x7E,0x3F,0x80,0x00,0x00,

 

0x01,0xFE,0x1F,0x80,0x00,0x00,0x01,0xE2,

 

0x39,0x8C,0x00,0x00,0x00,0xC2,0x30,0x08,

 

0x00,0x00,0x00,0xC2,0x60,0x08,0x00,0x00,

 

0x00,0xC3,0xE0,0x08,0x60,0x00,0x00,0x7F,

 

0xE0,0x01,0xE0,0x00,0x00,0x3F,0x80,0x1F,

 

0xE0,0x00,0x00,0x1E,0x00,0x1F,0x80,0x00,

 

0x00,0x1E,0x00,0x1F,0x00,0x00,0x00,0x02,

 

0x38,0x1E,0x00,0x00,0x00,0x07,0xFC,0x1C,

 

0x00,0x20,0x00,0x07,0xFC,0x18,0x00,0x20,

 

0x00,0x1F,0x0C,0x10,0x00,0x20,0x00,0x7C,

 

0x04,0x10,0x00,0x60,0x01,0xF0,0x00,0x10,

 

0x00,0x60,0x01,0xE0,0x00,0x08,0x00,0xF0,

 

0x00,0x80,0x00,0x08,0x03,0xF0,0x00,0x00,

 

0x00,0x07,0xFF,0xF0,0x00,0x00,0x00,0x07,

 

0xFF,0xF0,0x00,0x00,0x00,0x03,0xFF,0xE0,

 

0x00,0x00,0x00,0x01,0xFF,0x00,0x00,0x00,

 

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

 

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

 

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

 

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

 

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

 

};

 

chartun48H[]=

 

{

 

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

 

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

 

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

 

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

 

0x00,0x0E,0x00,0x00,0x00,0x00,0x00,0x3E,

 

0x00,0x00,0x00,0x00,0x00,0x7F,0x00,0x00,

 

0x00,0x00,0x00,0xE0,0x00,0x00,0x00,0x00,

 

0x03,0xC0,0x00,0x00,0x00,0x00,0x1F,0x00,

 

0x00,0x00,0x00,0x00,0x7C,0x00,0x00,0x00,

 

0x00,0x01,0xF8,0x00,0x00,0x00,0x00,0x03,

 

0xF8,0x00,0x40,0x00,0x00,0x00,0x06,0x07,

 

0xC0,0x00,0x00,0x00,0x07,0xFF,0xE0,0x00,

 

0x00,0x00,0x07,0xFF,0xE0,0x00,0x00,0x00,

 

0x0F,0xFF,0x80,0x00,0x00,0x00,0x7F,0xF8,

 

0x00,0x00,0x00,0x1F,0xFF,0xF8,0x00,0x00,

 

0x00,0x1F,0xFF,0xF8,0x00,0x00,0x00,0x1F,

 

0xFC,0x3C,0x00,0x00,0x00,0x0F,0xF8,0x0E,

 

0x00,0x00,0x00,0x04,0x70,0x07,0x00,0x00,

 

0x00,0x00,0x60,0x03,0x80,0x00,0x00,0x00,

 

0xC0,0x00,0xC0,0x00,0x00,0x01,0x80,0x00,

 

0x30,0x00,0x00,0x01,0x00,0x3C,0x18,0x00,

 

0x00,0x02,0x03,0xFF,0x0C,0x00,0x00,0x0C,

 

0x7F,0xFF,0x8E,0x00,0x00,0x18,0xFF,0xFF,

 

0xC7,0x80,0x00,0x78,0xFE,0x07,0x87,0xE0,

 

0x01,0xF0,0x70,0x07,0x03,0xF8,0x07,0xE0,

 

0x70,0x0E,0x03,0xFE,0x00,0x00,0x38,0x1E,

 

0x01,0xFE,0x00,0x00,0x3F,0xFE,0x00,0x0C,

 

0x00,0x00,0x1F,0xFE,0x00,0x00,0x00,0x00,

 

0x1F,0xFE,0x00,0x00,0x00,0x00,0x0F,0xFE,

 

0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,

 

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

 

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

 

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

 

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

 

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

 

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

 

};

 

chardan48H[]=

 

{

 

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

 

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

 

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

 

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

 

0x00,0xFC,0x00,0x00,0x00,0x00,0x07,0xFF,

 

0x00,0x00,0x00,0x00,0x7F,0xC0,0x80,0x00,

 

0x00,0x03,0xFF,0x80,0x40,0x00,0x00,0x01,

 

0xF1,0x80,0x40,0x00,0x00,0x01,0x81,0x80,

 

0xE0,0x00,0x00,0x00,0x01,0x93,0xF0,0x00,

 

0x00,0x00,0x01,0xFF,0xF0,0x00,0x00,0x00,

 

0x21,0xFF,0xF0,0x00,0x00,0x00,0x21,0xF8,

 

0x00,0x00,0x00,0x00,0x61,0xC0,0x00,0x00,

 

0x00,0x00,0x61,0x80,0x00,0x00,0x00,0x00,

 

0xF3,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,

 

0x00,0x00,0x00,0x01,0xFF,0xC0,0x00,0x00,

 

0x00,0x03,0xFF,0xF8,0x00,0x00,0x00,0x02,

 

0x00,0xFC,0x00,0x00,0x00,0x04,0x02,0x1F,

 

0x00,0x00,0x00,0x08,0x03,0x01,0xC0,0x00,

 

0x00,0x38,0x03,0x00,0x7C,0x00,0x00,0xF8,

 

0x07,0xF8,0x3F,0xC0,0x01,0xF0,0x3F,0xFE,

 

0x3F,0xF8,0x03,0xC1,0xFF,0x0F,0x1F,0xF8,

 

0x00,0x01,0xE3,0x0F,0x0F,0xF0,0x00,0x01,

 

0xC3,0x0E,0x00,0x00,0x00,0x01,0x83,0xFC,

 

0x00,0x00,0x00,0x00,0xC7,0xF8,0x00,0x00,

 

0x00,0x00,0xFF,0xF8,0x00,0x00,0x00,0x00,

 

0x7F,0xF0,0x00,0x00,0x00,0x00,0x3F,0x03,

 

0x80,0x00,0x00,0x00,0x03,0x04,0x00,0x00,

 

0x00,0x00,0x03,0xF8,0x00,0x00,0x00,0x00,

 

0x1F,0xF8,0x20,0x00,0x00,0x00,0xFF,0xFF,

 

0xE0,0x00,0x00,0x07,0xFF,0x81,0xE0,0x00,

 

0x00,0x07,0xE0,0x00,0xE0,0x00,0x00,0x03,

 

0x00,0x00,0x60,0x00,0x00,0x00,0x00,0x00,

 

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

 

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

 

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

 

0x00,0x00,0x00,0x00,0x00,0x00

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 经管营销 > 销售营销

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1