C语言的“推箱子”源代码-完整版
这个是完整版,记得是在寒假完毕的时候,来到学校才完善的,那时,看着自己的第一个作品,很高兴。我用C语言开发的“推箱子”源代码【完整版】。这些都是在dev-c/c++环境中编写的比较多。其中涉及到的技术含量可能很少,但是之前我都没有很认真听课,也没有带书之类的参考资料会去过寒假,也没有在之前学过编程语言,所以说,兴趣是最好的老师。
以下是C语言开发的“推箱子”源代码【完整版】的全部代码:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include <time.h>
/*==========================Program_Interface*/
int Program_Interface();
/*==========================Read From Cache*/
int ReadFromCache();
void DealWithData_Read();
int ChangeCTI_Score();
int TestIf_DataFile_Right();
// TestIf_DataFile_Right
void AboutMe();
/*================================General */
int Menu_General();
int GameStart();
int Input();
int RegisterUser();
/*================================V I P */
int Menu_VIP();
void ShowTheVIPInfomations();
int Login();
/*================================Game info*/
int DealWhitData();
void DealWhitData_YiDong();
int DealWithData_Win();
void DealWhitData_ZhiGuan();
int Output();
void Output_PrintBox();
/*================================Game info*/
void Help();
int Save();
void DealWithData_Write();
int ChangeITC_Score();
int WriteToFile();
/*====================================Quan Jun Bian Liang=====================*/
int WP[8][9]= {
0,2,2,2,2,0,0,0,0,
0,2,9,0,2,2,2,0,0,
0,2,0,1,0,0,2,0,0,
2,2,2,0,2,0,2,2,0,
2,8,2,0,2,0,0,2,0,
2,8,1,0,0,2,0,2,0,
2,8,0,0,0,1,0,2,0,
2,2,2,2,2,2,2,2,0
}
;
int ZG[24][70];
char SR[22];
int p,q;
char VIPNum[5]= {
'0','1','0','1','0'
}
;
char BeiMa[5]= {
'1','4','7','7','9'
}
;
char Name[15];
char Password[18];
char Char_Score[6];
char HouMen[4]= {
'0','l','q','c'
}
;
int Score=999999;
int Length_name;
int Length_passwd;
int WinNumber;
int IFRFF;
int IFLogin;
char EB0Read[323];
char EB0Write[323];
time_t rawtime;
struct tm *timeinfo;
/*====================================Quan Jun Bian Liang=====================*/
int main() {
int choice=0;
IFLogin=0;
p=1;
q=2;
Length_name=14;
Length_passwd=17;
time(&rawtime);
timeinfo=localtime(&rawtime);
ZG[4][53]=80;
//VIP number plas 1 5+1=6 Wei(No Define)
ZG[16][56]=83;
// *5 CHANGE TONG YONG
IFRFF=ReadFromCache();
if(IFRFF==4) {
system("cls");
printf("\n\n\n\n");
printf(" 你的数据文件Game_Data.txt错误 !!!\n\n");
printf(" 请删除此目录下的Game_Data.txt\n");
printf(" 然后重试...\n\n");
printf(" ****BYE-BYE****\n\n\n");
system("pause");
return 0;
}
while(1) {
choice=Program_Interface(IFRFF);
if(choice==-88)
break;
if(IFRFF==-1) //No Data In The Cache.... so Do General {
choice=Menu_General();
}
if(choice==81)
choice=Menu_General();
}
system("cls");
printf("\n\n\n");
printf(" <<<<<<<<<<<<<<<<<<<<<<<< ======== >>>>>>>>>>>>>>>>>>>>>>>>>>>> \n\n");
printf(" <<<<<<<<<<<<<<<<<<<<<<<< GOOD-BYE >>>>>>>>>>>>>>>>>>>>>>>>>>>> \n\n");
printf(" <<<<<<<<<<<<<<<<<<<<<<<< ======== >>>>>>>>>>>>>>>>>>>>>>>>>>>> \n\n");
printf(" <<<<<<<<<<<<<<<<<<<<<<<< GOOD-BYE >>>>>>>>>>>>>>>>>>>>>>>>>>>> \n\n");
system("pause");
return 0;
}
int Program_Interface(int IFRFF) {
int ch=0;
int li;
if(IFRFF==-1) {
system("cls");
printf("\n\n");
printf(" **************************************\n\n");
printf(" 你不是一个VIP用户... !!\n\n\n");
printf(" 你可以输入相应的选择(1/2/3/4/0)进行浏览帮助、注册、或者直接开始游戏... \n\n");
printf(" 建议您帮助... !!\n");
printf(" **************************************\n\n\n\n\n");
} else {
if(IFLogin==0)
li=Login();
// IFLogin 0/1 else if(IFLogin==1)
ch=Menu_VIP();
if(ch==-88)
return -88;
if(li==81)
return 81;
}
system("pause");
return 0;
}
int Menu_General() {
int choice;
int ch;
system("cls");
printf(">>>>>>>>>>>>\n Tourist:\n \n");
printf(" **************welocome To Boxing Game******************\n");
printf(" * xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx *\n");
printf(" * xxxxxxxx *\n");
printf(" * 1.开始游戏; *\n");
printf(" * 2.注册一个新用户; *\n");
printf(" * 3.帮助。 *\n");
printf(" * 4.编者的话 ; *\n");
printf(" * *\n");
printf(" * 0.退出 . *\n");
printf(" *******************************************************\n");
printf(" 输入(1/2/3/4/0):");
scanf("%d",&choice);
getchar();
//do {
switch(choice) {
case 1:
GameStart();
break;
case 2: {
ch=RegisterUser();
if(ch!=-2 && ch!=0)
Menu_General();
break;
}
case 3:
Help();
break;
case 4:
AboutMe();
break;
case 0:
return -88;
default:
break;
}
}
//while(choice==0);
//system("pause");
return 1;
// Right......
}
int Menu_VIP() {
int choice;
system("cls");
printf(" **************welocome To Boxing Game******************\n");
printf(" * xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx *\n");
printf(" * xxxxxxxx VIP centre xxxxxxxx *\n");
printf(" * xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx *\n");
printf(" * 1. 开始游戏. *\n");
printf(" * 2. 帮助. *\n");
printf(" * 3. 显示VIP信息. *\n");
printf(" * 4. 编者的话 ; *\n");
printf(" * *\n");
printf(" * 0. 退出游戏. *\n");
printf(" *******************************************************\n");
printf("You Choice(1/2/3/4/0):");
scanf("%d",&choice);
getchar();
switch(choice) {
case 1:
GameStart();
break;
case 2:
Help();
break;
case 3:
ShowTheVIPInfomations();
break;
case 4:
AboutMe();
break;
case 0:
return -88;
default: {
if(choice==88 || choice==8)
return 59;
}
break;
}
return 0;
}
int ReadFromCache() {
int h;
FILE *fpread;
system("cls");
fpread=fopen("Game_Data.txt","rb");
if(fpread==NULL) {
printf("\nInformations:\n************************************\n");
printf("\nCan't Open User Data File !! \n");
printf("你不是一个VIP用户,没你的注册信息!!\n\n");
printf("You Are Not a RAIN User !!\n\n");
IFRFF=-1;
system("pause");
return -1;
}
for (h=0;h<323;h++) {
if(fread(&EB0Read[h],1,1,fpread)!=1) {
printf("Can't Read From this file !!\n");
return -5;
}
}
fclose(fpread);
printf("\nfile 'Game_Data' info :\n\n");
for (h=0;h<323;h++)
printf("%c",EB0Read[h]);
printf("\n\n\n");
system("pause");
DealWithData_Read();
if(TestIf_DataFile_Right()==4)
return 4;
return 0;
}
void DealWithData_Read() {
int h;
int i;
int h_ot=0;
char OutTo[53];
for (h=0;h<323;) {
if(h==0)h+=2; else if(h==296) h+=3;
// 'a'~'g'... else {
if(EB0Read[h+0]=='1'&&EB0Read[h+1]=='0'&&EB0Read[h+2]=='1'&&EB0Read[h+3]=='1'&&EB0Read[h+4]=='0'&&EB0Read[h+5]=='1') {
OutTo[h_ot]='a';
h_ot++;
}
// ..... else if(EB0Read[h+0]=='1'&&EB0Read[h+1]=='0'&&EB0Read[h+2]=='1'&&EB0Read[h+3]=='1'&&EB0Read[h+4]=='0'&&EB0Read[h+5]=='0') {
OutTo[h_ot]='b';
h_ot++;
}
// ..... else if(EB0Read[h+0]=='1'&&EB0Read[h+1]=='0'&&EB0Read[h+2]=='1'&&EB0Read[h+3]=='0'&&EB0Read[h+4]=='1'&&EB0Read[h+5]=='1') {
OutTo[h_ot]='c';
h_ot++;
}
// ..... else if(EB0Read[h+0]=='1'&&EB0Read[h+1]=='0'&&EB0Read[h+2]=='1'&&EB0Read[h+3]=='0'&&EB0Read[h+4]=='1'&&EB0Read[h+5]=='0') {
OutTo[h_ot]='d';
h_ot++;
}
// ..... else if(EB0Read[h+0]=='1'&&EB0Read[h+1]=='0'&&EB0Read[h+2]=='1'&&EB0Read[h+3]=='0'&&EB0Read[h+4]=='0'&&EB0Read[h+5]=='1') {
OutTo[h_ot]='e';
h_ot++;
}
// ..... else if(EB0Read[h+0]=='1'&&EB0Read[h+1]=='0'&&EB0Read[h+2]=='1'&&EB0Read[h+3]=='0'&&EB0Read[h+4]=='0'&&EB0Read[h+5]=='0') {
OutTo[h_ot]='f';
h_ot++;
}
// ..... else if(EB0Read[h+0]=='1'&&EB0Read[h+1]=='0'&&EB0Read[h+2]=='0'&&EB0Read[h+3]=='1'&&EB0Read[h+4]=='1'&&EB0Read[h+5]=='1') {
OutTo[h_ot]='g';
h_ot++;
}
// .....
// 'h'~'n'.... else if(EB0Read[h+0]=='1'&&EB0Read[h+1]=='0'&&EB0Read[h+2]=='0'&&EB0Read[h+3]=='1'&&EB0Read[h+4]=='1'&&EB0Read[h+5]=='0') {
OutTo[h_ot]='h';
h_ot++;
}
// ..... else if(EB0Read[h+0]=='1'&&EB0Read[h+1]=='0'&&EB0Read[h+2]=='0'&&EB0Read[h+3]=='1'&&EB0Read[h+4]=='0'&&EB0Read[h+5]=='1') {
OutTo[h_ot]='i';
h_ot++;
}
// ..... else if(EB0Read[h+0]=='1'&&EB0Read[h+1]=='0'&&EB0Read[h+2]=='0'&&EB0Read[h+3]=='1'&&EB0Read[h+4]=='0'&&EB0Read[h+5]=='0') {
OutTo[h_ot]='j';
h_ot++;
}
// ..... else if(EB0Read[h+0]=='1'&&EB0Read[h+1]=='0'&&EB0Read[h+2]=='0'&&EB0Read[h+3]=='0'&&EB0Read[h+4]=='1'&&EB0Read[h+5]=='1') {
OutTo[h_ot]='k';
h_ot++;
}
// ..... else if(EB0Read[h+0]=='1'&&EB0Read[h+1]=='0'&&EB0Read[h+2]=='0'&&EB0Read[h+3]=='0'&&EB0Read[h+4]=='1'&&EB0Read[h+5]=='0') {
OutTo[h_ot]='l';
h_ot++;
}
// ..... else if(EB0Read[h+0]=='1'&&EB0Read[h+1]=='0'&&EB0Read[h+2]=='0'&&EB0Read[h+3]=='0'&&EB0Read[h+4]=='0'&&EB0Read[h+5]=='1') {
OutTo[h_ot]='m';
h_ot++;
}
// ..... else if(EB0Read[h+0]=='1'&&EB0Read[h+1]=='0'&&EB0Read[h+2]=='0'&&EB0Read[h+3]=='0'&&EB0Read[h+4]=='0'&&EB0Read[h+5]=='0') {
OutTo[h_ot]='n';
h_ot++;
}
// .....
// 'o'~'t'.... else if(EB0Read[h+0]=='1'&&EB0Read[h+1]=='1'&&EB0Read[h+2]=='0'&&EB0Read[h+3]=='0'&&EB0Read[h+4]=='1'&&EB0Read[h+5]=='1') {
OutTo[h_ot]='o';
h_ot++;
}
// ..... else if(EB0Read[h+0]=='1'&&EB0Read[h+1]=='1'&&EB0Read[h+2]=='0'&&EB0Read[h+3]=='0'&&EB0Read[h+4]=='1'&&EB0Read[h+5]=='0') {
OutTo[h_ot]='p';
h_ot++;
}
// ..... else if(EB0Read[h+0]=='1'&&EB0Read[h+1]=='1'&&EB0Read[h+2]=='0'&&EB0Read[h+3]=='0'&&EB0Read[h+4]=='0'&&EB0Read[h+5]=='1') {
OutTo[h_ot]='q';
h_ot++;
}
// ..... else if(EB0Read[h+0]=='1'&&EB0Read[h+1]=='1'&&EB0Read[h+2]=='0'&&EB0Read[h+3]=='0'&&EB0Read[h+4]=='0'&&EB0Read[h+5]=='0') {
OutTo[h_ot]='r';
h_ot++;
}
// ..... else if(EB0Read[h+0]=='1'&&EB0Read[h+1]=='0'&&EB0Read[h+2]=='1'&&EB0Read[h+3]=='1'&&EB0Read[h+4]=='1'&&EB0Read[h+5]=='1') {
OutTo[h_ot]='s';
h_ot++;
}
// ..... else if(EB0Read[h+0]=='1'&&EB0Read[h+1]=='0'&&EB0Read[h+2]=='1'&&EB0Read[h+3]=='1'&&EB0Read[h+4]=='1'&&EB0Read[h+5]=='0') {
OutTo[h_ot]='t';
h_ot++;
}
// .....
// 'u'~'z'.... else if(EB0Read[h+0]=='1'&&EB0Read[h+1]=='1'&&EB0Read[h+2]=='1'&&EB0Read[h+3]=='0'&&EB0Read[h+4]=='0'&&EB0Read[h+5]=='1') {
OutTo[h_ot]='u';
h_ot++;
}
// ..... else if(EB0Read[h+0]=='1'&&EB0Read[h+1]=='1'&&EB0Read[h+2]=='1'&&EB0Read[h+3]=='0'&&EB0Read[h+4]=='0'&&EB0Read[h+5]=='0') {
OutTo[h_ot]='v';
h_ot++;
}
// ..... else if(EB0Read[h+0]=='1'&&EB0Read[h+1]=='1'&&EB0Read[h+2]=='0'&&EB0Read[h+3]=='1'&&EB0Read[h+4]=='1'&&EB0Read[h+5]=='1') {
OutTo[h_ot]='w';
h_ot++;
}
// ..... else if(EB0Read[h+0]=='1'&&EB0Read[h+1]=='1'&&EB0Read[h+2]=='0'&&EB0Read[h+3]=='1'&&EB0Read[h+4]=='1'&&EB0Read[h+5]=='0') {
OutTo[h_ot]='x';
h_ot++;
}
// ..... else if(EB0Read[h+0]=='1'&&EB0Read[h+1]=='1'&&EB0Read[h+2]=='0'&&EB0Read[h+3]=='1'&&EB0Read[h+4]=='0'&&EB0Read[h+5]=='1') {
OutTo[h_ot]='y';
h_ot++;
}
// ..... else if(EB0Read[h+0]=='1'&&EB0Read[h+1]=='1'&&EB0Read[h+2]=='0'&&EB0Read[h+3]=='1'&&EB0Read[h+4]=='0'&&EB0Read[h+5]=='0') {
OutTo[h_ot]='z';
h_ot++;
}
// .....
// 0~9..... else if(EB0Read[h+0]=='0'&&EB0Read[h+1]=='1'&&EB0Read[h+2]=='0'&&EB0Read[h+3]=='0'&&EB0Read[h+4]=='0'&&EB0Read[h+5]=='0') {
OutTo[h_ot]='9';
h_ot++;
}
// ..... else if(EB0Read[h+0]=='0'&&EB0Read[h+1]=='1'&&EB0Read[h+2]=='0'&&EB0Read[h+3]=='0'&&EB0Read[h+4]=='0'&&EB0Read[h+5]=='1') {
OutTo[h_ot]='8';
h_ot++;
}
// ..... else if(EB0Read[h+0]=='0'&&EB0Read[h+1]=='1'&&EB0Read[h+2]=='0'&&EB0Read[h+3]=='0'&&EB0Read[h+4]=='1'&&EB0Read[h+5]=='0') {
OutTo[h_ot]='7';
h_ot++;
}
// ..... else if(EB0Read[h+0]=='0'&&EB0Read[h+1]=='1'&&EB0Read[h+2]=='0'&&EB0Read[h+3]=='0'&&EB0Read[h+4]=='1'&&EB0Read[h+5]=='1') {
OutTo[h_ot]='6';
h_ot++;
}
// ..... else if(EB0Read[h+0]=='0'&&EB0Read[h+1]=='1'&&EB0Read[h+2]=='0'&&EB0Read[h+3]=='1'&&EB0Read[h+4]=='0'&&EB0Read[h+5]=='0') {
OutTo[h_ot]='5';
h_ot++;
}
// ..... else if(EB0Read[h+0]=='0'&&EB0Read[h+1]=='1'&&EB0Read[h+2]=='0'&&EB0Read[h+3]=='1'&&EB0Read[h+4]=='0'&&EB0Read[h+5]=='1') {
OutTo[h_ot]='4';
h_ot++;
}
// ..... else if(EB0Read[h+0]=='0'&&EB0Read[h+1]=='1'&&EB0Read[h+2]=='0'&&EB0Read[h+3]=='1'&&EB0Read[h+4]=='1'&&EB0Read[h+5]=='0') {
OutTo[h_ot]='3';
h_ot++;
}
// ..... else if(EB0Read[h+0]=='0'&&EB0Read[h+1]=='1'&&EB0Read[h+2]=='0'&&EB0Read[h+3]=='1'&&EB0Read[h+4]=='1'&&EB0Read[h+5]=='1') {
OutTo[h_ot]='2';
h_ot++;
}
// ..... else if(EB0Read[h+0]=='0'&&EB0Read[h+1]=='1'&&EB0Read[h+2]=='1'&&EB0Read[h+3]=='0'&&EB0Read[h+4]=='0'&&EB0Read[h+5]=='0') {
OutTo[h_ot]='1';
h_ot++;
}
// ..... else if(EB0Read[h+0]=='0'&&EB0Read[h+1]=='1'&&EB0Read[h+2]=='1'&&EB0Read[h+3]=='0'&&EB0Read[h+4]=='0'&&EB0Read[h+5]=='1') {
OutTo[h_ot]='0';
h_ot++;
}
// ..... else if(EB0Read[h+0]=='0'&&EB0Read[h+1]=='0'&&EB0Read[h+2]=='1'&&EB0Read[h+3]=='0'&&EB0Read[h+4]=='0'&&EB0Read[h+5]=='0') {
OutTo[h_ot]='Q';
h_ot++;
}
// ..... else {
OutTo[h_ot]='F';
h_ot++;
}
h+=6;
}
}
/*-----------------------OutTo---------change---------------------*/
for (i=0;i<5;i++)
VIPNum[i]=OutTo[i];
//VIPNumber
for (i=5;i<10;i++)
BeiMa[i-5]=OutTo[i];
//BeiMa
for (i=10;i<25;i++) {
Name[i-10]=OutTo[i];
//Name
if(OutTo[i]=='Q')
Length_name=i-10;
}
for (i=25;i<43;i++) {
Password[i-25]=OutTo[i];
//Password
if(OutTo[i]=='Q')
Length_passwd=i-25;
}
for (i=43;i<49;i++)
Char_Score[i-43]=OutTo[i];
//Char_Score
for (i=49;i<53;i++)
HouMen[i-49]=OutTo[i];
Score=ChangeCTI_Score(Char_Score);
printf("\n\n\n");
//system("pause");
}
int ChangeCTI_Score(char CSC[]) //Change char to int {
int i;
int Sc;
int Get[6];
for (i=0;i<6;i++) {
switch(CSC[i]) {
case '0':Get[i]=0;
break;
case '1':Get[i]=1;
break;
case '2':Get[i]=2;
break;
case '3':Get[i]=3;
break;
case '4':Get[i]=4;
break;
case '5':Get[i]=5;
break;
case '6':Get[i]=6;
break;
case '7':Get[i]=7;
break;
case '8':Get[i]=8;
break;
case '9':Get[i]=9;
break;
default:break;
}
}
Sc=Get[0]*100000+Get[1]*10000+Get[2]*1000+Get[3]*100+Get[4]*10+Get[5]*1;
return Sc;
}
int TestIf_DataFile_Right() {
int i;
int k;
int ForPass=0;
if(BeiMa[0]=='1' && BeiMa[1]=='4' && BeiMa[2]=='7' && BeiMa[3]=='7' && BeiMa[4]=='9')
ForPass++;
//={'1','3','5','7','9'}; {
if(Length_name==5)
if((Name[Length_name]=='Q') && (Name[Length_name+1]==Name[4]) && (Name[Length_name+2]==Name[3]) && (Name[Length_name+3]==Name[2]) && (Name[Length_name+4]==Name[1]) && (Name[Length_name+5]==Name[0]) && (Name[Length_name+6]==Name[3]) && (Name[Length_name+7]==Name[2]) && (Name[Length_name+8]==Name[1]) && (Name[Length_name+9]==Name[0]))
ForPass++;
if(Length_name==6)
if((Name[Length_name]=='Q') && (Name[Length_name+1]==Name[4]) && (Name[Length_name+2]==Name[3]) && (Name[Length_name+3]==Name[2]) && (Name[Length_name+4]==Name[1]) && (Name[Length_name+5]==Name[0]) && (Name[Length_name+6]==Name[3]) && (Name[Length_name+7]==Name[2]) && (Name[Length_name+8]==Name[1]))
ForPass++;
if(Length_name==7)
if((Name[Length_name]=='Q') && (Name[Length_name+1]==Name[4]) && (Name[Length_name+2]==Name[3]) && (Name[Length_name+3]==Name[2]) && (Name[Length_name+4]==Name[1]) && (Name[Length_name+5]==Name[0]) && (Name[Length_name+6]==Name[3]) && (Name[Length_name+7]==Name[2]))
ForPass++;
if(Length_name==8)
if((Name[Length_name]=='Q') && (Name[Length_name+1]==Name[4]) && (Name[Length_name+2]==Name[3]) && (Name[Length_name+3]==Name[2]) && (Name[Length_name+4]==Name[1]) && (Name[Length_name+5]==Name[0]) && (Name[Length_name+6]==Name[3]))
ForPass++;
if(Length_name==9)
if((Name[Length_name]=='Q') && (Name[Length_name+1]==Name[4]) && (Name[Length_name+2]==Name[3]) && (Name[Length_name+3]==Name[2]) && (Name[Length_name+4]==Name[1]) && (Name[Length_name+5]==Name[0]))
ForPass++;
if(Length_name==10)
if((Name[Length_name]=='Q') && (Name[Length_name+1]==Name[4]) && (Name[Length_name+2]==Name[3]) && (Name[Length_name+3]==Name[2]) && (Name[Length_name+4]==Name[1]))
ForPass++;
if(Length_name==11)
if((Name[Length_name]=='Q') && (Name[Length_name+1]==Name[4]) && (Name[Length_name+2]==Name[3]) && (Name[Length_name+3]==Name[2]))
ForPass++;
if(Length_name==12)
if((Name[Length_name]=='Q') && (Name[Length_name+1]==Name[4]) && (Name[Length_name+2]==Name[3]))
ForPass++;
if(Length_name==13)
if((Name[Length_name]=='Q') && (Name[Length_name+1]==Name[4]))
ForPass++;
if(Length_name==14)
if((Name[Length_name]=='Q'))
ForPass++;
}
if(HouMen[0]=='0' && HouMen[1]=='l' && HouMen[2]=='q' && HouMen[3]=='c')
ForPass++;
//={'0','l','q','c'};
if(ForPass==3) {
system("cls");
printf("\nVIP user Welcome Back !!!\n\n");
system("pause");
ShowTheVIPInfomations();
} else {
return 4;
}
return 0;
}
void ShowTheVIPInfomations() {
int i;
system("cls");
printf("\n\n");
printf(" ===================VIP Informations:====================== \n");
printf(" ============== VIP Informations: ================= \n");
printf(" ========================================================== \n");
printf("\n\n");
printf(" VIP number: ");
for (i=0;i<5;i++)
printf("%c",VIPNum[i]);
printf("\n\n");
printf(" VIP User Name:%d = ",Length_name);
for (i=0;i<Length_name;i++)
printf("%c",Name[i]);
printf("\n");
printf(" VIP Password:%d = ",Length_passwd);
if(IFLogin==1) {
for (i=0;i<Length_passwd;i++)
printf("%c",Password[i]);
} else {
for (i=0;i<Length_passwd;i++)
printf("*");
printf(" (Please Login...)");
}
printf("\n\n");
printf(" VIP Score: %d",Score);
printf("\n\n");
printf(" HouMen: ");
for (i=0;i<4;i++)
printf("%c",HouMen[i]);
printf("\n\n\n");
printf(" ============================================================\n");
printf(" ===================== VIP Informations ==================\n");
printf(" ============================================================\n");
printf("\n\n\n");
system("pause");
}
int Login() {
int i,j;
int i_name;
int i_passwd2;
int k,l;
char PasswordAgain[18];
IFLogin=0;
k=99;
l=3;
while(k!=88) {
k=88;
system("cls");
printf(" ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ \n");
printf(" ***************** 登 录 ******************** \n");
printf(" ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ \n");
printf(" \n");
printf(" 您的用户名是: ");
for (i=0;i<Length_name;i++)
printf("%c",Name[i]);
printf("\n");
printf(" 请输入您的密码: ");
i_passwd2=-1;
do {
i_passwd2++;
scanf("%c",&PasswordAgain[i_passwd2]);
}
while(PasswordAgain[i_passwd2]!='\n');
l--;
//times out...
for (j=0;j<i_passwd2;j++) {
if(Password[j]!=PasswordAgain[j] || (Length_passwd!=i_passwd2)) {
k=99;
system("cls");
printf("\n\n Warning: Password Error !!\n");
printf(" please input again...\n>>>>>>>>>>>>>\n");
printf(" you have %d Chance to try...\n",l);
system("pause");
break;
}
}
if(Length_passwd != i_passwd2) {
k=99;
}
/*----------------------------To Sure Again over----------------*/
if(l==0) //Test times over break ! {
system("cls");
printf("\nWarning: 3 times has passed\n");
printf("Login Fail !!...\n\n");
printf(" 如果您忘记密码,且放弃数据..\n");
printf(" 请删除此目录下的Game_Data.txt\n");
printf(" 然后重试...\n\n\n");
system("pause");
return 81;
}
}
//if(k==88) over if(k==99) Continue...system("cls");
printf("\n\n\nLogin Successfull !!\n\n");
printf("================== VIP informations!! ==============\n");
printf("=========================================================\n");
printf("\n");
printf(" User Name: ");
for (i=0;i<Length_name;i++)
printf("%c",Name[i]);
printf("\n");
printf(" Password: ");
for (i=0;i<i_passwd2;i++)
printf("%c",Password[i]);
printf("\n\n");
printf("=========================================================\n");
printf("============remeber the fllowing informations!!==========\n");
printf("\n\n\n");
system("pause");
IFLogin=1;
return 0;
}
void Help() {
system("cls");
printf(" ======================================================== \n");
printf(" =================== 引言 ===================== \n");
printf(" ======================================================== \n");
printf(" 欢迎您试玩《推箱子_C语言版》 益智小游戏 \n");
printf(" 此小游戏没有华丽的图形界面,仅仅是黑屏白字的字符界面,是使用Dev_C++程序设计语言写的简单小游戏。可以直接双击运行,\n");
printf(" 相信大家都玩过手机游戏《推箱子》吧?没错,这就是‘简体推箱子’\n");
printf(" 此版本是第一个'正式中文版': V6.2.2.0 于2008年3月1日发布。此前的完成版与测试版皆没公开,第一个英文版V6.2.1.0\n");
printf(" 欢迎登录《积雨云空间》,http://hi.baidu.com/jiyuyunkongjian 此百度空间为系列互动空间,里面有最新信息,为保持可玩性,游戏的源代码将在正式版公开的一个月内公布。此后的系列信息将在此空间发布,敬请关注。\n");
printf("\n\n\n");
system("pause");
system("cls");
printf(" ======================================================== \n");
printf(" ================== 游戏说明 ==================== \n");
printf(" ======================================================== \n");
printf(" 初次打开此游戏后,出现的是一个提示信息,这提示你不是VIP会员,之后:你可以输入‘1’选择直接开始玩,和‘2’进行注册(注册在下页介绍)。\n");
printf(" 相关字符的意义:'M'代表是城墙,不可移动以及穿越;'='代表箱子;'T'代表目的地;'#'代表工人。\n\n");
printf(" 直接试玩的话,可以输入“w”“s”“a”“d”分别进行对应的‘上’、‘下’、‘左’、‘右’移动.操纵箱子工人'工作',\n\n");
printf("\n\n\n");
system("pause");
system("cls");
printf(" ======================================================== \n");
printf(" ================== 游戏说明 ==================== \n");
printf(" ======================================================== \n");
printf(" 注册需要输入用户名与密码。\n\n");
printf(" 注册的用户名、密码可以使用'0'~'9'、'a'~'z'(以为春节当时没带C回家,忘记了部分内容,之后懒得整体修改。所以...不支持大写字母*^_^*....很有可能导致录入错误,请小写与数字组合啦....)的任意组合\n\n");
printf("\n\n\n");
system("pause");
system("cls");
printf(" ======================================================== \n");
printf(" ======================Help Centre======================= \n");
printf(" ======================================================== \n");
printf(" 可以单独输入一个方向,也可以连续输入,但输入完成后必须按回车键以确认输入,例如:'w'+回车将进行'上'移动,输入'w'+'w'+'a'+'a'+'a'+回车将进行'上'、'上'、'左'、'左'、'左'的移动\n\n");
printf(" 游戏宫格右边显示相关信息\n\n");
printf(" 注册成功(或者游戏过关会提示您注册)后,将生成323位由类似10101100100.....的txt文档文件《Game_Data.txt》\n\n");
printf("\n");
printf(" 在游戏状态下,按'0000'四个零然后回车,将放弃游戏返回!\n");
printf("\n");
system("pause");
system("cls");
printf(" ======================================================== \n");
printf(" ======================Help Centre======================= \n");
printf(" ======================================================== \n");
printf(" 生成的《Game_Data.txt》文档文件您可以发送到carson256@163.com或者提取(复制)此323个字符到积雨云空间以留言的形式输入,之后将由本人进行解密(虽然字符串的意义只有本解密器能解密,但是安全起见,请不要使用重要密码,请使用简单不重要的密码),得到的注册信息在以后下个系列的游戏中可以直接运用,进行登录\n\n");
printf(" 注意:请勿将323个字符 修改,置换顺序。否则将乱码,不能提取信息。不能进行下次登录,或者默认登陆\n\n");
printf(" xiexie\n\n");
printf("\n");
system("pause");
//exit(0);
}
void AboutMe() {
system("cls");
printf(" ======================================================== \n");
printf(" =========== 序 ============ \n");
printf(" ======================================================== \n\n");
printf(" 谢谢您试玩 “推箱子_C语言版” 益智小游戏 \n");
printf(" 关于开发此小游戏是一个偶然...\n\n");
printf(" 除夕时无聊,就想打爆我手机上的推箱子游戏。但我反复就是在一个关卡停住了,这关其实不难,但我就是被我的惯性思维框死了,玩了N个小时。真是郁闷,就有突发奇想,可以使用这个学期刚学的C来写个小小的游戏。\n\n");
printf(" 没带电脑回家(此时有点后悔当初买台式机),设计出了基础的算法,没办法:只能把源代码写在纸上,代码写在纸上非常不利于修改,上网吧 敲进电脑去,一大堆的错误!之后不断调试DEBUG...终于让主程序模块可以运行了。\n\n");
printf(" 之后又增添了不少内容(其实核心代码才600多行,此正式版一共2230多行),比如增加了会员信息,积分制度(积分本来想利用在网络上找到的没学过的资料来完善的了,但没时间,也考虑到这是没学过的内容,在正式版就没加入,仅仅作为预览系统时间来运用。可能在下个版本会加入进去。让积分的意义更加深。)\n");
printf(" 此系列的以下版本增加多关卡。将可能增加“悔棋功能”\n\n");
printf(" 下个系列将以美术为主,敬请关注...\n");
printf(" 此致。\n");
printf("\n");
system("pause");
}
int GameStart() {
int input_n;
input_n=0;
while(1) {
if(DealWhitData(input_n)==8) return 10;
Output();
input_n=Input();
if(input_n==-1) break;
// return to Menu....
}
return 0;
}
/*----------------------------Begin---------------------------------------*/
int Input() {
int input_n;
printf("score =%d ",Score);
printf(" Input the fangxiang:");
input_n=-1;
do {
input_n++;
scanf("%c",&SR[input_n]);
}
while(SR[input_n]!='\n');
if(input_n==4) {
if(SR[0]=='0' && SR[1]=='0' && SR[2]=='0' && SR[3]=='0') {
Save();
return -1;
// '0000' T0 Escape
}
}
if(input_n==6) {
if(SR[0]=='0'&&SR[1]=='0'&&SR[2]=='0'&&SR[3]=='0'&&SR[4]=='0'&&SR[5]=='0')
return -1;
}
// '000000' T0 Escape ALL.....
return input_n;
}
int DealWhitData(int input_n) {
int i;
DealWhitData_YiDong(input_n);
if((i=DealWithData_Win())==8)return 8;
// Win .....
DealWhitData_ZhiGuan();
return 0;
}
void DealWhitData_YiDong(int input_n) {
int i;
for (i=0;i<input_n;i++) {
switch(SR[i]) {
case 'w': {
switch(WP[p-1][q]) {
case 0: {
WP[p][q]=0;
p--;
WP[p][q]=9;
Score-=1;
// Score addion...
break;
}
case 8: {
WP[p][q]=0;
p--;
WP[p][q]=9;
Score-=1;
// Score addion...
break;
}
case 1: {
if(WP[p-2][q]==0 || WP[p-2][q]==8) {
WP[p-2][q]=1;
WP[p][q]=0;
p--;
WP[p][q]=9;
Score-=1;
// Score addion...
} else if(WP[p-2][q]==2 || WP[p-1][q]==1) {
;
}
break;
}
case 2: {
break;
}
default:
break;
}
break;
}
case 's': {
switch(WP[p+1][q]) {
case 0: {
WP[p][q]=0;
p++;
WP[p][q]=9;
Score-=1;
// Score addion...
break;
}
case 8: {
WP[p][q]=0;
p++;
WP[p][q]=9;
Score-=1;
// Score addion...
break;
}
case 1: {
if(WP[p+2][q]==0 || WP[p+2][q]==8) {
WP[p+2][q]=1;
WP[p][q]=0;
p++;
WP[p][q]=9;
Score-=1;
// Score addion...
} else if(WP[p+2][q]==2 || WP[p+1][q]==1) {
;
}
break;
}
case 2: {
break;
}
default:
break;
}
break;
}
case 'a': {
switch(WP[p][q-1]) {
case 0: {
WP[p][q]=0;
q--;
WP[p][q]=9;
Score-=1;
// Score addion...
break;
}
case 8: {
WP[p][q]=0;
q--;
WP[p][q]=9;
Score-=1;
// Score addion...
break;
}
case 1: {
if(WP[p][q-2]==0 || WP[p][q-2]==8) {
WP[p][q-2]=1;
WP[p][q]=0;
q--;
WP[p][q]=9;
Score-=1;
// Score addion...
} else if(WP[p][q-2]==2 || WP[p][q-2]==1) {
;
}
break;
}
case 2: {
break;
}
default:
break;
}
break;
}
case 'd': {
switch(WP[p][q+1]) {
case 0: {
WP[p][q]=0;
q++;
WP[p][q]=9;
Score-=1;
// Score addion...
break;
}
case 8: {
WP[p][q]=0;
q++;
WP[p][q]=9;
Score-=1;
// Score addion...
break;
}
case 1: {
if(WP[p][q+2]==0 || WP[p][q+2]==8) {
WP[p][q+2]=1;
WP[p][q]=0;
q++;
WP[p][q]=9;
Score-=1;
// Score addion...
} else if(WP[p][q+2]==2 || WP[p][q+2]==1) {
;
}
break;
}
case 2: {
break;
}
default:
break;
}
break;
}
default:
break;
}
}
}
int DealWithData_Win() {
//DealWith_ZhiFfen();
int rg;
WinNumber=0;
if(WP[4][1]==1)WinNumber++;
if(WP[5][1]==1)WinNumber++;
if(WP[6][1]==1)WinNumber++;
//if(WP[6][1]==1)WinNumber++;
//if(WP[6][2]==1)WinNumber++;
if(WP[4][1]==1 && WP[5][1]==1 && WP[6][1]==1)//&&WP[6][1]==1&&WP[6][2]==1) {
system("cls");
printf(" ********************* 祝 贺 您 *********************\n");
printf("\n\n\n ***********Congratulations*******************\n");
printf(" You Win The Game !!!\n\n");
//printf("aaaaaaaaaaaaaaaaaaaaa");
system("pause");
//system("pause");system("pause");
if(IFRFF==-1) {
printf("Do u want to regester a user?(Yes=1/No=0):");
scanf("%d",&rg);
if(rg==0)
return 8; else {
system("pause");
RegisterUser();
Save();
//write TO file...
}
}
return 8;
}
return 0;
// win the game.....
}
void DealWhitData_ZhiGuan() {
int i,j,k,l;
//int x=0,y=0;
int s=0,t=0;
for (i=0;i<8;i++) {
for (j=0;j<9;j++) {
switch(WP[i][j]) {
case 0: {
for (k=0;k<3;k++) {
for (l=0;l<5;l++) {
ZG[s][t]=0;
t++;
}
s++;
t=t-5;
}
break;
}
case 1: {
for (k=0;k<3;k++) {
for (l=0;l<5;l++) {
ZG[s][t]=1;
t++;
}
s++;
t=t-5;
}
break;
}
case 2: {
for (k=0;k<3;k++) {
for (l=0;l<5;l++) {
ZG[s][t]=2;
t++;
}
s++;
t=t-5;
}
break;
}
case 8: {
for (k=0;k<3;k++) {
for (l=0;l<5;l++) {
ZG[s][t]=0;
t++;
}
s++;
t=t-5;
}
break;
}
case 9: // Make the shape of worker... {
for (k=0;k<3;k++) {
for (l=0;l<5;l++) {
if((k==0 || k==2) && (l==0 || l==4)) {
ZG[s][t]=9;
} else if(k==1 && (l==1 || l==2 || l==3)) {
ZG[s][t]=9;
} else {
ZG[s][t]=0;
}
t++;
}
s++;
t=t-5;
}
break;
}
default:
break;
}
//switch(WP[i][j]) over
s-=3;
t+=5;
}
s+=3;
t=0;
}
ZG[13][7]=8,ZG[16][7]=8,ZG[19][7]=8;
// ZG[19][7]=8,ZG[19][12]=8;//Aim sign
//WP[4][1]==1&&WP[5][1]==1&&WP[6][1]==1)
WinNumber+=80;
ZG[16][54]=WinNumber;
WinNumber-=80;
// !!!!!!!!!
/*=======================================Liang Jiao: */
for (i=45;i<70;i++) {
ZG[0][i]=91;
ZG[2][i]=93;
//ZG[22][i]=2;
ZG[23][i]=91;
}
for (j=0;j<24;j++) {
ZG[j][45]=3;
}
for (j=0;j<24;j++) {
//ZG[j][68]=2;
ZG[j][69]=2;
}
// | Show squre-Box-----
/*--------------------------Gu Ding--------------------------------*/
}
int Output() {
system("cls");
Output_PrintBox();
return 0;
}
void Output_PrintBox() {
int i,j,k;
//printf("%d\n",ZG[5][51]);
for (i=0;i<24;i++) {
for (j=0;j<70;j++) {
/*======================================================================*/
if(i==1 && j==50) // TO Print 'Informations' {
printf("INFORMATIONS");
j+=12;
}
if(i==3 && j==48) // To print "VIP number" {
printf("VIP Number:");
j+=11;
}
//||||||||||||||||||||||
if(i==4 && j==54) // To print VIP number {
for (k=0;k<5;k++)
printf("%c",VIPNum[k]);
j+=5;
}
if(i==6 && j==48) // To print "User Name:" {
printf("User Name:");
j+=10;
}
//||||||||||||||||||||||
if(i==7 && j==51) // To print Name {
for (k=0;k<Length_name;k++)
printf("%c",Name[k]);
for (k=0;k<15-Length_name;k++)
printf(" ");
j+=15;
}
if(i==9 && j==48) // To print "Score:" {
printf("Score:");
j+=6;
}
//||||||||||||||||||||||
if(i==10 && j==52) // To print Score {
printf("%6d",Score);
//
j+=6;
}
if(i==16 && j==47) // To print "WinNumber= X/X" {
printf("WinNB= ");
j+=7;
ZG[16][55]=92;
// /
}
if(i==20 && j==55) {
printf( "%02d:%02d",timeinfo->tm_hour,timeinfo->tm_min);
j+=5;
//break;// To print Time
}
if(i==23 && j==47) {
printf("'0000' To Escape.");
j+=17;
}
/*======================================================================*/
switch(ZG[i][j]) // >>> switch 1 begin {
case 0:
printf(" ");
break;
case 1:
printf("=");
break;
case 2:
printf("M");
break;
case 3:
printf("W");
break;
case 8:
printf("T");
break;
case 9:
printf("#");
break;
default: {
switch(ZG[i][j]) // >>> switch 2 begin {
case 51:printf("a");
break;
case 52:printf("b");
break;
case 53:printf("c");
break;
case 54:printf("d");
break;
case 55:printf("e");
break;
case 56:printf("f");
break;
case 57:printf("g");
break;
case 58:printf("h");
break;
case 59:printf("i");
break;
case 60:printf("j");
break;
case 61:printf("k");
break;
case 62:printf("l");
break;
case 63:printf("m");
break;
case 64:printf("n");
break;
case 65:printf("o");
break;
case 66:printf("p");
break;
case 67:printf("q");
break;
case 68:printf("r");
break;
case 69:printf("s");
break;
case 70:printf("t");
break;
case 71:printf("u");
break;
case 72:printf("v");
break;
case 73:printf("w");
break;
case 74:printf("x");
break;
case 75:printf("y");
break;
case 76:printf("z");
break;
default: {
switch(ZG[i][j]) // >>> switch 3 begin {
case 80:printf("0");
break;
case 81:printf("1");
break;
case 82:printf("2");
break;
case 83:printf("3");
break;
case 84:printf("4");
break;
case 85:printf("5");
break;
case 86:printf("6");
break;
case 87:printf("7");
break;
case 88:printf("8");
break;
case 89:printf("9");
break;
default: {
switch(ZG[i][j])// >>> switch 4 begin {
case 90:printf(":");
break;
case 91:printf("=");
break;
case 92:printf("/");
break;
case 93:printf(".");
break;
//case 95:printf("\n");break;
default:
exit(0);
break;
// <<< switch 4 OVER
}
}
break;
// <<< switch 3 OVER
}
}
break;
// <<< switch 2 OVER
}
}
break;
// <<< switch 1 OVER
}
// <<< switch's "}"...
}
//for j OVER
printf("\n");
}
//for I OVER
}
int RegisterUser() //Zhu Ce Yi Ge Yong Hu {
int i,j;
int i_name,i_passwd;
int i_passwd2;
int k,l;
char p;
char PasswordAgain[18];
system("cls");
printf(" ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ \n");
printf(" *****************Register a New User******************** \n");
printf(" ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ \n");
printf(" \n");
printf(" Please Input The Necessary Informations ! \n\n");
/*--------------------------Input the Name------------------------*/
k=99;
l=0;
while(k!=88) {
i_name=-1;
printf("User_Name(5~13):");
//Input the Name----(5~15)
do {
i_name++;
scanf("%c",&Name[i_name]);
p=Name[i_name];
}
while(Name[i_name]!='\n');
//i_name++;
if(k==44) {
printf(" Warning:\n Input Error...");
printf(" ('a'~'z' OR '0'~'9')\n\n\n");
}
if((i_name>=5 && i_name<15) && (k!=44))
k=88;
// TO Escape 'while' else k=99;
l++;
//Test times over break !
if(l==5) {
printf("\nWarning: 5 times has passed\n");
printf("Register Fail !!\n\n");
return -2;
}
if(k==99) {
printf("User Length is: 5~15\n");
printf("k==99 so ...==ERROR Again\n");
system("pause");
system("cls");
printf(" ++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
printf(" ****************Register a New User*******************\n");
printf(" ++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
printf(" \n");
printf(" Please Input The Necessary Informations ! \n\n");
}
}
printf("i_name=%d\n",i_name);
Length_name=i_name;
if(i_name!=15) //Make the Name fulllllll {
j=16-i_name;
i_name--;
//!!!!!!!!!!!!!!!!!!!!!!!!!!
//if(j>0)Name[i+0]=Name[0];
if(j>1)Name[i_name+1]='Q';
if(j>2)Name[i_name+2]=Name[4];
if(j>3)Name[i_name+3]=Name[3];
if(j>4)Name[i_name+4]=Name[2];
if(j>5)Name[i_name+5]=Name[1];
if(j>6)Name[i_name+6]=Name[0];
if(j>7)Name[i_name+7]=Name[3];
if(j>8)Name[i_name+8]=Name[2];
if(j>9)Name[i_name+9]=Name[1];
if(j>10)Name[i_name+10]=Name[0];
}
i_name++;
/*--------------------------Input the Password------------------------*/
k=99;
l=0;
while(k!=88) {
i_passwd=-1;
printf("User_Password(6~15):");
//Input the Password--(6~18)
do {
i_passwd++;
scanf("%c",&Password[i_passwd]);
p=Password[i_passwd];
}
while(Password[i_passwd]!='\n');
if(i_passwd>5 && i_passwd<18) {
k=88;
} else {
k=99;
}
printf("i_passwd=%d\n",i_passwd);
Length_passwd=i_passwd;
/*----------------------------To Sure Again---------------------*/
if(k==88) {
i_passwd2=-1;
printf("Input Passwd Again :");
//To Sure Again
do {
i_passwd2++;
scanf("%c",&PasswordAgain[i_passwd2]);
}
while(PasswordAgain[i_passwd2]!='\n');
for (j=0;j<i_passwd2;j++) {
if((Password[j]!=PasswordAgain[j]) || (i_passwd!=i_passwd2)) {
k=99;
printf("\nWarning: Password is no the same !!\n");
printf("please input again...\n\n>>>\n");
break;
}
}
}
/*----------------------------To Sure Again over----------------*/
l++;
if(l==4) //Test times over break ! {
printf("\nWarning: 3 times has passed\n");
printf("Register Fail !!\n\n");
return -2;
}
//k=99;
}
//if(k==88) over if(k==99) Continue...
if(i_passwd!=18) //Make the Password fulllllll {
j=19-i_passwd;
i_passwd--;
//!!!!!!!!!!!!!!
//if(j>0)Name[i+0]=Name[0];
if(j>1)Password[i_passwd+1]='Q';
if(j>2)Password[i_passwd+2]=Password[4];
if(j>3)Password[i_passwd+3]=Password[3];
if(j>4)Password[i_passwd+4]=Password[2];
if(j>5)Password[i_passwd+5]=Password[1];
if(j>6)Password[i_passwd+6]=Password[0];
if(j>7)Password[i_passwd+7]=Password[4];
if(j>8)Password[i_passwd+8]=Password[3];
if(j>9)Password[i_passwd+9]=Password[2];
if(j>10)Password[i_passwd+10]=Password[1];
if(j>11)Password[i_passwd+11]=Password[0];
if(j>12)Password[i_passwd+12]=Password[0];
}
i_passwd++;
system("cls");
printf("\n\n\nRegister a New User Successfull !!\n\n");
printf("============remeber the fllowing informations!!==========\n");
printf("=========================================================\n");
printf("\n");
printf(" User Name: ");
for (i=0;i<i_name;i++) {
printf("%c",Name[i]);
}
printf("\n");
printf(" Password: ");
for (i=0;i<i_passwd;i++) {
printf("%c",Password[i]);
}
printf("\n\n");
printf("=========================================================\n");
printf("============remeber the fllowing informations!!==========\n");
printf("\n\n\n");
system("pause");
Save();
IFRFF=1;
return 0;
}
int Save() {
DealWithData_Write();
WriteToFile();
return 0;
}
void DealWithData_Write() {
int h;
int i,j,k,l;
char InTo[53];
/*-----------------------InTo---------change---------------------*/
for (i=0;i<5;i++)
InTo[i]=VIPNum[i];
//VIPNumber
for (i=5;i<10;i++)
InTo[i]=BeiMa[i-5];
//BeiMa
/*
for(i=6;i<8;i++)
InTo[i]=Length_Name[i-6]; //Length_Name
for(i=8;i<10;i++)
InTo[i]=Length_Password[i-8]; //Length_Password
*/
/*-----------------------working---------------------------------*/
//if()
for (i=10;i<25;i++)
InTo[i]=Name[i-10];
//Name
for (i=25;i<43;i++)
InTo[i]=Password[i-25];
//Password
/*-----------------------working-------------------------------*/
ChangeITC_Score(Score);
for (i=43;i<49;i++)
InTo[i]=Char_Score[i-43];
//Char_Score
for (i=49;i<53;i++)
InTo[i]=HouMen[i-49];
/*---------------------DealWith--EB0Write----------change-------------*/
h=2;
for (i=0;i<53;i++) {
switch(InTo[i]) {
case '9': {
EB0Write[h+0]='0';
EB0Write[h+1]='1';
EB0Write[h+2]='0';
EB0Write[h+3]='0';
EB0Write[h+4]='0';
EB0Write[h+5]='0';
break;
}
case '8': {
EB0Write[h+0]='0';
EB0Write[h+1]='1';
EB0Write[h+2]='0';
EB0Write[h+3]='0';
EB0Write[h+4]='0';
EB0Write[h+5]='1';
break;
}
case '7': {
EB0Write[h+0]='0';
EB0Write[h+1]='1';
EB0Write[h+2]='0';
EB0Write[h+3]='0';
EB0Write[h+4]='1';
EB0Write[h+5]='0';
break;
}
case '6': {
EB0Write[h+0]='0';
EB0Write[h+1]='1';
EB0Write[h+2]='0';
EB0Write[h+3]='0';
EB0Write[h+4]='1';
EB0Write[h+5]='1';
break;
}
case '5': {
EB0Write[h+0]='0';
EB0Write[h+1]='1';
EB0Write[h+2]='0';
EB0Write[h+3]='1';
EB0Write[h+4]='0';
EB0Write[h+5]='0';
break;
}
case '4': {
EB0Write[h+0]='0';
EB0Write[h+1]='1';
EB0Write[h+2]='0';
EB0Write[h+3]='1';
EB0Write[h+4]='0';
EB0Write[h+5]='1';
break;
}
case '3': {
EB0Write[h+0]='0';
EB0Write[h+1]='1';
EB0Write[h+2]='0';
EB0Write[h+3]='1';
EB0Write[h+4]='1';
EB0Write[h+5]='0';
break;
}
case '2': {
EB0Write[h+0]='0';
EB0Write[h+1]='1';
EB0Write[h+2]='0';
EB0Write[h+3]='1';
EB0Write[h+4]='1';
EB0Write[h+5]='1';
break;
}
case '1': {
EB0Write[h+0]='0';
EB0Write[h+1]='1';
EB0Write[h+2]='1';
EB0Write[h+3]='0';
EB0Write[h+4]='0';
EB0Write[h+5]='0';
break;
}
case '0': {
EB0Write[h+0]='0';
EB0Write[h+1]='1';
EB0Write[h+2]='1';
EB0Write[h+3]='0';
EB0Write[h+4]='0';
EB0Write[h+5]='1';
break;
}
default: // Inoder To Save the Cache------------ {
/*---------------------------IN switch begin------------------------*/
switch(InTo[i]) {
case 'a': {
EB0Write[h+0]='1';
EB0Write[h+1]='0';
EB0Write[h+2]='1';
EB0Write[h+3]='1';
EB0Write[h+4]='0';
EB0Write[h+5]='1';
break;
}
case 'b': {
EB0Write[h+0]='1';
EB0Write[h+1]='0';
EB0Write[h+2]='1';
EB0Write[h+3]='1';
EB0Write[h+4]='0';
EB0Write[h+5]='0';
break;
}
case 'c': {
EB0Write[h+0]='1';
EB0Write[h+1]='0';
EB0Write[h+2]='1';
EB0Write[h+3]='0';
EB0Write[h+4]='1';
EB0Write[h+5]='1';
break;
}
case 'd': {
EB0Write[h+0]='1';
EB0Write[h+1]='0';
EB0Write[h+2]='1';
EB0Write[h+3]='0';
EB0Write[h+4]='1';
EB0Write[h+5]='0';
break;
}
case 'e': {
EB0Write[h+0]='1';
EB0Write[h+1]='0';
EB0Write[h+2]='1';
EB0Write[h+3]='0';
EB0Write[h+4]='0';
EB0Write[h+5]='1';
break;
}
case 'f': {
EB0Write[h+0]='1';
EB0Write[h+1]='0';
EB0Write[h+2]='1';
EB0Write[h+3]='0';
EB0Write[h+4]='0';
EB0Write[h+5]='0';
break;
}
case 'g': {
EB0Write[h+0]='1';
EB0Write[h+1]='0';
EB0Write[h+2]='0';
EB0Write[h+3]='1';
EB0Write[h+4]='1';
EB0Write[h+5]='1';
break;
}
case 'h': {
EB0Write[h+0]='1';
EB0Write[h+1]='0';
EB0Write[h+2]='0';
EB0Write[h+3]='1';
EB0Write[h+4]='1';
EB0Write[h+5]='0';
break;
}
case 'i': {
EB0Write[h+0]='1';
EB0Write[h+1]='0';
EB0Write[h+2]='0';
EB0Write[h+3]='1';
EB0Write[h+4]='0';
EB0Write[h+5]='1';
break;
}
case 'j': {
EB0Write[h+0]='1';
EB0Write[h+1]='0';
EB0Write[h+2]='0';
EB0Write[h+3]='1';
EB0Write[h+4]='0';
EB0Write[h+5]='0';
break;
}
case 'k': {
EB0Write[h+0]='1';
EB0Write[h+1]='0';
EB0Write[h+2]='0';
EB0Write[h+3]='0';
EB0Write[h+4]='1';
EB0Write[h+5]='1';
break;
}
case 'l': {
EB0Write[h+0]='1';
EB0Write[h+1]='0';
EB0Write[h+2]='0';
EB0Write[h+3]='0';
EB0Write[h+4]='1';
EB0Write[h+5]='0';
break;
}
case 'm': {
EB0Write[h+0]='1';
EB0Write[h+1]='0';
EB0Write[h+2]='0';
EB0Write[h+3]='0';
EB0Write[h+4]='0';
EB0Write[h+5]='1';
break;
}
case 'n': {
EB0Write[h+0]='1';
EB0Write[h+1]='0';
EB0Write[h+2]='0';
EB0Write[h+3]='0';
EB0Write[h+4]='0';
EB0Write[h+5]='0';
break;
}
case 'o': {
EB0Write[h+0]='1';
EB0Write[h+1]='1';
EB0Write[h+2]='0';
EB0Write[h+3]='0';
EB0Write[h+4]='1';
EB0Write[h+5]='1';
break;
}
case 'p': {
EB0Write[h+0]='1';
EB0Write[h+1]='1';
EB0Write[h+2]='0';
EB0Write[h+3]='0';
EB0Write[h+4]='1';
EB0Write[h+5]='0';
break;
}
case 'q': {
EB0Write[h+0]='1';
EB0Write[h+1]='1';
EB0Write[h+2]='0';
EB0Write[h+3]='0';
EB0Write[h+4]='0';
EB0Write[h+5]='1';
break;
}
case 'r': {
EB0Write[h+0]='1';
EB0Write[h+1]='1';
EB0Write[h+2]='0';
EB0Write[h+3]='0';
EB0Write[h+4]='0';
EB0Write[h+5]='0';
break;
}
case 's': {
EB0Write[h+0]='1';
EB0Write[h+1]='0';
EB0Write[h+2]='1';
EB0Write[h+3]='1';
EB0Write[h+4]='1';
EB0Write[h+5]='1';
break;
}
case 't': {
EB0Write[h+0]='1';
EB0Write[h+1]='0';
EB0Write[h+2]='1';
EB0Write[h+3]='1';
EB0Write[h+4]='1';
EB0Write[h+5]='0';
break;
}
case 'u': {
EB0Write[h+0]='1';
EB0Write[h+1]='1';
EB0Write[h+2]='1';
EB0Write[h+3]='0';
EB0Write[h+4]='0';
EB0Write[h+5]='1';
break;
}
case 'v': {
EB0Write[h+0]='1';
EB0Write[h+1]='1';
EB0Write[h+2]='1';
EB0Write[h+3]='0';
EB0Write[h+4]='0';
EB0Write[h+5]='0';
break;
}
case 'w': {
EB0Write[h+0]='1';
EB0Write[h+1]='1';
EB0Write[h+2]='0';
EB0Write[h+3]='1';
EB0Write[h+4]='1';
EB0Write[h+5]='1';
break;
}
case 'x': {
EB0Write[h+0]='1';
EB0Write[h+1]='1';
EB0Write[h+2]='0';
EB0Write[h+3]='1';
EB0Write[h+4]='1';
EB0Write[h+5]='0';
break;
}
case 'y': {
EB0Write[h+0]='1';
EB0Write[h+1]='1';
EB0Write[h+2]='0';
EB0Write[h+3]='1';
EB0Write[h+4]='0';
EB0Write[h+5]='1';
break;
}
case 'z': {
EB0Write[h+0]='1';
EB0Write[h+1]='1';
EB0Write[h+2]='0';
EB0Write[h+3]='1';
EB0Write[h+4]='0';
EB0Write[h+5]='0';
break;
}
default: // Inoder To Save the Cache------------ {
switch(InTo[i]) {
case 'Q': {
EB0Write[h+0]='0';
EB0Write[h+1]='0';
EB0Write[h+2]='1';
EB0Write[h+3]='0';
EB0Write[h+4]='0';
EB0Write[h+5]='0';
break;
}
default:
break;
}
}
break;
}
}
//switch(InSide) over
break;
/*-------------------IN switch over--------------------*/
}
//-------OUT switch over-------------------
if(i<=47 || i>=49)
h=h+6; else
h=h+9;
}
// for over
/*---------mihuo-----chidiao------2+3=5--------------------------*/
for (i=0;i<2;i++)
EB0Write[i]='1';
for (i=296;i<299;i++)
EB0Write[i]='1';
/*---------mihuo-----chidiao------over---------------------------*/
}
int ChangeITC_Score(int Sc) {
int i;
int Put[6];
Put[0]=(Sc/100000);
Put[1]=(Sc/10000)%10;
Put[2]=(Sc/1000)%10;
Put[3]=(Sc/100)%10;
Put[4]=(Sc/10)%10;
Put[5]=(Sc/1)%10;
for (i=0;i<6;i++) {
switch(Put[i]) {
case 0:Char_Score[i]='0';
break;
case 1:Char_Score[i]='1';
break;
case 2:Char_Score[i]='2';
break;
case 3:Char_Score[i]='3';
break;
case 4:Char_Score[i]='4';
break;
case 5:Char_Score[i]='5';
break;
case 6:Char_Score[i]='6';
break;
case 7:Char_Score[i]='7';
break;
case 8:Char_Score[i]='8';
break;
case 9:Char_Score[i]='9';
break;
default:break;
}
}
printf("\n");
return 0;
}
/*-----------------------'begin' to write '323' chars---------------*/
int WriteToFile() {
int h;
FILE *fpwrite;
fpwrite=fopen("Game_Data.txt","wb");
if(fpwrite==NULL) {
printf("Can't open the file !!!!!!\n");
printf("Because of you Cache !\n");
return -1;
}
for (h=0;h<323;h++) {
if(fwrite(&EB0Write[h],1,1,fpwrite)!=1)
printf("Can't write to this file <SEEK=%d>!\n",h+1);
if(h==322)printf("write sucess !!!!!!!!!!\n");
}
fclose(fpwrite);
IFRFF=1;
system("pause");
return 0;
}