Java game programming 01

Source: Internet
Author: User

Programming

Public class project01 {
/**
* @ Param ARGs
*/
Public static void main (string [] ARGs ){
// Todo automatically generates method stubs
Int HP = 0;
Int x = 0;
Int y = 0;
Boolean begin = true;
System. Out. println ("before the game starts, HP =" + HP + "x =" + x + "Y =" + y );
If (begin = true ){
X = 10;
Y = 10;
HP = 100;
}
System. Out. println ("after the game starts, HP =" + HP + "x =" + x + "Y =" + y );
}
}

Public class project02 {
/**
* @ Param ARGs
*/
Public static void main (string [] ARGs ){
// Todo automatically generates method stubs
String type = "AK-47 ";
Int attactvalue = 0;
Int change = 0;
System. Out. println ("before the gun is selected, the gun type is:" + Type + "the gun's attack value is:" + attactvalue );
Change = 2;
If (change = 1 ){
Attactvalue = 30;
Type = "M4 ";

}
If (change = 2 ){
Attactvalue = 20;
Type = "b31 ";
}
System. Out. println ("after a gun is selected, the gun type is:" + Type + "the attack value of this gun is:" + attactvalue );
}
}

Public class project03 {
/**
* @ Param ARGs
*/
Public static void main (string [] ARGs ){
// Todo automatically generates method stubs
Int distance = 15;
Int heroexp = 0;
Int herox = 10;
Int enemyx = 30;
Int enemyhp = 100;
String attactstate = "entering attack state ";


If (enemyx-herox) <distance ){
Attactstate = "entering attack state ";
Heroexp + = 5;
Enemyhp-= 10;
}
System. Out. println ("Attack Status:" + attactstate) before the enemy's position changes );
System. Out. println ("player experience:" + heroexp) before the enemy position changes );
System. Out. println ("enemy blood:" + enemyhp );
Enemyx-= 10;
If (enemyx-herox) <distance ){
Attactstate = "entering attack state ";
Heroexp + = 5;
Enemyhp-= 10;
}
System. Out. println ("--------------------------------------------------------");
System. Out. println ("attack status after the enemy position changes:" + attactstate );
System. Out. println ("player experience score after enemy position change:" + heroexp );
System. Out. println ("the enemy's blood value after the enemy's position changes:" + enemyhp );
}
}

Public class project04 {
/**
* @ Param ARGs
*/
Public static void main (string [] ARGs ){
// Todo automatically generates method stubs
Int HP = 100;
System. Out. println ("HP =" + Hp );
If (HP> 0 ){
System. Out. println ("game in progress ");
} Else {
System. Out. println ("game ended ");
}
HP-= 110;
System. Out. println ("----------------------------------------");
System. Out. println ("HP =" + Hp after Hp transformation );
If (HP> 0 ){
System. Out. println ("game in progress ");
}
Else {
System. Out. println ("game ended ");
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.