一个小型的文字游戏,这是在大学的时候整蛊室友编写的,语句都是我们刚刚学完,所以比较简单,有能力的可以拿去玩一下。
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
int monster_one(int p_xue,int p_blue,int *p_money,int *p_grade,int p_skill_1,int p_skill_2)
{
int gongji,xue = p_xue,blue = p_blue;/
int gongji1 = p_skill_1;///
int gongji2 = p_skill_2;
int monster_one_xue;
printf("怪物名称:刘露\n怪物血量;200\n怪物攻击:10\n");
for(monster_one_xue=200;monster_one_xue>0 && xue > 0;xue-=10)
{
printf("请选择攻击技能:\n1、普通攻击 \t伤害:%d\t蓝量+1\n2、焊烙铁攻击\t伤害:%d\t蓝量-5\n",gongji1,gongji2);
scanf("%d",&gongji);
if(gongji == 1 && xue > 0)
{
monster_one_xue = monster_one_xue - gongji1;
blue++;
printf("刘露血量-%d\\n",p_skill_1);
printf("刘露攻击了你,您的血量-10\t蓝量+1\n");
printf("刘露剩余血量%d\t您剩余的血量%d\t蓝量%d\n",monster_one_xue,xue,blue);
}
else if(gongji == 2 && xue > 0)
{
if(blue >= 5)
{
monster_one_xue -= gongji2;
blue -= 5;
printf("刘露血量-%d\n",p_skill_2);
printf("刘露攻击了你,您的血量-10\t蓝量-5\n");
printf("刘露剩余血量%d\t您剩余的血量%d\t蓝量%d\n",monster_one_xue,xue,blue);
}
else
printf("您的蓝量不足!\n");
}
}
// for(i=0;i<0;i-+5)
//结算
if(monster_one_xue <= 0)
{
*p_money+=200; //金币+200
*p_grade+=1; //等级+1
printf("恭喜你击败了丑陋的怪物:刘露\n您的金币+200!等级+1\n\n\n");
}
else
printf("打怪失败请继续努力升级哦!\n\n");
}
int monster_two(int p_xue,int p_blue,int *p_money,int *p_grade,int p_skill_1,int p_skill_2)
{
int gongji,xue = p_xue,blue = p_blue;//
int gongji1 = p_skill_1;
int gongji2 = p_skill_2;
int monster_two_xue;
printf("怪物名称:刘露进化体\n怪物血量;1000\n怪物攻击:50\n");
for(monster_two_xue=1000;monster_two_xue>0 && xue > 0;xue-=50)
{
printf("请选择攻击技能:\n1、普通攻击 \t伤害:%d\t蓝量+1\n2、焊烙铁攻击\t伤害:%d\t蓝量-5\n",gongji1,gongji2);
scanf("%d",&gongji);
if(gongji == 1 && xue > 0)
{
monster_two_xue = monster_two_xue - gongji1;
blue++;
printf("刘露进化体血量-%d\n",p_skill_1);
printf("刘露进化体攻击了你,您的血量-50\t蓝量+1\n");
printf("刘露进化体剩余血量%d\t您剩余的血量%d\t蓝量%d\n",monster_two_xue,xue,blue);
}
else if(gongji == 2 && xue > 0)
{
if(blue >= 5)
{
monster_two_xue -= gongji2;
blue -= 5;
printf("刘露进化体血量-%d\n",p_skill_2);
printf("刘露进化体攻击了你,您的血量-50\t蓝量-5\n");
printf("刘露进化体剩余血量%d\t您剩余的血量%d\t蓝量%d\n",monster_two_xue,xue,blue);
}
else
printf("您的蓝量不足!\n");
}
}
//结算
if(monster_two_xue <= 0)
{
*p_money+=1000; //金币+1000
*p_grade+=10; //等级+10
printf("恭喜你击败了丑陋的怪物:刘露进化体\n您的金币+1000!等级+10\n\n\n");
}
else
printf("打怪失败请继续努力升级哦!\n\n");
}
//游戏加载调用
void deng(long number)
{
long i=0,j=0;
for(i=0;i<number;i++)
for(j=0;j<number;j++)
;
}
//游戏加载动画
int load(int time)
{
int i;
printf("\n\n\n\n\n游戏正在加载中.");
for(i=1;i<time;i++)
{
deng(10000);
printf(" .");
if(i%7==0)
{
system("cls");
printf("\t\t\n\n\n\n\n游戏正在加载中.");
}
}
system("cls");
}
int asd()
{
}
int main()
{
//初始化人物的信息
int admin_xue = 240; //人物血量
int admin_blue = 20; //人物蓝量
int admin_grade = 1; //人物等级
int admin_skill_1 = 10; //普通攻击
int admin_skill_2 = 20; //焊烙铁攻击
int admin_money = 100; //人物金钱
int scene; //场景选择
int guaiwu; //怪物选择
int buy_eqment; //购买商品选择
//都做成指针打怪的时候方便调用
// int *p_xue = admin_xue;/
// int *p_blue = admin_blue;/
int *p_money = &admin_money;
int *p_grade = &admin_grade;
// int *p_skill_1 = admin_skill_1;//
// int *p_skill_2 = admin_skill_2;//
int bye = 1; //游戏退出设置
//游戏加载中。。。
system("color 17"); //修改字体颜色以及背景颜色
system("mode con cols=80 lines=40 ");//修改界面大小
load(5);
//提示模块
printf("\n欢迎来到暴打刘露游戏\n请选择你要进入的场景:\n\n");
while(bye)
{
printf("1、装备商店\n\n2、冒险打怪\n\n3、个人信息查看\n\n4、退出游戏\n\n5、清理屏幕\n\n");
//场景选择
scene=4;
scanf("%d",&scene);
// if(scene<0&&scene>5)
// {
// scene = 5;
// }
switch(scene)
{
case 1:
printf("欢迎您来到装备商城!\n客观你看想要点啥?\n");
printf("1、短 剑:攻击+5 售价:100金币\n2、护 甲:血量+10 售价:100金币\n3、蓝宝石:蓝量+20 售价:200金币\n");
scanf("%d",&buy_eqment);
if(buy_eqment==1)
{
if(admin_money>=100)
{
printf("共喜您购买短剑成功!普通攻击+5\n");
admin_skill_1+=5;
admin_money-=100;
}
else
printf("您的金币不足!!!\n");
}
else if(buy_eqment==2)
{
if(admin_money>=100)
{
printf("共喜您购买护甲成功!基础血量+10\n");
admin_xue+=10;
admin_money-=100;
}
else
printf("您的金币不足!!!\n");
}
else if(buy_eqment==3)
{
if(admin_money>=200)
{
printf("共喜您购买蓝宝石成功!基础蓝量+20\n");
admin_blue+=20;
admin_money-=200;
}
else
printf("您的金币不足!!!\n");
}
else
printf("不好意思客官展示没有其他商品!!\n");
break;
case 2:
printf("\n\n请选择挑战的怪物:");
printf("\n1、刘露\n2、刘露进化体\n") ;
scanf("%d",&guaiwu);
if(guaiwu==1)
monster_one(admin_xue,admin_blue,p_money,p_grade,admin_skill_1,admin_skill_2);
else if(guaiwu==2)
monster_two(admin_xue,admin_blue,p_money,p_grade,admin_skill_1,admin_skill_2);
break;
case 3:
printf("\n\n人物名称;刘露的爸比\n");
printf("基础血量:%d\t",admin_xue);
printf("基础蓝量:%d\t",admin_blue);
printf("金钱剩余:%d\t",admin_money);
printf("人物等级:%d\n",admin_grade);
printf("攻击技能拥有;\n(1):普通攻击 伤害:%d点 蓝量+1\n(2):焊烙铁攻击 伤害:%d点 蓝量-5\n\n",admin_skill_1,admin_skill_2);
break;
case 4:printf("感谢您的试玩!再见");
bye = 0;
break;
case 5:system("cls");
break;
default:
{
printf("输入有误哈!!\n");
// bye=0;
}
}
}
return 0;
}