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.

Sunday, April 7, 2013

Games Mine


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 Mine extends JFrame implements ActionListener, MouseListener{
            int nomines = 80;
            int perm[][];
           String tmp;
           boolean found = false;
           int row;
           int column;
           int guesses[][];
           JButton b[][];
           int[][] mines;
           boolean allmines;
           int n = 30;
           int m = 30;
           int deltax[] = {-1, 0, 1, -1, 1, -1, 0, 1};
           int deltay[] = {-1, -1, -1, 0, 0, 1, 1, 1};
           double starttime;
           double endtime;
           public Mine(){
           this.setDefaultCloseOperation(EXIT_ON_CLOSE);
            perm = new int[n][m];
                   boolean allmines = false;
                   guesses = new int [n+2][m+2];
                   mines = new int[n+2][m+2];
                   b = new JButton [n][m];
                   setLayout(new GridLayout(n,m));
                   for (int y = 0;y<m+2;y++){
                           mines[0][y] = 3;
                           mines[n+1][y] = 3;
                           guesses[0][y] = 3;
                           guesses[n+1][y] = 3;
                   }
                   for (int x = 0;x<n+2;x++){
                           mines[x][0] = 3;
                           mines[x][m+1] = 3;
                           guesses[x][0] = 3;
                           guesses[x][m+1] = 3;
                   }
                   do {
                           int check = 0;
                           for (int y = 1;y<m+1;y++){
                               for (int x = 1;x<n+1;x++){
                                       mines[x][y] = 0;
                                       guesses[x][y] = 0;
                               }
                           }
                   for (int x = 0;x<nomines;x++){
                           mines [(int) (Math.random()*(n)+1)][(int) (Math.random()*(m)+1)] = 1;
                   }
                   for (int x = 0;x<n;x++){
                           for (int y = 0;y<m;y++){
                   if (mines[x+1][y+1] == 1){
                           check++;
                   }
                   }}
                   if (check == nomines){
                           allmines = true;
                           }}while (allmines == false);
                   for (int y = 0;y<m;y++){
                           for (int x = 0;x<n;x++){
                               if ((mines[x+1][y+1] == 0) || (mines[x+1][y+1] == 1)){
                                       perm[x][y] = perimcheck(x,y);
                               }
                                   b[x][y] = new JButton("?");
                                   b[x][y].addActionListener(this);
                                   b[x][y].addMouseListener(this);
                                   add(b[x][y]);
                                   b[x][y].setEnabled(true);
                           }//end inner for
                   }//end for
                   pack();
                   setVisible(true);
                   for (int y = 0;y<m+2;y++){
                   for (int x = 0;x<n+2;x++){
                   System.out.print(mines[x][y]);
                   }
                   System.out.println("");}
                   starttime = System.nanoTime();
           }//end constructor Mine()
    
           public void actionPerformed(ActionEvent e){
               found =  false;
                   JButton current = (JButton)e.getSource();
                   for (int y = 0;y<m;y++){
                           for (int x = 0;x<n;x++){
                                   JButton t = b[x][y];
                                   if(t == current){
                                           row=x;column=y; found =true;
                                   }
                           }//end inner for
                   }//end for
                   if(!found) {
                           System.out.println("didn't find the button, there was an error "); System.exit(-1);
                   }
                   Component temporaryLostComponent = null;
                   if (b[row][column].getBackground() == Color.orange){
                       return;
                   }else if (mines[row+1][column+1] == 1){
                           JOptionPane.showMessageDialog(temporaryLostComponent, "You set off a Mine!!!!.");
                           System.exit(0);
                   } else {
                           tmp = Integer.toString(perm[row][column]);
                           if (perm[row][column] == 0){
                                   tmp = " ";
                           }
                           b[row][column].setText(tmp);
                           b[row][column].setEnabled(false);
                           checkifend();
                           if (perm[row][column] == 0){
                               scan(row, column);
                               checkifend();
                           }}}
          
           public void checkifend(){
               int check= 0;
               for (int y = 0; y<m;y++){
                    for (int x = 0;x<n;x++){
               if (b[x][y].isEnabled()){
                       check++;
               }
                    }}
               if (check == nomines){
                       endtime = System.nanoTime();
                       Component temporaryLostComponent = null;
                       JOptionPane.showMessageDialog(temporaryLostComponent, "Congratulations you won!!! It took you "+(int)((endtime-starttime)/1000000000)+" seconds!");
               }
           }
    
           public void scan(int x, int y){
                   for (int a = 0;a<8;a++){
           if (mines[x+1+deltax[a]][y+1+deltay[a]] == 3){
              
           } else if ((perm[x+deltax[a]][y+deltay[a]] == 0) && (mines[x+1+deltax[a]][y+1+deltay[a]] == 0) && (guesses[x+deltax[a]+1][y+deltay[a]+1] == 0)){
               if (b[x+deltax[a]][y+deltay[a]].isEnabled()){
                   b[x+deltax[a]][y+deltay[a]].setText(" ");
                   b[x+deltax[a]][y+deltay[a]].setEnabled(false);
                   scan(x+deltax[a], y+deltay[a]);
          }
           } else if ((perm[x+deltax[a]][y+deltay[a]] != 0) && (mines[x+1+deltax[a]][y+1+deltay[a]] == 0)  && (guesses[x+deltax[a]+1][y+deltay[a]+1] == 0)){
                   tmp = new Integer(perm[x+deltax[a]][y+deltay[a]]).toString();
                   b[x+deltax[a]][y+deltay[a]].setText(Integer.toString(perm[x+deltax[a]][y+deltay[a]]));
                   b[x+deltax[a]][y+deltay[a]].setEnabled(false);   
           }
                   }}
          
           public int perimcheck(int a, int y){
                   int minecount = 0;
                           for (int x = 0;x<8;x++){
                                   if (mines[a+deltax[x]+1][y+deltay[x]+1] == 1){
                                           minecount++;
                                   }
                   }
                   return minecount;
           }
    
           public void windowIconified(WindowEvent e){
    
           }
    
           public static void main(String[] args){
                   new Mine();
           }
    
    
                    public void mouseClicked(MouseEvent e) {
                  
            }
    
    
    
                    @Override
                    public void mouseEntered(MouseEvent arg0) {
                            // TODO Auto-generated method stub
                          
                    }
    
                    @Override
                    public void mouseExited(MouseEvent arg0) {
                            // TODO Auto-generated method stub
                          
                    }
    
                    @Override
                    public void mousePressed(MouseEvent e) {
                            if (e.getButton() == MouseEvent.BUTTON3) {
                                    found =  false;
                        Object current = e.getSource();
                        for (int y = 0;y<m;y++){
                                for (int x = 0;x<n;x++){
                                        JButton t = b[x][y];
                                        if(t == current){
                                                row=x;column=y; found =true;
                                        }
                                }//end inner for
                        }//end for
                        if(!found) {
                                System.out.println("didn't find the button, there was an error "); System.exit(-1);
                        }
                        if ((guesses[row+1][column+1] == 0) && (b[row][column].isEnabled())){
                            b[row][column].setText("x");
                        guesses[row+1][column+1] = 1;
                        b[row][column].setBackground(Color.orange);
                        } else if (guesses[row+1][column+1] == 1){
                            b[row][column].setText("?");
                            guesses[row+1][column+1] = 0;
                            b[row][column].setBackground(null);
                        }}
                    }
    
                    @Override
                    public void mouseReleased(MouseEvent arg0) {
                            // TODO Auto-generated method stub
                          
                    }
    
    
    }//end class


