game1第二版(自制小游戏)
2026-08-27 14:10:23
发布于:河南
本篇game1第二版(自制小游戏)为game1(自制小游戏)的改良版,
主要更改了以下三点:
①画质增强
game1第二版(自制小游戏)增加了防御功能的画质,
添加了新的动画防御效果,
增强游玩体验。
②增加全新功能
game1第二版(自制小游戏)增加了
当“我方人才”是十的倍数时,可查阅敌方信息
的新功能,增加游玩乐趣。
③改正负数bug
game1第二版(自制小游戏)参考了@互关而已✅
和@议建的
改正敌方军马有可能出现负数的bag
总而言之,言而总之,game1第二版(自制小游戏)
已不再是原来的那篇game1(自制小游戏),
好好体验这篇全新的代码吧!
哦,对了:觉得好玩扣1!
#include<iostream>
#include<cstdlib>
#include<ctime>
#include<string>
#include<windows.h>
using namespace std;
void plane(){
cout<<" ###"<<endl;
cout<<"# ###"<<endl;
cout<<"## ###"<<endl;
cout<<"################"<<endl;
cout<<"#################"<<endl;
cout<<" ###"<<endl;
cout<<" ###"<<endl;
cout<<" ###"<<endl;
system("cls");
cout<<" ###"<<endl;
cout<<" # ###"<<endl;
cout<<" ## ###"<<endl;
cout<<" ################"<<endl;
cout<<" #################"<<endl;
cout<<" ###"<<endl;
cout<<" ###"<<endl;
cout<<" ###"<<endl;
system("cls");
cout<<" ###"<<endl;
cout<<" # ###"<<endl;
cout<<" ## ###"<<endl;
cout<<" ################"<<endl;
cout<<" #################"<<endl;
cout<<" ###"<<endl;
cout<<" ###"<<endl;
cout<<" ###"<<endl;
system("cls");
cout<<" ###"<<endl;
cout<<" # ###"<<endl;
cout<<" ## ###"<<endl;
cout<<" ################"<<endl;
cout<<" #################"<<endl;
cout<<" ###"<<endl;
cout<<" ###"<<endl;
cout<<" ###"<<endl;
system("cls");
cout<<" ###"<<endl;
cout<<" # ###"<<endl;
cout<<" ## ###"<<endl;
cout<<" ################"<<endl;
cout<<" #################"<<endl;
cout<<" ###"<<endl;
cout<<" ###"<<endl;
cout<<" ###"<<endl;
system("cls");
cout<<" ###"<<endl;
cout<<" # ###"<<endl;
cout<<" ## ###"<<endl;
cout<<" ################"<<endl;
cout<<" #################"<<endl;
cout<<" ###"<<endl;
cout<<" ###"<<endl;
cout<<" ###"<<endl;
system("cls");
cout<<" ###"<<endl;
cout<<" # ###"<<endl;
cout<<" ## ###"<<endl;
cout<<" ################"<<endl;
cout<<" #################"<<endl;
cout<<" ###"<<endl;
cout<<" ###"<<endl;
cout<<" ###"<<endl;
system("cls");
cout<<" ###"<<endl;
cout<<" # ###"<<endl;
cout<<" ## ###"<<endl;
cout<<" ################"<<endl;
cout<<" #################"<<endl;
cout<<" ###"<<endl;
cout<<" ###"<<endl;
cout<<" ###"<<endl;
system("cls");
cout<<" ###"<<endl;
cout<<" # ###"<<endl;
cout<<" ## ###"<<endl;
cout<<" ################"<<endl;
cout<<" #################"<<endl;
cout<<" ###"<<endl;
cout<<" ###"<<endl;
cout<<" ###"<<endl;
system("cls");
cout<<" ###"<<endl;
cout<<" # ###"<<endl;
cout<<" ## ###"<<endl;
cout<<" ################"<<endl;
cout<<" #################"<<endl;
cout<<" ###"<<endl;
cout<<" ###"<<endl;
cout<<" ###"<<endl;
system("cls");
cout<<" ###"<<endl;
cout<<" # ###"<<endl;
cout<<" ## ###"<<endl;
cout<<" ################"<<endl;
cout<<" #################"<<endl;
cout<<" ###"<<endl;
cout<<" ###"<<endl;
cout<<" ###"<<endl;
system("cls");
cout<<" ###"<<endl;
cout<<" # ###"<<endl;
cout<<" ## ###"<<endl;
cout<<" ################"<<endl;
cout<<" #################"<<endl;
cout<<" ###"<<endl;
cout<<" ###"<<endl;
cout<<" ###"<<endl;
system("cls");
cout<<" ###"<<endl;
cout<<" # ###"<<endl;
cout<<" ## ###"<<endl;
cout<<" ################"<<endl;
cout<<" #################"<<endl;
cout<<" ###"<<endl;
cout<<" ###"<<endl;
cout<<" ###"<<endl;
system("cls");
cout<<" ###"<<endl;
cout<<" # ###"<<endl;
cout<<" ## ###"<<endl;
cout<<" ################"<<endl;
cout<<" #################"<<endl;
cout<<" ###"<<endl;
cout<<" ###"<<endl;
cout<<" ###"<<endl;
system("cls");
cout<<" ###"<<endl;
cout<<" # ###"<<endl;
cout<<" ## ###"<<endl;
cout<<" ################"<<endl;
cout<<" #################"<<endl;
cout<<" ###"<<endl;
cout<<" ###"<<endl;
cout<<" ###"<<endl;
system("cls");
cout<<" ###"<<endl;
cout<<" # ###"<<endl;
cout<<" ## ###"<<endl;
cout<<" ################"<<endl;
cout<<" #################"<<endl;
cout<<" ###"<<endl;
cout<<" ###"<<endl;
cout<<" ###"<<endl;
system("cls");
cout<<" ###"<<endl;
cout<<" # ###"<<endl;
cout<<" ## ###"<<endl;
cout<<" #############"<<endl;
cout<<" #############"<<endl;
cout<<" ###"<<endl;
cout<<" ###"<<endl;
cout<<" ###"<<endl;
system("cls");
cout<<" ###"<<endl;
cout<<" # ##"<<endl;
cout<<" ## #"<<endl;
cout<<" #########"<<endl;
cout<<" #########"<<endl;
cout<<" ##"<<endl;
cout<<" ###"<<endl;
cout<<" ###"<<endl;
system("cls");
cout<<endl;
cout<<" #"<<endl;
cout<<" ##"<<endl;
cout<<" #####"<<endl;
cout<<" #####"<<endl;
system("cls");
cout<<endl;
cout<<" #"<<endl;
cout<<" #"<<endl;
cout<<" #"<<endl;
cout<<" #"<<endl;
system("cls");
}
void planef(){
cout<<" ###"<<endl;
cout<<"# ###"<<endl;
cout<<"## ###"<<endl;
cout<<"################"<<endl;
cout<<"#################"<<endl;
cout<<" ###"<<endl;
cout<<" ###"<<endl;
cout<<" ###"<<endl;
system("cls");
cout<<" ###"<<endl;
cout<<" # ###"<<endl;
cout<<" ## ###"<<endl;
cout<<" ################"<<endl;
cout<<" #################"<<endl;
cout<<" ###"<<endl;
cout<<" ###"<<endl;
cout<<" ###"<<endl;
system("cls");
cout<<" ###"<<endl;
cout<<" # ###"<<endl;
cout<<" ## ###"<<endl;
cout<<" ################"<<endl;
cout<<" #################"<<endl;
cout<<" ###"<<endl;
cout<<" ###"<<endl;
cout<<" ###"<<endl;
system("cls");
cout<<" ###"<<endl;
cout<<" # ###"<<endl;
cout<<" ## ###"<<endl;
cout<<" ################"<<endl;
cout<<" #################"<<endl;
cout<<" ###"<<endl;
cout<<" ###"<<endl;
cout<<" ###"<<endl;
system("cls");
cout<<" ###"<<endl;
cout<<" # ###"<<endl;
cout<<" ## ###"<<endl;
cout<<" ################"<<endl;
cout<<" #################"<<endl;
cout<<" ###"<<endl;
cout<<" ###"<<endl;
cout<<" ###"<<endl;
system("cls");
cout<<" ###"<<endl;
cout<<" # ###"<<endl;
cout<<" ## ###"<<endl;
cout<<" ################"<<endl;
cout<<" #################"<<endl;
cout<<" ###"<<endl;
cout<<" ###"<<endl;
cout<<" ###"<<endl;
system("cls");
cout<<" ###"<<endl;
cout<<" # ###"<<endl;
cout<<" ## ###"<<endl;
cout<<" ################"<<endl;
cout<<" #################"<<endl;
cout<<" ###"<<endl;
cout<<" ###"<<endl;
cout<<" ###"<<endl;
system("cls");
cout<<" ###"<<endl;
cout<<" # ###"<<endl;
cout<<" ## ###"<<endl;
cout<<" ################"<<endl;
cout<<" #################"<<endl;
cout<<" ###"<<endl;
cout<<" ###"<<endl;
cout<<" ###"<<endl;
system("cls");
cout<<" ###"<<endl;
cout<<" # ###"<<endl;
cout<<" ## ###"<<endl;
cout<<" ################"<<endl;
cout<<" #################"<<endl;
cout<<" ###"<<endl;
cout<<" ###"<<endl;
cout<<" ###"<<endl;
system("cls");
cout<<" ###"<<endl;
cout<<" # ###"<<endl;
cout<<" ## ###"<<endl;
cout<<" ################"<<endl;
cout<<" #################"<<endl;
cout<<" ###"<<endl;
cout<<" ###"<<endl;
cout<<" ###"<<endl;
system("cls");
cout<<" ###"<<endl;
cout<<" # ###"<<endl;
cout<<" ## ###"<<endl;
cout<<" ################"<<endl;
cout<<" #################"<<endl;
cout<<" ###"<<endl;
cout<<" ###"<<endl;
cout<<" ###"<<endl;
system("cls");
cout<<" ###"<<endl;
cout<<" # ###"<<endl;
cout<<" ## ###"<<endl;
cout<<" ################"<<endl;
cout<<" #################"<<endl;
cout<<" ###"<<endl;
cout<<" ###"<<endl;
cout<<" ###"<<endl;
system("cls");
cout<<" ###"<<endl;
cout<<" # ###"<<endl;
cout<<" ## ###"<<endl;
cout<<" ################"<<endl;
cout<<" #################"<<endl;
cout<<" ###"<<endl;
cout<<" ###"<<endl;
cout<<" ###"<<endl;
system("cls");
cout<<" ###"<<endl;
cout<<" # ###"<<endl;
cout<<" ## ###"<<endl;
cout<<" ################"<<endl;
cout<<" #################"<<endl;
cout<<" ###"<<endl;
cout<<" ###"<<endl;
cout<<" ###"<<endl;
system("cls");
cout<<" ###"<<endl;
cout<<" # ###"<<endl;
cout<<" ## ###"<<endl;
cout<<" ################ |"<<endl;
cout<<" #################|"<<endl;
cout<<" ###"<<endl;
cout<<" ###"<<endl;
cout<<" ###"<<endl;
system("cls");
cout<<" ###"<<endl;
cout<<" # ###"<<endl;
cout<<" ## ###"<<endl;
cout<<" #############|"<<endl;
cout<<" #############|"<<endl;
cout<<" ###"<<endl;
cout<<" ###"<<endl;
cout<<" ###"<<endl;
system("cls");
cout<<" ###|"<<endl;
cout<<" # ##|"<<endl;
cout<<" ## #|"<<endl;
cout<<" #########|"<<endl;
cout<<" #########|"<<endl;
cout<<" ##|"<<endl;
cout<<" ###|"<<endl;
cout<<" ###"<<endl;
Sleep(600);
system("cls");
}
void number(){
for(int i=0;i<=10;i++){
cout<<"010101010101010101010101010101010101"<<endl;
cout<<"101010101010101010101010101010101010"<<endl;
cout<<"010101010101010101010101010101010101"<<endl;
cout<<"101010101010101010101010101010101010"<<endl;
cout<<"010101010101010101010101010101010101"<<endl;
system("cls");
cout<<"101010101010101010101010101010101010"<<endl;
cout<<"010101010101010101010101010101010101"<<endl;
cout<<"101010101010101010101010101010101010"<<endl;
cout<<"010101010101010101010101010101010101"<<endl;
cout<<"101010101010101010101010101010101010"<<endl;
system("cls");
}
}
void numberf(){
for(int i=0;i<=2;i++){
cout<<"010101010101010101010101010101010101"<<endl;
cout<<"101010101010101010101010101010101010"<<endl;
cout<<"010101010101010101010101010101010101"<<endl;
cout<<"101010101010101010101010101010101010"<<endl;
cout<<"010101010101010101010101010101010101"<<endl;
system("cls");
cout<<"101010101010101010101010101010101010"<<endl;
cout<<"010101010101010101010101010101010101"<<endl;
cout<<"101010101010101010101010101010101010"<<endl;
cout<<"010101010101010101010101010101010101"<<endl;
cout<<"101010101010101010101010101010101010"<<endl;
system("cls");
}
system("cls");
cout<<"010101010101010101010101010101010101"<<endl;
cout<<"101010101010101010101010101010101010"<<endl;
cout<<"0101010101010101 101010101010101"<<endl;
cout<<"101010101010101010101010101010101010"<<endl;
cout<<"010101010101010101010101010101010101"<<endl;
Sleep(100);
system("cls");
cout<<"101010101010101010101010101010101010"<<endl;
cout<<"01010101 1010101"<<endl;
cout<<"10101010 0101010"<<endl;
cout<<"01010101 1010101"<<endl;
cout<<"101010101010101010101010101010101010"<<endl;
Sleep(100);
system("cls");
cout<<"101010101010101010101010101010101010"<<endl;
cout<<"01 01"<<endl;
cout<<"10 10"<<endl;
cout<<"01 01"<<endl;
cout<<"101010101010101010101010101010101010"<<endl;
Sleep(100);
system("cls");
}
int main(){
int dx=100,wx=100,dr=5,wr=5;
float dj=5,wj=5;
string a;
cout<<"游戏现在开始!"<<endl;
cout<<"按下G键攻击,F键防守,H键回血,Z键招揽军马人才!"<<endl;
system("pause");
system("cls");
cout<<"你先来!"<<endl;
system("pause");
system("cls");
for(int i=1;i<=10;i++){
srand(time(NULL));
cout<<"我方血量:"<<wx<<endl;
cout<<"我方人才:"<<wr<<endl;
cout<<"我方军马:"<<wj<<"W"<<endl;
cin>>a;
if(a=="g"||a=="f"){
cout<<"开局前10回合不能使用“攻击 ”或 “防御 ”";
i--;
system("pause");
system("cls");
}else if(a=="h"){
wx+=2;
system("cls");
}else if(a=="z"){
wr=wr+rand()%5+1;
wj=wj+0.2;
cout<<"已招揽军马人才"<<endl;
system("pause");
system("cls");
}else{
cout<<"按下G键攻击,F键防守,H键回血,Z键招揽军马人才!"<<endl;
i--;
system("pause");
system("cls");
}
srand(time(NULL));
int d=rand()%4+1;
switch(d){
case 1:
case 2:
dx+=2;
break;
case 3:
case 4:
srand(time(NULL));
dr=dr+rand()%5+1;
dj=dj+0.2;
}
}
while(1){
if(dx<=0){
system("cls");
cout<<"恭喜你,你赢了!"<<endl;
break;
}else if(wx<=0){
system("pause");
system("cls");
cout<<"真遗憾,你输了"<<endl;
break;
}
cout<<"我方血量:"<<wx<<endl;
cout<<"我方人才:"<<wr<<endl;
cout<<"我方军马:"<<wj<<"W"<<endl;
if(wr%10==0){
cout<<"恭喜你,我方人才是十的倍数,可查看敌方信息!";
system("pause");
system("cls");
cout<<endl;
cout<<"敌方血量:"<<dx<<endl;
cout<<"敌方人才:"<<dr<<endl;
cout<<"敌方军马:"<<dj<<"W"<<endl;
}
cin>>a;
if(a=="g"){
srand(time(NULL));
int dd=rand()%2+1;
if(dd==1 && dr>=15){
wj-=0.05;
dj-=0.02;
if(dj<0){
dj=0;
}
if(wj>=0.05){
cout<<"攻击!!!"<<endl;
numberf();
cout<<"对手防住了"<<endl;
}else{
cout<<"军马不够!"<<endl<<"损失一次机会!";
}
system("pause");
system("cls");
}else{
dx-=5;
dj-=0.2;
wj-=0.05;
if(dj<0){
dj=0;
}
if(wj>=0.05){
number();
cout<<"攻击!!!"<<endl;
cout<<"成功!!!"<<endl<<"已将对手血量减5"<<endl;
system("pause");
system("cls");
}else{
cout<<"军马不够!"<<endl<<"损失一次机会!";
}
}
}else if(a=="f"){
cout<<"对手未攻击时不能使用“防御 ”"<<endl;
cout<<"损失一次机会!"<<endl;
system("pause");
system("cls");
}else if(a=="h"){
wx+=2;
system("cls");
}else if(a=="z"){
wr=wr+rand()%5+1;
wj=wj+0.2;
cout<<"已招揽军马人才"<<endl;
system("pause");
system("cls");
}else{
cout<<"按下G键攻击,F键防守,H键回血,Z键招揽军马人才!"<<endl;
cout<<"损失一次机会!"<<endl;
system("pause");
system("cls");
}
srand(time(NULL));
int d=rand()%4+1;
switch(d){
case 1:
if(dj>=0.05){
dj-=0.05;
cout<<"警告!"<<endl;
cout<<"敌方攻击!"<<endl;
cin>>a;
if(a=="f"){
planef();
cout<<"完美防守!"<<endl;
wj-=0.02;
system("pause");
system("cls");
} else {
plane();
cout<<"糟糕!!"<<endl;
wx-=5;
system("pause");
system("cls");
}
}else{
srand(time(NULL));
dr=dr+rand()%5+1;
dj=dj+0.2;
}
break;
case 2:
dx+=2;
break;
case 3:
break;
case 4:
srand(time(NULL));
dr=dr+rand()%5+1;
dj=dj+0.2;
}
}
return 0;
}
全部评论 1
- 置顶
建议使用编译器DEV-C++体验效果更佳,
如果觉得还可以请回1。
如有疑问或建议欢迎留言!昨天 来自 河南
0













有帮助,赞一个