JAVA

Java adalah bahasa pemrograman yang multi platform dan multi device. Sekali anda menuliskan sebuah program dengan menggunakan Java, anda dapat menjalankannya hampir di semua komputer dan perangkat lain yang support Java, dengan sedikit perubahan dalam kodenya.

PHP

PHP merupakan sebuah bahasa scripting yang terpasang pada HTML. Sebagian besar sintaks mirip dengan bahasa C, Java dan Perl, ditambah beberapa fungsi PHP yang spesifik. Tujuan utama penggunaan bahasa ini adalah untuk memungkinkan perancang web.

C++

C++ adalah bahasa pemrograman komputer C++ dikembangkan di Bell Labs (Bjarne Stroustrup) pada awal tahun 1970-an, Bahasa itu diturunkan dari bahasa sebelumnya, yaitu BCL, Pada awalnya, bahasa tersebut dirancang sebagai bahasa pemrograman yang dijalankan pada sistem Unix.

HTML

HTML merupakan suatu metoda untuk mengimplementasikan konsep hypertext dalam suatu naskah atau dokumen. HTML sendiri bukan tergolong pada suatu bahasa pemrograman karena sifatnya yang hanya memberikan tanda (marking up) pada suatu naskah teks dan bukan sebagai program.

CSS

CSS adalah bagian dari sebuah website yang khusus dibuat untuk mengatur tampilan sebuah website. Kita dapat mengontrol isi (konten) dan tampilan secara terpisah. Perubahan konten tidak mengharuskan kita melakukan perubahan tampilan, demikian juga sebaliknya.

Showing posts with label Games Java. Show all posts
Showing posts with label Games Java. Show all posts

Wednesday, April 17, 2013

Games LastChance Dengan Aplikasi Java

Gann Sekarang ini saya ingin bikin game nihh,,  tpi sekaran ini saya ingin bikin games dengan nama Games LastChance gann,,,

okee,, kita lansung ajj yy gann,, ehmm gann klau kita bikin game coding nya psti bnyk nih gaann,,
Sekarang Saya kasi link ajj yy gann,,    :)

Outputnya :




Jangan Lupa saran dan kritik nya yy gann,,  salam sukses untuk gan semua nya,,,   :)

Sunday, April 7, 2013

Games Tic Tac Toe

Hai Gan,,  hari ini saya ingin membuat games Tic Tac Toe dengan menggunakan java.

1. Pertama - tama kita buka aplikasi Notped ++

2. Copas coding dibawah ini ke Notped ++


Source Code :


Source Code :