3. Save file yang sudah di bikin tadi dengan nama Mine.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/?9cq1i6fp6sb44ie

Games Laser

Hayyy gann,,,  pikir" sekarang ini anak indonesia sering main game,,  tpi ternyata yg bikin games nya thu orang Luar Negri,,
Coba kita sebagai anak bangsa kita hobi main game, tpi game itu gaan bikinan anak bangsa sendiri....

Gan sekaran ini saya ingin membuat game Laser,,, langkah pertama" kita harus memiliki aplikasi notped ++ gann,,, hehehehe

1. Pertama - tama kita buka aplikasi noteped++ gan,,
2. Copas Coding di bawah ini,

Source Code :


import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;

public class Laser extends JFrame implements KeyListener {
       
        public static void main (String[] args){
                System.setProperty("java.util.Arrays.useLegacyMergeSort", "true");
                new laser();
        }
        static int score = 0;
        static boolean fire2 = false;
        static boolean wmd = false;
    static int deltax[] = {0,-1, 1, 0};
    static int deltay[] = {-1, 0, 0, 1};
        static int rand[] = { (int) (Math.floor(Math.random()*8+1)), (int) (Math.floor(Math.random()*8+1)), (int) (Math.floor(Math.random()*8+1)), (int) (Math.floor(Math.random()*8+1)), (int) (Math.floor(Math.random()*8+1)), (int) (Math.floor(Math.random()*8+1)), (int) Math.floor(Math.random()*8+1), (int) Math.floor(Math.random()*8+1), (int) (Math.floor(Math.random()*8+1)) };
        static Color[] colours = new Color[9];
        static Color[] colour =  {Color.BLACK, Color.blue, Color.WHITE, Color.magenta, (new Color (255,36,0)), Color.green, Color.cyan, (new Color (66,19,130)), Color.yellow};
        static Color[][] grid = new Color[14][23];
        static int energy = 0;
        static double pulse = 0;
        static double bullet = 0;
        static double clock = 0;
        static boolean fire = false;
        static boolean up = false;
        static boolean down = false;
        static boolean left = false;
        static boolean right = false;
        static int m = 16;
        static int n = 27;
        JLabel b[][];
        static int health = 15;
        static int centrex = 7;
        static int centrey = 19;
        static int ammo = 15;
        static boolean alive = true;
        static int num = 0;
        static Color[] bc = new Color[25];
        static int[] bx = new int[25];
        static int[] by = new int[25];
        static int tmp[][] = new int[14][23];
        static int count = 0;
        public laser(){
                for (int x = 0;x<25;x++){
                        bx[x] = -5;
                    by[x] = -5;
                }
                this.setDefaultCloseOperation(EXIT_ON_CLOSE);
                b = new JLabel [m][n];
        setLayout(new GridLayout(n,m));
        for (int y = 0;y<n;y++){
            for (int x = 0;x<m;x++){
                    b[x][y] = new JLabel( );
                    b[x][y].setBackground(Color.BLACK);
                    add(b[x][y]);
                    b[x][y].setEnabled(true);
                    b[x][y].setOpaque(true);
                    b[x][y].setBorder(BorderFactory.createLineBorder(Color.BLACK));
                    b[x][y].setPreferredSize(new Dimension(50,25));
            }
    }
        setFocusable(true);
        addKeyListener(this);
        pack();
        setVisible(true);
        for (int y = 0;y<23;y++){
            grid[0][y] = Color.gray;
            grid[13][y] = Color.gray;
    }
    for (int x = 0;x<14;x++){
            grid[x][0] = Color.gray;
            grid[x][22] = Color.gray;
    }
        go();
        }
       
