因为从零基础开始学习的,刚开始学习没多少时间,所以会的不多,就分享一个在第五天写的很小很小很简单很简单的游戏;
public class Game01 {
public static void main(String[] args) {
Random ra = new Random();
int a = ra.nextInt(500)+301;
System.out.println("Boss血量初始是: "+a);
int c = 20;
int g = 500;
int i = 100;
System.out.println("冒险者你的初始血量是:"+g+" 你的攻击力是: "+c+" 初始蓝量是: "+i);
while(true) {
int h = ra.nextInt(20)+20;
Scanner sc =new Scanner(System.in);
System.out.println("选择你要进行行动 1: 斩击 2:旋风斩 3:舍命一击 4: 格挡");
int b = sc.nextInt();
if(b==1) {
a = a-c;
g = g -20;
System.out.println("你对Boss造成"+c+"点伤害"+" Boss剩余血量"+a+" 你的剩余血量"+g);
}else if(b==2) {
i = i-30;
if(i>=0){
int d = ra.nextInt(20)+10;
a = a-d;
g = g -20;
System.out.println("你对Boss造成"+d+"点伤害"+" Boss剩余血量"+a+" 你的剩余血量"+g);
}else{
System.out.println("蓝量不足");
}
}else if(b==3) {
i = i-70;
if(i>=0){
int e = ra.nextInt(20)+60;
a = a-e;
g = g -20;
System.out.println("你对Boss造成"+e+"点伤害"+" Boss剩余血量"+a+" 你的剩余血量"+g);
}else{
System.out.println("蓝量不足");
}
}else if(b==4) {
int f = ra.nextInt(10)+1;
if(f<2){
g=g-h;
}
System.out.println("冒险者剩余血量 "+g+" Boss剩余血量"+a);
}else{
System.out.println("选择你的行动");
}
i = i + 10;
if(a<=0&&g>0) {
System.out.println("恭喜你胜利了");
break;
}else if(a>0&&g<=0){
System.out.println("Geme Over");
break;
}else{
}
}
}
}
|
|