很简单的小游戏
import javax.swing.JOptionPane;
public class GameWithNumbers_GroupProject
{
public static void main(String[] args)
{
//Create buttons for you to choose the game.
Object[] options ={ "Game fight", "Find mere", "Guess numbers","Quit" };
int button = JOptionPane.showOptionDialog(null, "Which action you want to do next?", "Combat Control Panel",
JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]);
if (button == JOptionPane.YES_OPTION)
{
{
Object[] options1 ={ "Attack", "Heal", "Quit" };
int myap = 0 ;
int enap = 0 ;
int myhp = 500;
int enemyhp = 500;
JOptionPane.showMessageDialog(null, "This is a Fighting Game \nYou and your enemy both have 500 blood \nYou can choose attack your enemy or heal yourself next");
while (myhp > 0 && enemyhp > 0){
int myattack = (int)(Math.random()*100);
int enemyattack = (int)(Math.random()*100);
int myheal = (int)(Math.random()*50);
int enemyheal = (int)(Math.random()*50);
int i = JOptionPane.showOptionDialog(null, "Which action you want to do next?", "Combat Control Panel",JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options1, options[0]);
if (i == JOptionPane.YES_OPTION){
if (myap != 100){
enemyhp-=myattack;
enap += 25;
if(enemyhp <= 0){JOptionPane.showMessageDialog(null,"You have attacked your enemy this turn \nYour HP: " + myhp + ", \nYour enemy's HP:" + "0" + " \nGet into your enemy's turn?")
;
break;}
else{
JOptionPane.showMessageDialog(null,"You have attacked your enemy this turn \nYour HP: " + myhp + ", \nYour enemy's HP:" + enemyhp + " \nGet into your enemy's turn?");
}}else{enemyhp-=myattack*2;
enap += 25;
myap = 0 ;
if(enemyhp <= 0){JOptionPane.showMessageDialog(null,"You have attacked your enemy"
+ " critically this turn \nYour HP: " + myhp + ", \nYour enemy's HP:" + "0" +
" \nGet into your enemy's turn?");
break;}
else{
JOptionPane.showMessageDialog(null,"You have attacked your enemy critially this "
+ "turn \nYour HP: " + myhp + ", \nYour enemy's HP:" + enemyhp +
" \nGet into your enemy's turn?");
}}
if (i == JOptionPane.NO_OPTION){
myhp+=myheal;if (myhp >= 1000){
myhp = 1000;}
}
JOptionPane.showMessageDialog(null,"You have healed yourself this turn \nYour HP: " + myhp + ", \nYour enemy's HP:" + enemyhp + " \nGet into your enemy's turn?");
}
if (i == JOptionPane.CANCEL_OPTION){
break;
}
int enemyif = (int)(Math.random()*2);
if (enemyif == 0){if(enap !=100){
myhp-=enemyattack;
myap+=25;
java好玩小游戏源代码 2页 5财富值喜欢此文档的还喜欢 java小游戏源代码 3页 免费 java推箱子游戏源代码 4页 免费 java小游戏连连看源代码 4页 免费 Java写...
初学JAVA 好玩的打架小游... 暂无评价 4页 2下载券 Java游戏源代码 5页 ...本系列就是利用 Java 这门语言教大家一步一步学习游戏开发,领会 Java 游戏开发...
java小游戏代码_计算机软件及应用_IT/计算机_专业资料。java小游戏代码,好玩的游戏,代码www.u2588.com www.u2588.com www.u2588.com www.u2588.com www.u...
这种代价值得 我们做的不是 pc 游戏,没必要把内存...sun 公司可以发布相关高端标准来统一规范代码 这三大...sun 公司发布的 java 版本很有意思 虽然总是写是 ...
Java猜拳小游戏源代码 4页 免费 java好玩小游戏源代码 2页 2下载券 C语言... Y)-(X + 1, Y + 1), RGB(255, 255, 0), BF End Sub 此代码非...
知识共享-很好玩的扫雷java源代码(雷惊风)_计算机软件及应用_IT/计算机_专业...{ //是否已经开始游戏 super("扫雷"); initSource(); setJMenuBar(getMenu()...
import java.awt.*; import javax.swing.*; import java.awt.event.*; ...\n 游戏规则:\n 您有 10 次猜数字的机会,每次你可以输入 1~100 之间的...
好玩好学的小游戏哦_IT/计算机_专业资料。下面是 java 小游戏的代码 !!!下面是 java 小游戏的代码 !!!...
JAVA 初学者要看的东西 1 什么是 Java,Java2,JDK?JDK 后面的 1.3,1.4....你也可以抛出自己的异常指示发生了某些不正常情况.常见的拦截处理代码如下: try ...
闽公网安备 35021102001881号 
热门文档