/*
Nama           : JAKA
Tanggal Lahir  : 13 APRIL 1992
Asal Daerah    : Kab. Ketapang
Universitas    : STMIK AMIKOM Yogyakarta

Nama Games             : TicTacToe
Tanggal Games Di Bikin : Maret 16, 2013
*/
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;
public class TicTacToe implements ActionListener {
final String VERSION = "1.0";
//Setting up ALL the variables
JFrame window = new JFrame("Tic-Tac-Toe " + VERSION);

JMenuBar mnuMain = new JMenuBar();
JMenuItem mnuNewGame = new JMenuItem("New Game"),
mnuInstruction = new JMenuItem("Instructions"),
mnuExit = new JMenuItem("Exit"),
mnuAbout = new JMenuItem("About");

JButton btn1v1 = new JButton("Player vs Player"),
btn1vCPU = new JButton("Player vs CPU"),
btnBack = new JButton("<--back");
JButton btnEmpty[] = new JButton[10];

JPanel pnlNewGame = new JPanel(),
pnlNorth = new JPanel(),
pnlSouth = new JPanel(),
pnlTop = new JPanel(),
pnlBottom = new JPanel(),
pnlPlayingField = new JPanel();
JLabel lblTitle = new JLabel("Tic-Tac-Toe");
JTextArea txtMessage = new JTextArea();

final int winCombo[][] = new int[][] {
{1, 2, 3}, {1, 4, 7}, {1, 5, 9},
{4, 5, 6}, {2, 5, 8}, {3, 5, 7},
{7, 8, 9}, {3, 6, 9}
/*Horizontal Wins*/ /*Vertical Wins*/ /*Diagonal Wins*/
};
final int X = 412, Y = 268, color = 190;
boolean inGame = false;
boolean win = false;
boolean btnEmptyClicked = false;
String message;
int turn = 1;
int wonNumber1 = 1, wonNumber2 = 1, wonNumber3 = 1;

public TicTacToe() { //Setting game properties and layout and sytle...
//Setting window properties:
window.setSize(X, Y);
window.setLocation(450, 260);
window.setResizable(false);
window.setLayout(new BorderLayout());
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

//Setting Panel layouts and properties
pnlNewGame.setLayout(new GridLayout(2, 1, 2, 10));
pnlNorth.setLayout(new FlowLayout(FlowLayout.CENTER));
pnlSouth.setLayout(new FlowLayout(FlowLayout.CENTER));

pnlNorth.setBackground(new Color(color-20, color-20, color-20));
pnlSouth.setBackground(new Color(color, color, color));

pnlTop.setBackground(new Color(color, color, color));
pnlBottom.setBackground(new Color(color, color, color));

pnlTop.setLayout(new FlowLayout(FlowLayout.CENTER));
pnlBottom.setLayout(new FlowLayout(FlowLayout.CENTER));
pnlNewGame.setBackground(Color.blue);

//Adding menu items to menu bar
mnuMain.add(mnuNewGame);
mnuMain.add(mnuInstruction);
mnuMain.add(mnuAbout);
mnuMain.add(mnuExit);//---->Menu Bar Complete

//Adding buttons to NewGame panel
pnlNewGame.add(btn1v1);
pnlNewGame.add(btn1vCPU);

//Adding Action Listener to all the Buttons and Menu Items
mnuNewGame.addActionListener(this);
mnuExit.addActionListener(this);
mnuInstruction.addActionListener(this);
mnuAbout.addActionListener(this);
btn1v1.addActionListener(this);
btn1vCPU.addActionListener(this);
btnBack.addActionListener(this);

//Setting up the playing field
pnlPlayingField.setLayout(new GridLayout(3, 3, 2, 2));
pnlPlayingField.setBackground(Color.black);
for(int i=1; i<=9; i++) {
btnEmpty[i] = new JButton();
btnEmpty[i].setBackground(new Color(220, 220, 220));
btnEmpty[i].addActionListener(this);
pnlPlayingField.add(btnEmpty[i]);
}
//Adding everything needed to pnlNorth and pnlSouth
pnlNorth.add(mnuMain);
pnlSouth.add(lblTitle);

//Adding to window and Showing window
window.add(pnlNorth, BorderLayout.NORTH);
window.add(pnlSouth, BorderLayout.CENTER);
window.setVisible(true);
}

//-------------------START OF ACTION PERFORMED CLASS-------------------------//
public void actionPerformed(ActionEvent click) {
Object source = click.getSource();
for(int i=1; i<=9; i++) {
if(source == btnEmpty[i] && turn < 10) {
btnEmptyClicked = true;
if(!(turn % 2 == 0))
btnEmpty[i].setText("X");
else
btnEmpty[i].setText("O");
btnEmpty[i].setEnabled(false);
pnlPlayingField.requestFocus();
turn++;
}
}
if(btnEmptyClicked) {
checkWin();
btnEmptyClicked = false;
}
if(source == mnuNewGame) {
clearPanelSouth();
pnlSouth.setLayout(new GridLayout(2, 1, 2, 5));
pnlTop.add(pnlNewGame);
pnlBottom.add(btnBack);
pnlSouth.add(pnlTop);
pnlSouth.add(pnlBottom);

}
else if(source == btn1v1) {
if(inGame) {
int option = JOptionPane.showConfirmDialog(null, "If you start a new game," +
"your current game will be lost..." + "\n" +
"Are you sure you want to continue?",
"Quit Game?" ,JOptionPane.YES_NO_OPTION);
if(option == JOptionPane.YES_OPTION) {
inGame = false;
}
}
if(!inGame) {
btnEmpty[wonNumber1].setBackground(new Color(220, 220, 220));
btnEmpty[wonNumber2].setBackground(new Color(220, 220, 220));
btnEmpty[wonNumber3].setBackground(new Color(220, 220, 220));
turn = 1;
for(int i=1; i<10; i++) {
btnEmpty[i].setText("");
btnEmpty[i].setEnabled(true);
}
win = false;
showGame();

}
}
else if(source == btn1vCPU) {
JOptionPane.showMessageDialog(null, "Coming Soon!!");
}
else if(source == mnuExit) {
int option = JOptionPane.showConfirmDialog(null, "Are you sure you want to exit?",
"Exit Game" ,JOptionPane.YES_NO_OPTION);
if(option == JOptionPane.YES_OPTION)
System.exit(0);
}
else if(source == mnuInstruction || source == mnuAbout) {
clearPanelSouth();
String message = "";
txtMessage.setBackground(new Color(color, color, color));
if(source == mnuInstruction) {
message = "Instructions:\n\n" +
"Your goal is to be the first player to get 3 X's or O's in a\n" +
"row. (horizontally, diagonally, or vertically)";
} else {
message = "About:\n\n" +
"Title: Tic-Tac-Toe\n" +
"Author: Blmaster\n" +
"Version: " + VERSION + "\n";
}
txtMessage.setEditable(false);
txtMessage.setText(message);
pnlSouth.setLayout(new GridLayout(2, 1, 2, 5));
pnlTop.add(txtMessage);
pnlBottom.add(btnBack);
pnlSouth.add(pnlTop);
pnlSouth.add(pnlBottom);
}
else if(source == btnBack) {
if(inGame)
showGame();
else {
clearPanelSouth();
pnlSouth.setLayout(new FlowLayout(FlowLayout.CENTER));
pnlNorth.setVisible(true);
pnlSouth.add(lblTitle);
}
}
pnlSouth.setVisible(false);
pnlSouth.setVisible(true);
}
//-------------------END OF ACTION PERFORMED CLASS-------------------------//

/*
----------------------------------
Start of all the other methods. |
----------------------------------
*/
public void showGame() { // Shows the Playing Field
// *IMPORTANT*- Does not start out brand new (meaning just shows what it had before)
clearPanelSouth();
inGame = true;
pnlSouth.setLayout(new BorderLayout());
pnlSouth.add(pnlPlayingField, BorderLayout.CENTER);
pnlPlayingField.requestFocus();
}

public void checkWin() { // checks if there are 3 symbols in a row vertically, diagonally, or horizontally.
// then shows a message and disables buttons.
for(int i=0; i<7; i++) {
if(
!btnEmpty[winCombo[i][0]].getText().equals("") &&
btnEmpty[winCombo[i][0]].getText().equals(btnEmpty[winCombo[i][1]].getText()) &&
// if {1 == 2 && 2 == 3}
btnEmpty[winCombo[i][1]].getText().equals(btnEmpty[winCombo[i][2]].getText())
/*
The way this checks the if someone won is:
First: it checks if the btnEmpty[x] is not equal to an empty string- x being the array number
inside the multi-dementional array winCombo[checks inside each of the 7 sets][the first number]
Secong: it checks if btnEmpty[x] is equal to btnEmpty[y]- x being winCombo[each set][the first number]
y being winCombo[each set the same as x][the second number] (So basically checks if the first and
second number in each set is equal to each other)
Third: it checks if btnEmtpy[y] is eual to btnEmpty[z]- y being the same y as last time and z being
winCombo[each set as y][the third number]
Conclusion: So basically it checks if it is equal to the btnEmpty is equal to each set of numbers
*/
) {
win = true;
wonNumber1 = winCombo[i][0];
wonNumber2 = winCombo[i][1];
wonNumber3 = winCombo[i][2];
btnEmpty[wonNumber1].setBackground(Color.white);
btnEmpty[wonNumber2].setBackground(Color.white);
btnEmpty[wonNumber3].setBackground(Color.white);
break;
}
}
if(win || (!win && turn>9)) {
if(win) {
if(turn % 2 == 0)
message = "X has won!";
else
message = "O has won!";
win = false;
} else if(!win && turn>9) {
message = "Both players have tied!\nBetter luck next time.";
}
JOptionPane.showMessageDialog(null, message);
for(int i=1; i<=9; i++) {
btnEmpty[i].setEnabled(false);
}
}
}

public void clearPanelSouth() { //Removes all the possible panels
//that pnlSouth, pnlTop, pnlBottom
//could have.
pnlSouth.remove(lblTitle);
pnlSouth.remove(pnlTop);
pnlSouth.remove(pnlBottom);
pnlSouth.remove(pnlPlayingField);
pnlTop.remove(pnlNewGame);
pnlTop.remove(txtMessage);
pnlBottom.remove(btnBack);
}

public static void main(String[] args) {
new TicTacToe();// Calling the class construtor.
}
}