        public void colours(){
                int random = (int) (Math.floor(Math.random()*8+1));
                colours[8] = colours[7];
                colours[7] = colours[6];
                colours[6] = colours[5];
                colours[5] = colours[4];
                colours[4] = colours[3];
                colours[3] = colours[2];
                colours[2] = colours[1];
                colours[1] = colours[0];
                colours[0] = colour[random];
                for (int y = 0;y<9;y++){
                        b[0][(y)*3].setBackground(colours[y]);
                        b[0][(y)*3+1].setBackground(colours[y]);
                        b[0][(y)*3+2].setBackground(colours[y]);
                }
        }
       
        public void combo(){
                for (int x = 0;x<12;x++){
                        for (int y = 0;y<21;y++){
                                if (grid[x+1][y+1] != Color.BLACK){
                                        count = 0;
                                combochk(x, y, grid[x+1][y+1]);
                                        for (int x2 = 0;x2<12;x2++){
                                                for (int y2 = 0;y2<21;y2++){
                                                        if (count > 3){
                                                        if (tmp[x2+1][y2+1] == 1){
                                                                grid[x2+1][y2+1] = Color.BLACK;
                                                        }
                                                  }
                                                        tmp[x2+1][y2+1] = 0;
                                                }      
                                }
                                        if (count > 3){
                                                score++;
                                        energy+=6;
                                        }
                        }}
                }
        }
       
        public void combochk(int x, int y, Color c){
        for (int a = 0;a<4;a++){
                if ((grid[x+1+deltax[a]][y+1+deltay[a]] == c) && (tmp[x+deltax[a]+1][y+deltay[a]+1] == 0)){
                        tmp[x+deltax[a]+1][y+deltay[a]+1] = 1;
                        count++;
             combochk(x+deltax[a], y+deltay[a], c);
        }}}
       
