一些简单的代码(自行复制使用,最好不复制哈,gan'xi...
#include<bits\stdc++.h>#include<conio.h>
#include <stdio.h>
#include<unistd.h>
#include <windows.h>
#include <time.h>
#include<cstdio>
using namespace std;
int key,lv,sword_lv,armet_lv,breastplate_lv,cuish_lv,boot_lv,evolution_stone,super_evolution_stone,glint_super_evolution_stone,oracle_super_evolution_stone,god_super_evolution_stone,money,reward_lv,job;
string name,sword,armet,breastplate,cuish,boot,reward;
string sword_name={"木剑","石剑","铁剑","钻石剑","闪剑","天剑","圣剑","神剑","元素剑"};
string reward_list={"拯救格亚",""};
string principal_line={"帮助村长","前往历练","通过试练1","接一个悬赏","完成一个悬赏","抵御狼群","回村","通过试炼2","转职"};
string job_list={"战士","剑士","狂战士","骑士","坦克","召唤师","弓箭手","骑射手","法师","巫师","刺客","忍者","牧师","祭祀"};
int l_monster,w_monster,direction;
void clear(){
system("cls");
}
int safe(){
ofstream ofile;
ofile.open("zhmc.tq");
ofile<<lv<<name<<sword<<sword_lv<<armet<<armet_lv<<breastplate<<breastplate_lv<<cuish<<cuish_lv<<boot<<boot_lv<<evolution_stone<<super_evolution_stone<<glint_super_evolution_stone<<oracle_super_evolution_stone<<god_super_evolution_stone<<money<<reward<<reward_lv<<job;
ofile.close();
}
int wars(){
if(lv<=10){
cout<<"1.普攻";
}
}
int buy_sword(){
clear();
cout << "1.木剑 2.石剑 3.铁剑 4.钻石剑5.闪剑 6.天剑7.圣剑8.神剑9.元素剑0.离开";
key=_getch();
key=char(key)-'0';
if(key>0&&key<10){
if(money>=10*pow(10,key)){
sword=sword_name;
sword_lv=1+sword_lv/10;
cout << endl << "购买成功"<<endl;
system("pause");
buy_sword();
return 0;
}
else{
cout << endl << "购买失败"<<endl;
system("pause");
buy_sword();
return 0;
}
}
else{
safe();
return 0;
}
}
int shop(){
clear();
cout << "你要买什么?"<<endl;
cout << "1.剑 2.经验丹 3.装备 4.石头(特殊) 5.保存0.离开";
key=_getch();
if(char(key)=='1'){
buy_sword();
shop();
return 0;
}
}
int reward_f(){
clear();
if(reward=="无"){
}
}
int index(){
clear();
cout << "欢迎来到天启小镇";
sleep(1);
clear();
cout << "你要干什么"<<endl;
cout << "1.去商店 2.去悬赏台 3.回家 4.外出游历 5.去刷怪塔 6.到处逛逛(可获得主线任务或者交付主线任务)";
key=_getch();
if(char(key)=='1'){
shop();
index();
return 0;
}
if(char(key)=='2'){
shop();
index();
return 0;
}
}
int main(){
cout << " 开始游戏" << endl;
cout << " (按下A键开始)"<<endl;
while(!(char(key) == 'a' || char(key) == 'A')){
key = _getch();
}
clear();
ifstream ifile;
ifile.open("zhmc.tq");
ifile>>lv>>name>>sword>>sword_lv>>armet>>armet_lv>>breastplate>>breastplate_lv>>cuish>>cuish_lv>>boot>>boot_lv>>evolution_stone>>super_evolution_stone>>glint_super_evolution_stone>>oracle_super_evolution_stone>>god_super_evolution_stone>>money>>reward>>reward_lv>>job;
if(lv==0)
{
ofstream ofile;
ofile.open("zhmc.tq");
ofile<<1<<" "<<"无"<<" "<<"无"<<" "<<0<<" "<<"无"<<" "<<0<<" "<<"无"<<" "<<0<<" "<<"无"<<" "<<0<<" "<<"无"<<" "<<0<<" "<<0<<" "<<0<<" "<<0<<" "<<0<<" "<<0<<" "<<0<<" "<<"无"<<" "<<0<<" "<<0;
ofile.close();
return 0;
}
if(name=="无"){
clear();
cout << "请输入你的名字:" << endl;
cin >> name;
safe();
}
clear();
index();
return 0;
}
页:
[1]