我是靠谱客的博主 漂亮小松鼠,最近开发中收集的这篇文章主要介绍用Java时写的第一个小小RPG游戏程序(第一版),觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

package com.rmsi.game;
public class TestGame
{
public static void main(String[] args)
{
int i=0;
Hunter hunter = new Hunter();
Monster monster = new Monster();
for(i=0;;i++)
{i+=1;
System.out.println("n第"+i+"回合战斗开始");
hunter.fight(monster);
System.out.println("第"+i+"回合战斗结束");
System.out.println("战斗统计");
hunter.show();
monster.show();
i-=1;
if(monster.life<=0)
{break;
}
}
monster.isLive=false;
System.out.println("n战胜方是"+hunter.name);
System.out.println("n战争统计");
i+=1;
System.out.println(hunter.name+"与"+ monster.type+"战斗"+i+"次");
}
}
package com.rmsi.game;
public class Monster
{
public String type="吸血鬼";
public int life=1000;
public boolean isLive=true;
public void injured()
{
System.out.println(this.type+"被打中了");
this.life -= 100;
}
public void show()
{
System.out.println(this.type+"还有"+this.life+"点血");
//	System.out.println(this.isLive);
}
}

package com.rmsi.game;
public class Hunter
{
public String name = "戰士";
public int life = 1000;
public String weapon = "屠龙刀";
public boolean isLive = true;
public void fight(Monster monster)
{
System.out.println(this.name + "手持" + this.weapon+"杀向"+monster.type);
monster.injured();
}
public void show()
{
//	System.out.println(this.life);
//System.out.println(this.isLive);
}
}

怀念过去学习的日子。

最后

以上就是漂亮小松鼠为你收集整理的用Java时写的第一个小小RPG游戏程序(第一版)的全部内容,希望文章能够帮你解决用Java时写的第一个小小RPG游戏程序(第一版)所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(39)

评论列表共有 0 条评论

立即
投稿
返回
顶部