        public void power(){
                        for (int y = 0;y<27;y++){
                                if ((27-energy) <= y){
                                        b[15][y].setBackground(Color.green);
                                } else {
                                b[15][y].setBackground(Color.red);
                                }
                        }
                }
       
        public void gen(){
                int randi;
                int geni;
                for (int x = 0;x<12;x++){
                        for (int y = 19;y>=0;y--){
                                grid[x+1][y+1+1] = grid[x+1][y+1];
                        }
                }
                for (int x = 0; x<12;x++){
                        geni = (int) (Math.floor(Math.random()*100+1));
                        if (geni<50){
                        randi = (int) (Math.floor(Math.random()*8+1));
                        } else {
                                randi = 0;
                        }
                        grid [x+1][1] = colour[randi];
                }
        }
       
        public void match(){
                for (int x = 0;x<12;x++){
                        for (int y = 0;y<21;y++){
                                b[x+2][y].setBackground(grid[x+1][y+1]);
                        }
                }
        }
       
        public void go(){      
                setup();
                int time = 4000;
                clock = System.currentTimeMillis();
                bullet = System.currentTimeMillis();
                pulse = System.currentTimeMillis();
                do{
                        if (health < 0){
                                Component temporaryLostComponent = null;
                                JOptionPane.showMessageDialog(temporaryLostComponent, "Game Over! You scored: "+score+". Well done!");
                    System.exit(0);
                        }
                        ship();
                        if (System.currentTimeMillis()-pulse > time){
                                if (time>1000){
                                time-=10;
                                }
                        gen();
                        match();
                        pulse = System.currentTimeMillis();
                        }
                        if (System.currentTimeMillis()-clock > 300){
                                regen();
                                clock = System.currentTimeMillis();
                        }
                        if (System.currentTimeMillis()-bullet > 30){
                                health();
                                power();
                                combo();
                        projectile();
                                bullet = System.currentTimeMillis();
                        }
                        if (up == true){
                                up();
                                up = false;
                        }
                        if  (down == true){
                                down();
                                down = false;
                        }
                        if (left == true){
                                left();
                                left = false;
                        }
                        if  (right == true){
                                right();
                                right = false;
                        }
                        if (fire == true){
                                if ((ammo>0) && (num<25)){
                                fire();
                                colours();
                                projectile();
                                }
                        }
                                if (fire2 == true){
                                        wmd();
                                        fire2 = false;
                                }
                                fire = false;
                }while (alive == true);
        }
       
        public void wmd(){
                energy = 0;
                for (int x = 0;x<12;x++){
                        for (int y = 0;y<21;y++){
                                grid[x+1][y+1] = Color.BLACK;
                        }
                }
        }
       
        public void regen(){
                if (ammo<12){
                ammo+=1;
                ammo(Color.blue);
                } else {
                        ammo = 15;
                        ammo(Color.blue);
                }
        }
       
        public void setup(){
                for (int x = 1;x<13;x++){
                        for(int y = 1;y<22;y++){
                                grid[x][y] = Color.BLACK;
                        }
                }
                for (int x = 0;x<9;x++){
                        colours[x] = colour[rand[x]];
                }
                for (int y = 0;y<9;y++){
                        b[0][(y)*3].setBackground(colours[y]);
                        b[0][(y)*3+1].setBackground(colours[y]);
                        b[0][(y)*3+2].setBackground(colours[y]);
                }
                power();
                ship();
                health();
                ammo(Color.blue);
                gen();
                match();
        }
       
        public void ammo(Color l){
                for (int x = 1;x<ammo;x++){
                         b[x][26].setBackground(l);
                         b[x][25].setBackground(l);
                }
        }
        public void health(){
                for (int x = 1;x<15;x++){
                        b[x][24].setBackground(Color.BLACK);   
                }
                for (int x = 1;x<health;x++){
                        if (x<3){
                                b[x][24].setBackground(Color.red);     
                        } else {
                         b[x][24].setBackground(Color.green);
                }
                        }
        }
       
        public void ship(){
                b[centrex+1][centrey].setBackground(Color.WHITE);
                b[centrex-1][centrey].setBackground(Color.WHITE);
                b[centrex][centrey-1].setBackground(Color.WHITE);
                b[centrex][centrey-2].setBackground(Color.WHITE);
                b[centrex+1][centrey-1].setBackground(Color.WHITE);
                b[centrex-1][centrey-1].setBackground(Color.WHITE);
        }
       