3. Save file yang sudah di bikin tadi dengan nama TicTacToe.java
4. Komfile file tersebut dengan CMD
5. SUKSES dehh gannn bikin games Mine menggunakan Java
Outputnya :



jangan lupa komentarnya ya gannn,,,
Salam sukses gannn

Link source code nya yang sudah jadi dan complite : http://www.mediafire.com/?8ebjbtkkyeks41y


Games Tetris

Hai Gan,,  hari ini saya ingin membuat games Mine dengan menggunakan java.

1. Pertama - tama kita buka aplikasi Notped ++

2. Copas coding dibawah ini ke Notped ++


Source Code :

    import java.awt.*;
    import java.awt.event.*;
     
    import javax.swing.*;
     
    public class Tetris extends JFrame implements KeyListener {
            int pos[] = {0,1};
            boolean bottom = false;
    int n = 20;
    int m = 10;
    JButton b[][];
    Color tmp[][] = new Color[m][n];
    int rand = 0;
    int centralx = 0;
    int centraly = 0;
    int deltax = 0;
    int perim[][] = new int[m+4][n+4];
    or[][][] prof = new or[4][4][7];
    Color rnd[] = {Color.red, Color.yellow, Color.cyan, Color.green, Color.white, Color.blue, Color.orange};
    int rowsclrd = 0;
    public Tetris(){
            for(int a = 0;a<4;a++){
                    for(int b = 0;b<4;b++){
                            for(int c = 0;c<7;c++){
                                    prof[a][b][c] = new or();
                            }
                    }
            }
            this.setDefaultCloseOperation(EXIT_ON_CLOSE);
            prof[0][0][0].x = -1;
            prof[0][1][0].x = 0;
            prof[0][2][0].x = 0;
            prof[0][3][0].x = 1;
            prof[1][0][0].x = 0;
            prof[1][1][0].x = 0;
            prof[1][2][0].x = -1;
            prof[1][3][0].x = -1;
            prof[2][0][0].x = 1;
            prof[2][1][0].x = 0;
            prof[2][2][0].x = 0;
            prof[2][3][0].x = -1;
            prof[3][0][0].x = 0;
            prof[3][1][0].x = 0;
            prof[3][2][0].x = 1;
            prof[3][3][0].x = 1;
            prof[0][0][1].x = -1;
            prof[0][1][1].x = -1;
            prof[0][2][1].x = 0;
            prof[0][3][1].x = 1;
            prof[1][0][1].x = -1;
            prof[1][1][1].x = 0;
            prof[1][2][1].x = 0;
            prof[1][3][1].x = 0;
            prof[2][0][1].x = 1;
            prof[2][1][1].x = 1;
            prof[2][2][1].x = 0;
            prof[2][3][1].x = -1;
            prof[3][0][1].x = 1;
            prof[3][1][1].x = 0;
            prof[3][2][1].x = 0;
            prof[3][3][1].x = 0;
            prof[0][0][2].x = -1;
            prof[0][1][2].x = 0;
            prof[0][2][2].x = 1;
            prof[0][3][2].x = 1;
            prof[1][0][2].x = 0;
            prof[1][1][2].x = 0;
            prof[1][2][2].x = 0;
            prof[1][3][2].x = -1;
            prof[2][0][2].x = 1;
            prof[2][1][2].x = 0;
            prof[2][2][2].x = -1;
            prof[2][3][2].x = -1;
            prof[3][0][2].x = 0;
            prof[3][1][2].x = 0;
            prof[3][2][2].x = 0;
            prof[3][3][2].x = 1;
            prof[0][0][3].x = -1;
            prof[0][1][3].x = 0;
            prof[0][2][3].x = 0;
            prof[0][3][3].x = 1;
            prof[1][0][3].x = -1;
            prof[1][1][3].x = -1;
            prof[1][2][3].x = 0;
            prof[1][3][3].x = 0;
            prof[2][0][3].x = 1;
            prof[2][1][3].x = 0;
            prof[2][2][3].x = 0;
            prof[2][3][3].x = -1;
            prof[3][0][3].x = 1;
            prof[3][1][3].x = 1;
            prof[3][2][3].x = 0;
            prof[3][3][3].x = 0;
            prof[0][0][4].x = -1;
            prof[0][1][4].x = 0;
            prof[0][2][4].x = 0;
            prof[0][3][4].x = 1;
            prof[1][0][4].x = 0;
            prof[1][1][4].x = 0;
            prof[1][2][4].x = -1;
            prof[1][3][4].x = 0;
            prof[2][0][4].x = 1;
            prof[2][1][4].x = 0;
            prof[2][2][4].x = 0;
            prof[2][3][4].x = -1;
            prof[3][0][4].x = 0;
            prof[3][1][4].x = 0;
            prof[3][2][4].x = 1;
            prof[3][3][4].x = 0;
            prof[0][0][5].x = 0;
            prof[0][1][5].x = 0;
            prof[0][2][5].x = 1;
            prof[0][3][5].x = 1;
            prof[1][0][5].x = 0;
            prof[1][1][5].x = 0;
            prof[1][2][5].x = 1;
            prof[1][3][5].x = 1;
            prof[2][0][5].x = 0;
            prof[2][1][5].x = 0;
            prof[2][2][5].x = 1;
            prof[2][3][5].x = 1;
            prof[3][0][5].x = 0;
            prof[3][1][5].x = 0;
            prof[3][2][5].x = 1;
            prof[3][3][5].x = 1;
            prof[0][0][6].x = -1;
            prof[0][1][6].x = 0;
            prof[0][2][6].x = 1;
            prof[0][3][6].x = 2;
            prof[1][0][6].x = 0;
            prof[1][1][6].x = 0;
            prof[1][2][6].x = 0;
            prof[1][3][6].x = 0;
            prof[2][0][6].x = 1;
            prof[2][1][6].x = 0;
            prof[2][2][6].x = -1;
            prof[2][3][6].x = -2;
            prof[3][0][6].x = 0;
            prof[3][1][6].x = 0;
            prof[3][2][6].x = 0;
            prof[3][3][6].x = 0;
            prof[0][0][0].y = 0;
            prof[0][1][0].y = 0;
            prof[0][2][0].y = 1;
            prof[0][3][0].y = 1;
            prof[1][0][0].y = -1;
            prof[1][1][0].y = 0;
            prof[1][2][0].y = 0;
            prof[1][3][0].y = 1;
            prof[2][0][0].y = 0;
            prof[2][1][0].y = 0;
            prof[2][2][0].y = -1;
            prof[2][3][0].y = -1;
            prof[3][0][0].y = 1;
            prof[3][1][0].y = 0;
            prof[3][2][0].y = 0;
            prof[3][3][0].y = -1;
            prof[0][0][1].y = 0;
            prof[0][1][1].y = 1;
            prof[0][2][1].y = 0;
            prof[0][3][1].y = 0;
            prof[1][0][1].y = -1;
            prof[1][1][1].y = -1;
            prof[1][2][1].y = 0;
            prof[1][3][1].y = 1;
            prof[2][0][1].y = -1;
            prof[2][1][1].y = 0;
            prof[2][2][1].y = 0;
            prof[2][3][1].y = 0;
            prof[3][0][1].y = 1;
            prof[3][1][1].y = 1;
            prof[3][2][1].y = 0;
            prof[3][3][1].y = -1;
            prof[0][0][2].y = 0;
            prof[0][1][2].y = 0;
            prof[0][2][2].y = 0;
            prof[0][3][2].y = 1;
            prof[1][0][2].y = -1;
            prof[1][1][2].y = 0;
            prof[1][2][2].y = 1;
            prof[1][3][2].y = 1;
            prof[2][0][2].y = 0;
            prof[2][1][2].y = 0;
            prof[2][2][2].y = 0;
            prof[2][3][2].y = -1;
            prof[3][0][2].y = 1;
            prof[3][1][2].y = 0;
            prof[3][2][2].y = -1;
            prof[3][3][2].y = -1;
            prof[0][0][3].y = 1;
            prof[0][1][3].y = 1;
            prof[0][2][3].y = 0;
            prof[0][3][3].y = 0;
            prof[1][0][3].y = -1;
            prof[1][1][3].y = 0;
            prof[1][2][3].y = 0;
            prof[1][3][3].y = 1;
            prof[2][0][3].y = -1;
            prof[2][1][3].y = -1;
            prof[2][2][3].y = 0;
            prof[2][3][3].y = 0;
            prof[3][0][3].y = 1;
            prof[3][1][3].y = 0;
            prof[3][2][3].y = 0;
            prof[3][3][3].y = -1;
            prof[0][0][4].y = 0;
            prof[0][1][4].y = 0;
            prof[0][2][4].y = 1;
            prof[0][3][4].y = 0;
            prof[1][0][4].y = -1;
            prof[1][1][4].y = 0;
            prof[1][2][4].y = 0;
            prof[1][3][4].y = 1;
            prof[2][0][4].y = 0;
            prof[2][1][4].y = 0;
            prof[2][2][4].y = -1;
            prof[2][3][4].y = 0;
            prof[3][0][4].y = 1;
            prof[3][1][4].y = 0;
            prof[3][2][4].y = 0;
            prof[3][3][4].y = -1;
            prof[0][0][5].y = 0;
            prof[0][1][5].y = 1;
            prof[0][2][5].y = 0;
            prof[0][3][5].y = 1;
            prof[1][0][5].y = 0;
            prof[1][1][5].y = 1;
            prof[1][2][5].y = 0;
            prof[1][3][5].y = 1;
            prof[2][0][5].y = 0;
            prof[2][1][5].y = 1;
            prof[2][2][5].y = 0;
            prof[2][3][5].y = 1;
            prof[3][0][5].y = 0;
            prof[3][1][5].y = 1;
            prof[3][2][5].y = 0;
            prof[3][3][5].y = 1;
            prof[0][0][6].y = 0;
            prof[0][1][6].y = 0;
            prof[0][2][6].y = 0;
            prof[0][3][6].y = 0;
            prof[1][0][6].y = -1;
            prof[1][1][6].y = 0;
            prof[1][2][6].y = 1;
            prof[1][3][6].y = 2;
            prof[2][0][6].y = 0;
            prof[2][1][6].y = 0;
            prof[2][2][6].y = 0;
            prof[2][3][6].y = 0;
            prof[3][0][6].y = -1;
            prof[3][1][6].y = 0;
            prof[3][2][6].y = 1;
            prof[3][3][6].y = 2;
            for (int y = 0;y<2;y++){
            for (int x = 0;x<m+4;x++){
            perim[x][y]= 1;
            }}
            for (int y = n+2;y<n+4;y++){
                    for (int x = 0;x<m+4;x++){
                    perim[x][y]= 4;
                    }}
            for (int y = 2;y<n+2;y++){
                    for (int x = 0;x<2;x++){
                    perim[x][y]= 2;
                    }}
            for (int y = 2;y<n+2;y++){
                    for (int x = m+2;x<m+4;x++){
                    perim[x][y]= 2;
                    }}
            for(int y = 0;y<n+4;y++){
                    for (int x = 0;x<m+4;x++){
                            System.out.print(perim[x][y]);
                    }
                    System.out.println("");
            }
                b = new JButton [m][n];
                setLayout(new GridLayout(n,m));//Grid layouts x and y are SWAPPED!
                for (int y = 0;y<n;y++){
                    for (int x = 0;x<m;x++){
                            b[x][y] = new JButton(" ");
                            tmp[x][y] = Color.DARK_GRAY;
                            b[x][y].setBackground(Color.DARK_GRAY);
                            add(b[x][y]);
                            b[x][y].setEnabled(true);
                    }//end inner for
            }
                setFocusable(true);
                addKeyListener(this);
                pack();
                setVisible(true);
                blockgen();
               
               
        }//end constructor Mine()
     
            class or {
                    int x;
                    int y;
            }
     
            public void blockgen(){
                    Component temporaryLostComponent = null;
                    pos[0] = 0;
                    pos[1] = 1;
                    rand = (int) (Math.floor(Math.random()*7+1));
            centralx = 4;
            centraly = 0;
             System.out.print(rand);
                    if ((b[4+prof[pos[0]][0][rand-1].x][prof[pos[0]][0][rand-1].y].getBackground() == Color.DARK_GRAY) &&
                    (b[4+prof[pos[0]][1][rand-1].x][prof[pos[0]][1][rand-1].y].getBackground() == Color.DARK_GRAY) &&
                    (b[4+prof[pos[0]][2][rand-1].x][prof[pos[0]][2][rand-1].y].getBackground() == Color.DARK_GRAY) &&
                    (b[4+prof[pos[0]][3][rand-1].x][prof[pos[0]][3][rand-1].y].getBackground() == Color.DARK_GRAY)){
                    b[4+prof[pos[0]][0][rand-1].x][prof[pos[0]][0][rand-1].y].setBackground(rnd[rand-1]);
                    b[4+prof[pos[0]][1][rand-1].x][prof[pos[0]][1][rand-1].y].setBackground(rnd[rand-1]);
                    b[4+prof[pos[0]][2][rand-1].x][prof[pos[0]][2][rand-1].y].setBackground(rnd[rand-1]);
                    b[4+prof[pos[0]][3][rand-1].x][prof[pos[0]][3][rand-1].y].setBackground(rnd[rand-1]);
            go();
                    } else {
                            JOptionPane.showMessageDialog(temporaryLostComponent, "Game Over! You cleared "+rowsclrd+" rows, well done!");
                System.exit(0);
                    }
            }
           
            public void rotate(){
                    if (pos[0] < 3){
                            pos[1] = pos[0];
                    pos[0]++;
                    } else if (pos[0] == 3){
                            pos[0] = 0;
                            pos[1] = 3;
                    } else {
                            System.out.println("error");
                    }
                    if ((perim[2+centralx+prof[pos[0]][0][rand-1].x][centraly+prof[pos[0]][0][rand-1].y+2] != 4) && (perim[2+centralx+prof[pos[0]][0][rand-1].x][centraly+prof[pos[0]][0][rand-1].y+2] != 1) && (perim[2+centralx+prof[pos[0]][0][rand-1].x][centraly+prof[pos[0]][0][rand-1].y+2] != 2) && (perim[2+centralx+prof[pos[0]][0][rand-1].x][centraly+prof[pos[0]][0][rand-1].y+2] != 3)
                             && (perim[centralx+2+prof[pos[0]][1][rand-1].x][centraly+prof[pos[0]][1][rand-1].y+2] != 4) && (perim[centralx+2+prof[pos[0]][1][rand-1].x][centraly+prof[pos[0]][1][rand-1].y+2] != 1) && (perim[centralx+2+prof[pos[0]][1][rand-1].x][centraly+prof[pos[0]][1][rand-1].y+2] != 2) && (perim[centralx+2+prof[pos[0]][1][rand-1].x][centraly+prof[pos[0]][1][rand-1].y+2] != 3)
                             && (perim[centralx+2+prof[pos[0]][2][rand-1].x][centraly+prof[pos[0]][2][rand-1].y+2] != 4) && (perim[centralx+2+prof[pos[0]][2][rand-1].x][centraly+prof[pos[0]][2][rand-1].y+2] != 1) && (perim[centralx+2+prof[pos[0]][2][rand-1].x][centraly+prof[pos[0]][2][rand-1].y+2] != 2) && (perim[centralx+2+prof[pos[0]][2][rand-1].x][centraly+prof[pos[0]][2][rand-1].y+2] != 3)
                             && (perim[centralx+prof[pos[0]][3][rand-1].x+2][centraly+prof[pos[0]][3][rand-1].y+2] != 4) && (perim[centralx+prof[pos[0]][3][rand-1].x+2][centraly+prof[pos[0]][3][rand-1].y+2] != 1) && (perim[centralx+prof[pos[0]][3][rand-1].x+2][centraly+prof[pos[0]][3][rand-1].y+2] != 2) && (perim[centralx+prof[pos[0]][3][rand-1].x+2][centraly+prof[pos[0]][3][rand-1].y+2] != 3)){
                     b[centralx+prof[pos[1]][0][rand-1].x][centraly+prof[pos[1]][0][rand-1].y].setBackground(Color.DARK_GRAY);
                        b[centralx+prof[pos[1]][1][rand-1].x][centraly+prof[pos[1]][1][rand-1].y].setBackground(Color.DARK_GRAY);
                        b[centralx+prof[pos[1]][2][rand-1].x][centraly+prof[pos[1]][2][rand-1].y].setBackground(Color.DARK_GRAY);
                        b[centralx+prof[pos[1]][3][rand-1].x][centraly+prof[pos[1]][3][rand-1].y].setBackground(Color.DARK_GRAY);
                        b[centralx+(prof[pos[0]][0][rand-1].x)][centraly+(prof[pos[0]][0][rand-1].y)].setBackground(rnd[rand-1]);
                        b[centralx+(prof[pos[0]][1][rand-1].x)][centraly+(prof[pos[0]][1][rand-1].y)].setBackground(rnd[rand-1]);
                        b[centralx+(prof[pos[0]][2][rand-1].x)][centraly+(prof[pos[0]][2][rand-1].y)].setBackground(rnd[rand-1]);
                        b[centralx+(prof[pos[0]][3][rand-1].x)][centraly+(prof[pos[0]][3][rand-1].y)].setBackground(rnd[rand-1]);
                    } else {
                            if (pos[1] > 0){
                                    pos[0] = pos[1];
                                    pos[1]--;
                            } else if (pos[1] == 0){
                                    pos[0] = 0;
                                    pos[1] = 3;                             }
                            }
            }
           
           
            public int getxs(){
                       int xs = 0;
                       int[] xf = {-1, -1, -1, -1};
                       for (int d = 0;d<4;d++){
                               if ((xf[0] != prof[pos[0]][d][rand-1].x) || (xf[1] != prof[pos[0]][d][rand-1].x) || (xf[2] != prof[pos[0]][d][rand-1].x) || (xf[3] != prof[pos[0]][d][rand-1].x)){
                                       xf[d] = prof[pos[0]][d][rand-1].x;
                               }
                       }
                       for (int d = 0;d<4;d++){
                               if (xf[d] != -1){
                                       xs++;
                               }
                       }
                       return xs;
            }
           
           
       public void movedown(){
               int[] m2 = {-1, -1, -1, -1};
               int[] m1 = {-1, -1, -1, -1};
               int[] zero = {-1, -1, -1, -1};
               int[] one = {-1, -1, -1, -1};
               int[] two = {-1, -1, -1, -1};
                    for (int d = 0;d<4;d++){
                            if (prof[pos[0]][d][rand-1].x == -2){
                                    m2[d] = d;
                            } else if (prof[pos[0]][d][rand-1].x == -1){
                                    m1[d] = d;
                            } else if (prof[pos[0]][d][rand-1].x == 0){
                                    zero[d] = d;
                            } else if (prof[pos[0]][d][rand-1].x == 1){
                                    one[d] = d;
                            } else if (prof[pos[0]][d][rand-1].x == 2){
                                    two[d] = d;
                            }
                    }
                    int tmpm2 = -5;
                    int tmpm1 = -5;
                    int tmpzero = -5;
                    int tmpone = -5;
                    int tmptwo = -5;
                    for (int d = 0;d<4;d++){
                            if (m2[d] != -1){
                                    if (tmpm2<prof[pos[0]][m2[d]][rand-1].y){
                                    tmpm2 = prof[pos[0]][m2[d]][rand-1].y;
                                    }
                            }
                            if (m1[d] != -1){
                                    if (tmpm1<prof[pos[0]][m1[d]][rand-1].y){
                                    tmpm1 = prof[pos[0]][m1[d]][rand-1].y;
                            }
                            }
                            if (zero[d] != -1){
                                    if (tmpzero<prof[pos[0]][zero[d]][rand-1].y){
                                    tmpzero = prof[pos[0]][zero[d]][rand-1].y;
                            }
                            }
                            if (one[d] != -1){
                                    if (tmpone<prof[pos[0]][one[d]][rand-1].y){
                                    tmpone = prof[pos[0]][one[d]][rand-1].y;
                            }
                            }
                            if (two[d] != -1){
                                    if (tmptwo<prof[pos[0]][two[d]][rand-1].y){
                                    tmptwo = prof[pos[0]][two[d]][rand-1].y;
                            }
                            }
                    }
                    int total = 0;
                    for (int d = 0;d<4;d++){
                            if (prof[pos[0]][d][rand-1].x == -2){
                                    if (perim[2+centralx+-2][2+centraly+tmpm2+1] != 4){
                                            if(b[centralx+-2][centraly+tmpm2+1].getBackground() == Color.DARK_GRAY){
                                            total++;
                                    }}
                            } else if (prof[pos[0]][d][rand-1].x == -1){
                                    if (perim[2+centralx+-1][2+centraly+tmpm1+1] != 4){
                                                    if (b[centralx+-1][centraly+tmpm1+1].getBackground() == Color.DARK_GRAY){
                                            total++;
                                    }}
                            } else if (prof[pos[0]][d][rand-1].x == 0){
                                    if (perim[2+centralx][2+centraly+tmpzero+1] != 4){
                                                    if (b[centralx][centraly+tmpzero+1].getBackground() == Color.DARK_GRAY){
                                            total++;
                                    }}
                            } else if (prof[pos[0]][d][rand-1].x == 1){
                                    if (perim[2+centralx+1][2+centraly+tmpone+1] != 4){
                                                    if (b[centralx+1][centraly+tmpone+1].getBackground() == Color.DARK_GRAY){
                                            total++;
                                    }}
                            } else if (prof[pos[0]][d][rand-1].x == 2){
                                    if (perim[2+centralx+2][2+centraly+tmptwo+1] != 4){
                                            if (b[centralx+2][centraly+tmptwo+1].getBackground() == Color.DARK_GRAY){
                                            total++;
                                    }}
                            }
                    }
                     if (total == 4){
                              b[centralx+prof[pos[0]][0][rand-1].x][centraly+prof[pos[0]][0][rand-1].y].setBackground(Color.DARK_GRAY);
                        b[centralx+prof[pos[0]][1][rand-1].x][centraly+prof[pos[0]][1][rand-1].y].setBackground(Color.DARK_GRAY);
                        b[centralx+prof[pos[0]][2][rand-1].x][centraly+prof[pos[0]][2][rand-1].y].setBackground(Color.DARK_GRAY);
                        b[centralx+prof[pos[0]][3][rand-1].x][centraly+prof[pos[0]][3][rand-1].y].setBackground(Color.DARK_GRAY);
                            centraly++;
                            b[centralx+prof[pos[0]][0][rand-1].x][centraly+prof[pos[0]][0][rand-1].y].setBackground(rnd[rand-1]);
                        b[centralx+prof[pos[0]][1][rand-1].x][centraly+prof[pos[0]][1][rand-1].y].setBackground(rnd[rand-1]);
                        b[centralx+prof[pos[0]][2][rand-1].x][centraly+prof[pos[0]][2][rand-1].y].setBackground(rnd[rand-1]);
                        b[centralx+prof[pos[0]][3][rand-1].x][centraly+prof[pos[0]][3][rand-1].y].setBackground(rnd[rand-1]);
                      } else {
                   
    bottom = true;
                             }
                     }
               
     
       
       public void go(){
               do{
               try {
                    Thread.sleep(1000L);
            } catch (InterruptedException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
            }
               movedown();
               rowcheck();
       }
       while(bottom == false);
               bottom = false;
               blockgen();
               }
       
       public void rowcheck(){
               int row = 0;
               for (int y = 0;y<20;y++){
                       for (int x = 0;x<10;x++){
                               if (b[x][y].getBackground() != Color.DARK_GRAY){
                                       row++;
                               }
                               if (row == 10){
                                       rowsclrd++;
                                       rowclear(y);                            
                               }
                       }
                       row = 0;
               }
       }
       
       public void rowclear(int y){
               int inc = 0;
               for (int x = 0;x<10;x++){
                       b[x][y].setBackground(Color.DARK_GRAY);
               }
               for (int c = y-1;c>-1;c--){
           for (int x = 0;x<10;x++){
               tmp[x][y-inc] = b[x][c].getBackground();
           }inc++;}
               for (int c = y;c>-1;c--){
                       for (int x = 0;x<10;x++){
                               b[x][c].setBackground(tmp[x][c]);
                       }
               }
       }
       
       public void movelr(){                 
               int[] m2 = {-1, -1, -1, -1};
               int[] m1 = {-1, -1, -1, -1};
               int[] zero = {-1, -1, -1, -1};
               int[] one = {-1, -1, -1, -1};
               int[] two = {-1, -1, -1, -1};
                    for (int d = 0;d<4;d++){
                            if (prof[pos[0]][d][rand-1].y == -2){
                                    m2[d] = d;
                            } else if (prof[pos[0]][d][rand-1].y == -1){
                                    m1[d] = d;
                            } else if (prof[pos[0]][d][rand-1].y == 0){
                                    zero[d] = d;
                            } else if (prof[pos[0]][d][rand-1].y == 1){
                                    one[d] = d;
                            } else if (prof[pos[0]][d][rand-1].y == 2){
                                    two[d] = d;
                            }
                    }
                            int tmpm2 = -5;
                            int tmpm1 = -5;
                            int tmpzero = -5;
                            int tmpone = -5;
                            int tmptwo = -5;
                    if (deltax == 1){
                    for (int d = 0;d<4;d++){
                            if (m2[d] != -1){
                                    if (tmpm2<prof[pos[0]][m2[d]][rand-1].x){
                                    tmpm2 = prof[pos[0]][m2[d]][rand-1].x;
                                    }
                            }
                            if (m1[d] != -1){
                                    if (tmpm1<prof[pos[0]][m1[d]][rand-1].x){
                                    tmpm1 = prof[pos[0]][m1[d]][rand-1].x;
                            }
                            }
                            if (zero[d] != -1){
                                    if (tmpzero<prof[pos[0]][zero[d]][rand-1].x){
                                    tmpzero = prof[pos[0]][zero[d]][rand-1].x;
                            }
                            }
                            if (one[d] != -1){
                                    if (tmpone<prof[pos[0]][one[d]][rand-1].x){
                                    tmpone = prof[pos[0]][one[d]][rand-1].x;
                            }
                            }
                            if (two[d] != -1){
                                    if (tmptwo<prof[pos[0]][two[d]][rand-1].x){
                                    tmptwo = prof[pos[0]][two[d]][rand-1].x;
                            }
                            }
                    }
                    } else if (deltax == -1){
                            tmpm2 = 5;
                            tmpm1 = 5;
                            tmpzero = 5;
                            tmpone = 5;
                            tmptwo = 5;
                            for (int d = 0;d<4;d++){
                                    if (m2[d] != -1){
                                            if (tmpm2>prof[pos[0]][m2[d]][rand-1].x){
                                            tmpm2 = prof[pos[0]][m2[d]][rand-1].x;
                                            }
                                    }
                                    if (m1[d] != -1){
                                            if (tmpm1>prof[pos[0]][m1[d]][rand-1].x){
                                            tmpm1 = prof[pos[0]][m1[d]][rand-1].x;
                                    }
                                    }
                                    if (zero[d] != -1){
                                            if (tmpzero>prof[pos[0]][zero[d]][rand-1].x){
                                            tmpzero = prof[pos[0]][zero[d]][rand-1].x;
                                    }
                                    }
                                    if (one[d] != -1){
                                            if (tmpone>prof[pos[0]][one[d]][rand-1].x){
                                            tmpone = prof[pos[0]][one[d]][rand-1].x;
                                    }
                                    }
                                    if (two[d] != -1){
                                            if (tmptwo>prof[pos[0]][two[d]][rand-1].x){
                                            tmptwo = prof[pos[0]][two[d]][rand-1].x;
                                    }
                                    }
                            }
                    }
                    int total = 0;
                    for (int d = 0;d<4;d++){
                            if (prof[pos[0]][d][rand-1].y == -2){
                                    if (perim[2+centralx+deltax+tmpm2][2+centraly-2] != 2){
                                            if(b[centralx+deltax+tmpm2][centraly-2].getBackground() == Color.DARK_GRAY){
                                            total++;
                                    }}
                            } else if (prof[pos[0]][d][rand-1].y == -1){
                                    if (perim[2+centralx+deltax+tmpm1][2+centraly-1] != 2){
                                                    if (b[centralx+deltax+tmpm1][centraly-1].getBackground() == Color.DARK_GRAY){
                                            total++;
                                    }}
                            } else if (prof[pos[0]][d][rand-1].y == 0){
                                    if (perim[2+centralx+deltax+tmpzero][2+centraly] != 2){
                                                    if (b[centralx+deltax+tmpzero][centraly].getBackground() == Color.DARK_GRAY){
                                            total++;
                                    }}
                            } else if (prof[pos[0]][d][rand-1].y == 1){
                                    if (perim[2+centralx+deltax+tmpone][2+centraly+1] != 2){
                                                    if (b[centralx+deltax+tmpone][centraly+1].getBackground() == Color.DARK_GRAY){
                                            total++;
                                    }}
                            } else if (prof[pos[0]][d][rand-1].y == 2){
                                    if (perim[2+centralx+deltax+tmptwo][2+centraly+2] != 2){
                                            if (b[centralx+deltax+tmptwo][centraly+2].getBackground() == Color.DARK_GRAY){
                                            total++;
                                    }}
                            }
                    } if (total == 4){
                                            b[centralx+prof[pos[0]][0][rand-1].x][centraly+prof[pos[0]][0][rand-1].y].setBackground(Color.DARK_GRAY);
                                            b[centralx+prof[pos[0]][1][rand-1].x][centraly+prof[pos[0]][1][rand-1].y].setBackground(Color.DARK_GRAY);
                                b[centralx+prof[pos[0]][2][rand-1].x][centraly+prof[pos[0]][2][rand-1].y].setBackground(Color.DARK_GRAY);
                                b[centralx+prof[pos[0]][3][rand-1].x][centraly+prof[pos[0]][3][rand-1].y].setBackground(Color.DARK_GRAY);
                                    centralx = centralx+deltax;
                                    b[centralx+prof[pos[0]][0][rand-1].x][centraly+prof[pos[0]][0][rand-1].y].setBackground(rnd[rand-1]);
                                b[centralx+prof[pos[0]][1][rand-1].x][centraly+prof[pos[0]][1][rand-1].y].setBackground(rnd[rand-1]);
                                b[centralx+prof[pos[0]][2][rand-1].x][centraly+prof[pos[0]][2][rand-1].y].setBackground(rnd[rand-1]);
                                b[centralx+prof[pos[0]][3][rand-1].x][centraly+prof[pos[0]][3][rand-1].y].setBackground(rnd[rand-1]);
                    }
                             
                     
       }
     
    public static void main (String[] args){
            new Tetris();
    }
     
    @Override
    public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_RIGHT){
                    deltax = 1;
                    movelr();
                    }
            if (e.getKeyCode() == KeyEvent.VK_LEFT){
                    deltax = -1;
                    movelr();
                    }
            if (e.getKeyCode() == KeyEvent.VK_UP){
                    rotate();
                    }
            if (e.getKeyCode() == KeyEvent.VK_DOWN){
                    movedown();
                    }
    }
     
     
    @Override
    public void keyReleased(KeyEvent e) {
            // TODO Auto-generated method stub
           
    }
     
     
    @Override
    public void keyTyped(KeyEvent e) {
            // TODO Auto-generated method stub
           
    }
    }


3. Save file yang sudah di bikin tadi dengan nama Tetris.java
4. Komfile file tersebut dengan CMD
5. SUKSES dehh gannn bikin games Mine menggunakan Java
Outputnya :

jangan lupa komentarnya ya gannn,,,
Salam sukses gannn

Link source code nya yang sudah jadi dan complite :  http://www.mediafire.com/?y3t828gmwuzt1d3