本次仅为代码更新 会CE 一定有运行时错误
哪位大佬指点一下结构体数组怎么用 谢谢~
下面就是代码了
//Self_Made "Harry Potter" Game in C++
//Version 0.1.2 beta
#include<bits/stdc++.h>
#include<windows.h>
using namespace std;
slowout(string s,int a){
for(int i=0;i<a;i++){
cout<<s[i];
Sleep(100);
}
return 0;
}
void gotoxy(HANDLE hOut, int x, int y)//移动光标
{
COORD pos;
pos.X = x; //横坐标
pos.Y = y; //纵坐标
SetConsoleCursorPosition(hOut, pos);
}
void middle(char str[],int y)
{
HANDLE hOutput = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_SCREEN_BUFFER_INFO bInfo;
GetConsoleScreenBufferInfo(hOutput, &bInfo);
int dwSizeX=bInfo.dwSize.X,dwSizey=bInfo.dwSize.Y;//获取控制台屏幕缓冲区大小
int len=strlen(str);//获取要输出的字符串的长度
int x=dwSizeX/2-len/2;
gotoxy(hOutput,x,y);//移动光标
slowout(str,len);
}
struct Magic{
string name;
int harm;
int cure;
int magicnum;
int control;
};
Magic magic[10];
int magicout(magic){
cout<<"控制为1 指绑 控制为2 指绑架且昏迷"<<endl;
Sleep(1000);
for(int i=1;i<=5;i++){
cout<<"咒语名称:"<<magic[i].name<<endl;
Sleep(1000);
cout<<"伤害:"<<magic[i].harm<<endl;
Sleep(1000);
cout<<"治疗量(负的是扣血量):"<<magic[i].cure<<endl;
Sleep(1000);
cout<<"魔力消耗:"<<magic[i].magicnum<<endl;
Sleep(1000);
cout<<"控制状态:"<<magic[i].control<<endl;
Sleep(5000);
system("cls");
}
system("cls");
}
int main(){
slowout("Welcome to this magic world",27);
cout<<endl;
Sleep(500);
slowout("Please wait a minute",20);
Sleep(2000);
cout<<endl;
system("pause");
system("cls");
for(int i=0;i<3;i++) {
middle("<-------------->",7);
system("cls");
}
cout<<endl;
Sleep(250);
system("cls");
slowout("Choose your camp",16);
cout<<endl;
slowout("1.Voldemort",11);
cout<<" ";
slowout("2.Harry Potter",14);
int camp;
cout<<endl;
cout<<" You will be in Voldemort camp if you print 1 "<<endl<<"you will be in Harry Potter's camp if you print 2"<<endl<<"print your choose on here-> ";
cin>>camp;
int x=MessageBox(GetForegroundWindow(),"你确定吗? 取消将退出游戏","温馨提示",1);
if(x!=1){
slowout("Goodbye",7);
Sleep(1000);
cout<<endl;
system("pause");
return 0;
}
else if(camp>1||camp<0){
cout<<"选择阵营时出现输入错误 我们为您退出游戏 否则后面将会冒出巨大的bug哦~"<<endl;
Sleep(1000);
system("pause");
return 0;
}
if(camp==1){
magic[1].name="钻心咒";
magic[2].name="阿瓦达索命";
magic[3].name="夺魂咒";
magic[4].name="默默然";
magic[5].name="火盾护身";
magic[1].harm=650;
magic[2].harm=500;
magic[3].harm=200;
magic[4].harm=400;
magic[5].harm=200;
magic[1].cure=0;
magic[2].cure=0;
magic[3].cure=0;
magic[4].cure=-100;
magic[5].cure=50;
magic[1].magicnum=5;
magic[2].magicnum=6;
magic[3].magicnum=3;
magic[4].magicnum=5;
magic[5].magicnum=5;
magic[1].control=0;
magic[2].control=0;
magic[3].control=2;
magic[4].control=1;
magic[5].control=1;
}
return 0;
}
以上就是本期所有内容了 谢谢
希望各位大佬们点个赞👍吧!!!求求啦~~~
关注+点赞超过100个立马更新哦!
版权声明:本文为CSDN博主「ian20120124_」的原创文章,如需转载,请通知CSDN博主「ian20120124_」。