        public void fire(){
                num++;
                bx[num-1] = centrex;
                by[num-1] = centrey-3;
                bc[num-1] = colours[8];
                ammo(Color.orange);
                if (ammo>-1){
                ammo-=6;
                }
                ammo(Color.BLUE);
        }
       
        public void projectile(){
                boolean hit = false;
                Color tmpbc[] = new Color[25];
                int tmpbx[] = new int[25];
                int tmpby[] = new int[25];
                for (int y = 0;y<25;y++){
                        tmpbc[y] = bc[y];
                        tmpbx[y] = bx[y];
                        tmpby[y] = by[y];
                }
                for (int x = 0;x<num;x++){
                if ((by[x] > 0) && (checkhit(bx[x],by[x]) == false)){
                        b[bx[x]][by[x]].setBackground(Color.BLACK);
                } else {
        hit = true;
                if (hit == true){
                        grid[bx[x]-2+1][by[x]+1] = bc[x];
                        if(x < 25){
                                if (x != 24){
                        if (tmpbx[x+1] == -5){
                                tmpbc[x] = null;
                                tmpbx[x] = -5;
                                tmpby[x] = -5;
                        } else {
                                for (int c = x;c<num;c++){
                                        tmpbc[c] = tmpbc[c+1];
                                        tmpbx[c] = tmpbx[c+1];
                                        tmpby[c] = tmpby[c+1];
                                }
                        }
                        } else {
                                tmpbc[x] = null;
                                tmpbx[x] = -5;
                                tmpby[x] = -5;
                        }
                        num--;
                }
                        x--;
                        for (int y = 0;y<25;y++){
                                bc[y] = tmpbc[y];
                                bx[y] = tmpbx[y];
                                by[y] = tmpby[y];
                        }
                }
                }
                }
                try {
                        Thread.sleep(30L);
                } catch (InterruptedException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                }
                for (int x = 0;x<num;x++){
                        if ((by[x] > 0) && (checkhit(bx[x],by[x]) == false)){
                by[x]--;
                b[bx[x]][by[x]].setBackground(bc[x]);
                        }
                }
        }
       
        public boolean checkhit(int bx, int by){
                if(b[bx][by-1].getBackground() == Color.BLACK){
                        return false;
                } else{
                        return true;
                }
        }
       
       
        public void right(){
                if ((b[centrex+1+1][centrey].getBackground() != Color.BLACK) ||
                (b[centrex+1+1][centrey-1].getBackground() != Color.BLACK) ||
                (b[centrex+1][centrey-1-1].getBackground() != Color.BLACK)){
                        health--;
                }
                b[centrex+1][centrey].setBackground(Color.BLACK);
                b[centrex-1][centrey].setBackground(Color.BLACK);
                b[centrex][centrey-1].setBackground(Color.BLACK);
                b[centrex][centrey-2].setBackground(Color.BLACK);
                b[centrex+1][centrey-1].setBackground(Color.BLACK);
                b[centrex-1][centrey-1].setBackground(Color.BLACK);
                centrex++;
                b[centrex+1][centrey].setBackground(Color.WHITE);
                b[centrex-1][centrey].setBackground(Color.WHITE);
                b[centrex][centrey-1].setBackground(Color.WHITE);
                b[centrex][centrey-2].setBackground(Color.WHITE);
                b[centrex+1][centrey-1].setBackground(Color.WHITE);
                b[centrex-1][centrey-1].setBackground(Color.WHITE);
        }
       
        public void left(){
                if ((b[centrex-1-1][centrey].getBackground() != Color.BLACK) ||
                (b[centrex-1][centrey-2].getBackground() != Color.BLACK) ||
                (b[centrex-1-1][centrey-1].getBackground() != Color.BLACK)){
                        health--;
                }
                b[centrex+1][centrey].setBackground(Color.BLACK);
                b[centrex-1][centrey].setBackground(Color.BLACK);
                b[centrex][centrey-1].setBackground(Color.BLACK);
                b[centrex][centrey-2].setBackground(Color.BLACK);
                b[centrex+1][centrey-1].setBackground(Color.BLACK);
                b[centrex-1][centrey-1].setBackground(Color.BLACK);
                centrex--;
                b[centrex+1][centrey].setBackground(Color.WHITE);
                b[centrex-1][centrey].setBackground(Color.WHITE);
                b[centrex][centrey-1].setBackground(Color.WHITE);
                b[centrex][centrey-2].setBackground(Color.WHITE);
                b[centrex+1][centrey-1].setBackground(Color.WHITE);
                b[centrex-1][centrey-1].setBackground(Color.WHITE);
        }
       
