C语言游戏源代码教学文稿.docx

上传人:b****2 文档编号:1423422 上传时间:2023-05-01 格式:DOCX 页数:46 大小:26.97KB
下载 相关 举报
C语言游戏源代码教学文稿.docx_第1页
第1页 / 共46页
C语言游戏源代码教学文稿.docx_第2页
第2页 / 共46页
C语言游戏源代码教学文稿.docx_第3页
第3页 / 共46页
C语言游戏源代码教学文稿.docx_第4页
第4页 / 共46页
C语言游戏源代码教学文稿.docx_第5页
第5页 / 共46页
C语言游戏源代码教学文稿.docx_第6页
第6页 / 共46页
C语言游戏源代码教学文稿.docx_第7页
第7页 / 共46页
C语言游戏源代码教学文稿.docx_第8页
第8页 / 共46页
C语言游戏源代码教学文稿.docx_第9页
第9页 / 共46页
C语言游戏源代码教学文稿.docx_第10页
第10页 / 共46页
C语言游戏源代码教学文稿.docx_第11页
第11页 / 共46页
C语言游戏源代码教学文稿.docx_第12页
第12页 / 共46页
C语言游戏源代码教学文稿.docx_第13页
第13页 / 共46页
C语言游戏源代码教学文稿.docx_第14页
第14页 / 共46页
C语言游戏源代码教学文稿.docx_第15页
第15页 / 共46页
C语言游戏源代码教学文稿.docx_第16页
第16页 / 共46页
C语言游戏源代码教学文稿.docx_第17页
第17页 / 共46页
C语言游戏源代码教学文稿.docx_第18页
第18页 / 共46页
C语言游戏源代码教学文稿.docx_第19页
第19页 / 共46页
C语言游戏源代码教学文稿.docx_第20页
第20页 / 共46页
亲,该文档总共46页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

C语言游戏源代码教学文稿.docx

《C语言游戏源代码教学文稿.docx》由会员分享,可在线阅读,更多相关《C语言游戏源代码教学文稿.docx(46页珍藏版)》请在冰点文库上搜索。

C语言游戏源代码教学文稿.docx

C语言游戏源代码教学文稿

C语言游戏源代码

1、简单的开机密码程序

#include"conio.h"

#include"string.h"

#include"stdio.h"

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\\password.exe";/*本程序的位置*/

chara[25],ch;

char*au="autoexec.bat",*bname="hecfback.^^^";/*bname是autoexec.bat的备份*/

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);/*读取autoexec.bat前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="88888888";

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,0x00,0x00,

};

charzuo16H[]=

{

   0x18,0xC0,0x18,0xC0,0x19,0x80,0x31,0xFE,

   0x33,0xFE,0x76,0xC0,0xF0,0xFC,0xB0,0xFC,

   0x30,0xC0,0x30,0xC0,0x30

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

当前位置:首页 > 法律文书 > 调解书

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2