请问有和我一起做游戏的吗?
要求:懂得c++的大部分语法知识,比较频繁的上线
我现在在做MC铁匠铺传奇。
现在的代码:
#include<bits/stdc++.h>
#include<windows.h>
#define io ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
#define N 15
int c = 0, v = 0;
bool gold, diamond;
struct item {
string name;
int i;
void make(string u) {
name = u;
i = 0;
// printf("\t\tmake item:%s\n", u.c_str());
}
} s[101];
struct synthesistable {
#define maxx 3
string synthesis[maxx][maxx];
string name;
void make(string synthesi[maxx][maxx], string na) {
for (int i = 0; i < maxx; i++)
for (int j = 0; j < maxx; j++)
for (int k = 0; k < N; k++)
synthesis[i][j][k] = synthesi[i][j][k];
name = na;
if (s[v - 1].name != na) s[v++].make(na);
// printf("\t\tmake synthesistable:%s\n", na.c_str());
}
void print() {
printf("name:%s\n", name.c_str());
for (int i = 0; i < maxx; i++) {
for (int j = 0; j < maxx; j++) printf("%s\t\t", synthesis[i][j].c_str());
printf("\n");
}
printf("\n");
}
} synthe[101];
int mon = 0, day = 0;
void makesynttt() {
//iron
string iron_pickaxe[maxx][maxx] = {"iron", "iron", "iron", "air", "stick", "air", "air", "stick", "air"};
synthe[c++].make(iron_pickaxe, "iron_pickaxe");
string iron_axe1[maxx][maxx] = {"air", "iron", "iron", "air", "stick", "iron", "air", "stick", "air"};
synthe[c++].make(iron_axe1, "iron_axe");
string iron_axe2[maxx][maxx] = {"iron", "iron", "air", "iron", "stick", "air", "air", "stick", "air"};
synthe[c++].make(iron_axe2, "iron_axe");
string iron_shovel[maxx][maxx] = {"air", "iron", "air", "air", "stick", "air", "air", "stick", "air"};
synthe[c++].make(iron_shovel, "iron_shovel");
string iron_hoe1[maxx][maxx] = {"iron", "iron", "air", "air", "stick", "air", "air", "stick", "air"};
synthe[c++].make(iron_hoe1, "iron_hoe");
string iron_hoe2[maxx][maxx] = {"air", "iron", "iron", "air", "stick", "air", "air", "stick", "air"};
synthe[c++].make(iron_hoe2, "iron_hoe");
//gold
string gold_pickaxe[maxx][maxx] = {"gold", "gold", "gold", "air", "stick", "air", "air", "stick", "air"};
synthe[c++].make(gold_pickaxe, "gold_pickaxe");
string gold_axe1[maxx][maxx] = {"air", "gold", "gold", "air", "stick", "gold", "air", "stick", "air"};
synthe[c++].make(gold_axe1, "gold_axe");
string gold_axe2[maxx][maxx] = {"gold", "gold", "air", "gold", "stick", "air", "air", "stick", "air"};
synthe[c++].make(gold_axe2, "gold_axe");
string gold_shovel[maxx][maxx] = {"air", "gold", "air", "air", "stick", "air", "air", "stick", "air"};
synthe[c++].make(gold_shovel, "gold_shovel");
string gold_hoe1[maxx][maxx] = {"gold", "gold", "air", "air", "stick", "air", "air", "stick", "air"};
synthe[c++].make(gold_hoe1, "gold_hoe");
string gold_hoe2[maxx][maxx] = {"air", "gold", "gold", "air", "stick", "air", "air", "stick", "air"};
synthe[c++].make(gold_hoe2, "gold_hoe");
//copper
string copper_pickaxe[maxx][maxx] = {"copper", "copper", "copper", "air", "stick", "air", "air", "stick", "air"};
synthe[c++].make(copper_pickaxe, "copper_pickaxe");
string copper_axe1[maxx][maxx] = {"air", "copper", "copper", "air", "stick", "copper", "air", "stick", "air"};
synthe[c++].make(copper_axe1, "copper_axe");
string copper_axe2[maxx][maxx] = {"copper", "copper", "air", "copper", "stick", "air", "air", "stick", "air"};
synthe[c++].make(copper_axe2, "copper_axe");
string copper_shovel[maxx][maxx] = {"air", "copper", "air", "air", "stick", "air", "air", "stick", "air"};
synthe[c++].make(copper_shovel, "copper_shovel");
string copper_hoe1[maxx][maxx] = {"copper", "copper", "air", "air", "stick", "air", "air", "stick", "air"};
synthe[c++].make(copper_hoe1, "copper_hoe");
string copper_hoe2[maxx][maxx] = {"air", "copper", "copper", "air", "stick", "air", "air", "stick", "air"};
synthe[c++].make(copper_hoe2, "copper_hoe");
//diamond
string diamond_pickaxe[maxx][maxx] = {"diamond", "diamond", "diamond", "air", "stick", "air", "air", "stick", "air"};
synthe[c++].make(diamond_pickaxe, "diamond_pickaxe");
string diamond_axe1[maxx][maxx] = {"air", "diamond", "diamond", "air", "stick", "diamond", "air", "stick", "air"};
synthe[c++].make(diamond_axe1, "diamond_axe");
string diamond_axe2[maxx][maxx] = {"diamond", "diamond", "air", "diamond", "stick", "air", "air", "stick", "air"};
synthe[c++].make(diamond_axe2, "diamond_axe");
string diamond_shovel[maxx][maxx] = {"air", "diamond", "air", "air", "stick", "air", "air", "stick", "air"};
synthe[c++].make(diamond_shovel, "diamond_shovel");
string diamond_hoe1[maxx][maxx] = {"diamond", "diamond", "air", "air", "stick", "air", "air", "stick", "air"};
synthe[c++].make(diamond_hoe1, "diamond_hoe");
string diamond_hoe2[maxx][maxx] = {"air", "diamond", "diamond", "air", "stick", "air", "air", "stick", "air"};
synthe[c++].make(diamond_hoe2, "diamond_hoe");
//block
string iron_block[maxx][maxx] = {"iron", "iron", "iron", "iron", "iron", "iron", "iron", "iron", "iron"};
synthe[c++].make(iron_block, "iron_block");
string gold_block[maxx][maxx] = {"gold", "gold", "gold", "gold", "gold", "gold", "gold", "gold", "gold",};
synthe[c++].make(gold_block, "gold_block");
string copper_block[maxx][maxx] = {"copper", "copper", "copper", "copper", "copper", "copper", "copper", "copper", "copper",};
synthe[c++].make(copper_block, "copper_block");
string diamond_block[maxx][maxx] = {"diamond", "diamond", "diamond", "diamond", "diamond", "diamond", "diamond", "diamond", "diamond",};
synthe[c++].make(diamond_block, "diamond_block");
//other
string lightning_rod[maxx][maxx] = {"air", "copper", "air", "air", "copper", "air", "air", "copper", "air"};
synthe[c++].make(lightning_rod, "lightning_rod");
string bucket1[maxx][maxx] = {"iron", "air", "iron", "air", "iron", "air", "air", "air", "air"};
synthe[c++].make(bucket1, "bucket");
string bucket2[maxx][maxx] = {"air", "air", "air", "iron", "air", "iron", "air", "iron", "air"};
synthe[c++].make(bucket2, "bucket");
string stick1[maxx][maxx] = {"air", "plank", "air", "air", "plank", "air", "air", "air", "air"};
synthe[c++].make(stick1, "stick");
string stick2[maxx][maxx] = {"air", "air", "air", "air", "plank", "air", "air", "plank", "air"};
synthe[c++].make(stick2, "stick");
string plank1[maxx][maxx] = { "wood", "air", "air", "air", "air", "air", "air", "air", "air"};
synthe[c++].make(plank1, "plank");
string plank2[maxx][maxx] = { "air", "wood", "air", "air", "air", "air", "air", "air", "air"};
synthe[c++].make(plank2, "plank");
string plank3[maxx][maxx] = { "air", "air", "wood", "air", "air", "air", "air", "air", "air"};
synthe[c++].make(plank3, "plank");
string plank4[maxx][maxx] = { "air", "air", "air", "wood", "air", "air", "air", "air", "air"};
synthe[c++].make(plank4, "plank");
string plank5[maxx][maxx] = { "air", "air", "air", "air", "wood", "air", "air", "air", "air"};
synthe[c++].make(plank5, "plank");
string plank6[maxx][maxx] = { "air", "air", "air", "air", "air", "wood", "air", "air", "air"};
synthe[c++].make(plank6, "plank");
string plank7[maxx][maxx] = { "air", "air", "air", "air", "air", "air", "wood", "air", "air"};
synthe[c++].make(plank7, "plank");
string plank8[maxx][maxx] = { "air", "air", "air", "air", "air", "air", "air", "wood", "air"};
synthe[c++].make(plank8, "plank");
string plank9[maxx][maxx] = { "air", "air", "air", "air", "air", "air", "air", "air", "wood"};
synthe[c++].make(plank9, "plank");
//item
s[v++].make("iron");
s[v++].make("gold");
s[v++].make("copper");
s[v++].make("diamond");
s[v++].make("wood");
}
void write_file() {
fstream f("tjp.dat");
for (int i = 0; i < v; i++) f << s[i].i << ' ';
f << mon << ' ' << day;
}
void read_file() {
// printf("file operations...\n");
fstream f("tjp.dat");
if (!f) {
// printf("\t\tmake file:tjp.dat\n");
// printf("\t\t\tinit...\n\t\t\t\t");
ofstream make("tjp.dat");
for (int i = 0; i < v; i++) {
make << 0 << ' ';
// printf("0 ");
}
make << "\n" << 0 << ' ' << 0 << "\n";
make << "0 0";
// printf("\n\t\t\t\t0 0\n0 0\n");
make.close();
}
for (int i = 0; i < v; i++) f >> s[i].i;
f >> mon >> day;
// printf("\t\tread file...\n\t\tfile:tjp.dat\n");
}
void init() {
// system("cls");
// printf("init...\n");
// printf("\tinit synthesistables and items...\n");
makesynttt();
read_file();
// system("pause");
}
void play();
void print() {
Sleep(1500);
printf("\
\n\
# # # # # ####### ## #### \n\
# # # # # # #### # \n\
# # # # # # # ## # \n\
# # # # # # # ### \n\
# # # # # # # \n\
# # # # # # # \n\
# # # # # # # # \n\
# # # ### ### \n\
\n\
");
Sleep(6666+'y'+'w'+'j');
init();
system("cls");
for (int i = 1; i <= 20; i++) {
printf("-");
Sleep(30);
}
printf("铁");
Sleep(60);
printf("匠");
Sleep(60);
printf("铺");
Sleep(200);
printf("传");
Sleep(200);
printf("奇");
Sleep(60);
for (int i = 1; i <= 20; i++) {
printf("-");
Sleep(30);
}
printf("\n");
for (int i = 1; i <= 30; i++) {
printf(" ");
Sleep(15);
}
string tprint = "by:ywj";
for (int i = 0; i < tprint.length(); i++) {
printf("%c", tprint[i]);
Sleep(80);
}
printf("\n");
xz:
printf("1.使用当前存档\n2.从头开始\n");
int i;
cin >> i;
if (i == 1) play();
else if (i == 2) {
printf("真的吗(y)?");
char t;
cin >> t;
if (t == 'y') {
ofstream make("tjp.dat");
for (int i = 0; i < v; i++) make << 0 << ' ';
make << "\n" << 0 << ' ' << 0 << "\n0 0";
make.close();
printf("已还原!\n");
printf("游戏即将重启,请耐心等待。\n");
Sleep(2000);
system("tjp");
}
goto xz;
} else goto xz;
}
void play() {
system("cls");
printf("天数:%d 钱数:%d\n", day, mon);
xz:
printf("1.开始新的一天\n2.升级\n");
int i;
cin >> i;
if (i == 1);
else if (i == 2);
else goto xz;
}
int main() {
io
system("cls");
CONSOLE_CURSOR_INFO cursor_info = {1, 0};
SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursor_info);
// for (int i = 0; i < c; i++) synthe[i].print();
// for (int i = 0; i < v; i++) printf("%s\n", s[i].name.c_str());
print();
return 0;
}