        public void up(){
                if ((b[centrex+1][centrey-1-1].getBackground() != Color.BLACK) ||
                (b[centrex-1][centrey-1-1].getBackground() != Color.BLACK) ||
                (b[centrex][centrey-2-1].getBackground() != Color.BLACK)){
                        health--;
                }
                b[centrex+1][centrey].setBackground(Color.BLACK);
                b[centrex-1][centrey].setBackground(Color.BLACK);
                b[centrex][centrey-1].setBackground(Color.BLACK);
                b[centrex][centrey-2].setBackground(Color.BLACK);
                b[centrex+1][centrey-1].setBackground(Color.BLACK);
                b[centrex-1][centrey-1].setBackground(Color.BLACK);
                centrey--;
                b[centrex+1][centrey].setBackground(Color.WHITE);
                b[centrex-1][centrey].setBackground(Color.WHITE);
                b[centrex][centrey-1].setBackground(Color.WHITE);
                b[centrex][centrey-2].setBackground(Color.WHITE);
                b[centrex+1][centrey-1].setBackground(Color.WHITE);
                b[centrex-1][centrey-1].setBackground(Color.WHITE);
        }
       
        public void down(){
                if ((b[centrex][centrey].getBackground() != Color.BLACK) ||
                (b[centrex-1][centrey+1].getBackground() != Color.BLACK) ||
                (b[centrex+1][centrey+1].getBackground() != Color.BLACK)){
                        health--;
                }
                b[centrex+1][centrey].setBackground(Color.BLACK);
                b[centrex-1][centrey].setBackground(Color.BLACK);
                b[centrex][centrey-1].setBackground(Color.BLACK);
                b[centrex][centrey-2].setBackground(Color.BLACK);
                b[centrex+1][centrey-1].setBackground(Color.BLACK);
                b[centrex-1][centrey-1].setBackground(Color.BLACK);
                centrey++;
                b[centrex+1][centrey].setBackground(Color.WHITE);
                b[centrex-1][centrey].setBackground(Color.WHITE);
                b[centrex][centrey-1].setBackground(Color.WHITE);
                b[centrex][centrey-2].setBackground(Color.WHITE);
                b[centrex+1][centrey-1].setBackground(Color.WHITE);
                b[centrex-1][centrey-1].setBackground(Color.WHITE);
        }
       
        public boolean checkmove(int x, int y, int dx, int dy){
                if (((x-1+dx) > 0) && ((x+1+dx) < 15) && ((y-2+dy) > -1) && ((y+dy) < 24)){
                        return true;
                } else {
                        return false;
                }
        }

        @Override
        public void keyPressed(KeyEvent e) {
                if (e.getKeyCode() == KeyEvent.VK_ENTER){              
                        if (energy > 25){
                                fire2 = true;
                        }
                } else if (e.getKeyCode() == KeyEvent.VK_UP){
                                if (checkmove(centrex, centrey, 0,-1) == true){
                                up = true;
                                }
                                } else if (e.getKeyCode() ==

KeyEvent.VK_RIGHT){
                                        if (checkmove(centrex, centrey, 1,0) == true){
                                        right = true;
                                        }
                                } else if (e.getKeyCode() ==

KeyEvent.VK_LEFT){
                                        if (checkmove(centrex, centrey, -1,0) == true){
                                        left = true;
                                        }
                                } else if (e.getKeyCode() ==

KeyEvent.VK_DOWN){
                                        if (checkmove(centrex, centrey, 0,1) == true){
                                        down = true;
                                        }
                                }
               
        }

        @Override
        public void keyReleased(KeyEvent e) {
                if (e.getKeyCode() == KeyEvent.VK_SPACE){
                        fire = true;
                        }
        }

        @Override
        public void keyTyped(KeyEvent e) {

        }
}


3. Save File tersebut dengan nama Laser.java
4. Komfile file tersebut dengan CMD gan,,
5. Selesai deh gan bikin game Lasernya dan lihat hasilnya gann

Outputnya :


Gaannn  jangan lupa komentar dan saran nya yy gannn,,
thnks gann,,  SALAM SUKSES buat gan semuanya,,,,   :)


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