Game RPG yang sederhana

karna saya suka bermain game terutama game rpg..eh tiba2 game ini mengimaginasi saya untuk iseng buat game sendiri walaupun sederhana…hahahah….cuma berantemnya doang….

 

import java.io.*;
class rpg
{
public int att;
public int hp;

public static void main(String args[]) throws IOException
{
rpg Human = new rpg();
rpg Monster = new rpg();
Human.att = 90;
Human.hp= 1000;
Monster.att = 100;
Monster.hp= 500;
int n =1;

System.out.println(“Pilih karakter : “);
System.out.println(“1. Human”);
System.out.println(“2. Monster”);
System.out.print(“Pilih : “);
int input=(new Integer((new BufferedReader(new InputStreamReader(System.in))).readLine()).intValue());
switch(input)
{
case 1 : System.out.println(“Human”);
System.out.println(“Serangan : “+Human.att);
System.out.println(“Darah    : “+Human.hp);
break;
case 2 : System.out.println(“Monster”);
System.out.println(“Serangan : “+Monster.att);
System.out.println(“Darah    : “+Monster.hp);
break;
default : System.out.println(“Salah”);
System.exit(0);
break;
}
if(input ==1 )
{
System.out.println(“You VS Monster”);
do
{
if( Human.hp <= 0)
{
System.out.println(“You are the Loser”);
System.exit(0);
}
else if( Monster.hp <= 0)
{
System.out.println(“You are the Winner”);
System.exit(0);
}

System.out.println(“===========Turn “+n+”==================”);
System.out.println(“Musuh : Monster”);
System.out.println(“hp : “+Monster.hp+” Serangan : “+Monster.att);
System.out.println(“You : Human”);
System.out.println(“hp : “+Human.hp+” Serangan : “+Human.att);
System.out.println(“1. Attack”);
System.out.println(“2. Kabur”);
System.out.print(“Pilih Mode : “);
int pilih = (new Integer((new BufferedReader(new InputStreamReader(System.in))).readLine()).intValue());
switch(pilih)
{
case 1 : Monster.hp = Monster.hp – Human.att;
Human.hp = Human.hp – Monster.att;
break;
case 2 : System.out.println(“GAME OVER”);
System.exit(0);
break;
default : System.out.println(“Salah”);
System.exit(0);
break;

}
System.out.println(“Human Attack Monster with “+Human.att+” Damage”);
System.out.println(“Monster Attack u with “+Monster.att+” Damage”);
System.out.println(“\n”);
n++;
}while(n<10);
}else
{
System.out.println(“You VS Human”);
do
{
if( Human.hp <= 0)
{
System.out.println(“You are the winner”);
System.exit(0);
}
else if( Monster.hp <= 0)
{
System.out.println(“You are the loser”);
System.exit(0);
}

System.out.println(“===========Turn “+n+”==================”);
System.out.println(“Musuh : Human”);
System.out.println(“hp : “+Human.hp+” Serangan : “+Human.att);
System.out.println(“You : Monster”);
System.out.println(“hp : “+Monster.hp+” Serangan : “+Monster.att);
System.out.println(“1. Attack”);
System.out.println(“2. Kabur”);
System.out.print(“Pilih Mode : “);
int pilih = (new Integer((new BufferedReader(new InputStreamReader(System.in))).readLine()).intValue());
switch(pilih)
{
case 1 : Human.hp = Human.hp – Monster.att;
Monster.hp = Monster.hp – Human.att;
break;
case 2 : System.out.println(“GAME OVER”);
System.exit(0);
break;
default : System.out.println(“Salah”);
System.exit(0);
break;

}
System.out.println(“Monster Attack Human with “+Monster.att+” Damage”);
System.out.println(“Human Attack u with “+Human.att+” Damage”);
System.out.println(“\n”);
n++;
}while(n<10);

}
}
}

Advertisements

One response to this post.

  1. Posted by Marli on January 29, 2011 at 1:58 pm

    Terus cara maininnya gimana?

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: