Angel.java

   1 /**
   2  * @author Juan David Marin
   3  */
   4 
   5 import java.awt.Color;
   6 import java.awt.Frame;
   7 import java.io.BufferedReader;
   8 import java.io.FileInputStream;
   9 import java.io.FileNotFoundException;
  10 import java.io.IOException;
  11 import java.io.InputStreamReader;
  12 import java.io.ObjectInputStream;
  13 
  14 public class Interfaz {
  15         private static final long serialVersionUID = -1982217312829381351L;
  16 
  17         public static void main(String[] args) {
  18                 Frame marco = new Frame("Dibujo");
  19                 System.out.println("WRITE  YOUR  NAME");
  20                 
  21                 BufferedReader teclado = new BufferedReader(new InputStreamReader (System.in) );
  22                 
  23                 ListaPuntajes listaPuntajes = null;
  24                 ObjectInputStream archivo = null;
  25                 try {
  26                         archivo = new ObjectInputStream(new FileInputStream(Constantes.nombreArchivo));
  27                         listaPuntajes = (ListaPuntajes) archivo.readObject();
  28                         archivo.close();
  29                 } catch (FileNotFoundException e1) {
  30                         listaPuntajes = new ListaPuntajes();
  31                 } catch (IOException e1) {
  32                         e1.printStackTrace();
  33                 } catch (ClassNotFoundException e) {
  34                         e.printStackTrace();
  35                 } 
  36                 
  37                 String nombreJugador = null;
  38                 try {
  39                         nombreJugador = teclado.readLine();
  40                 }
  41                 catch (IOException e) {
  42                         // TODO: handle exception
  43                         System.out.println("Error de entrada");
  44                 
  45                 }
  46                 Puntaje puntaje = new Puntaje(0,700,500,500, null);
  47                 puntaje.setNombre (nombreJugador);
  48                 
  49                 listaPuntajes.add (puntaje);
  50                 System.out.println("LIST OF PLAYERS");
  51                 System.out.println("NAME \t SCORE");
  52                 
  53                 
  54                 for (int i = 0; i < listaPuntajes.getNumPunt(); i++) {
  55                         Puntaje p = listaPuntajes.get(i);
  56                         System.out.println(p.getNombre() + " \t " + p.getCantidad());
  57                 }
  58                 
  59                 
  60                 GestionVentana g = new GestionVentana(listaPuntajes);
  61                 marco.addWindowListener(g);
  62                 marco.setVisible (true);
  63                 
  64                 
  65                 marco.setBackground(new Color(0,150, 250));
  66                 Lienzo lienzo = new Lienzo ();
  67                 marco.add (lienzo);
  68                 
  69                 
  70                 Angel angel = new Angel (800, 800, 130, 130, Color.pink);
  71                 lienzo.add (angel);
  72         
  73                 Heaven heaven = new Heaven (1050,10,180,240,lienzo, angel, puntaje);
  74                 lienzo.add (heaven);
  75                 
  76                 
  77                 Luna luna = new Luna (0 ,0 ,190 ,190, lienzo, angel, puntaje, null);
  78                 lienzo.add (luna);
  79                 
  80                 Thread hilos8 = new Thread();
  81         hilos8.start();
  82         
  83         hilos8 = new Thread(luna);
  84              hilos8.start();
  85         
  86                 
  87                 
  88                 // Nubes
  89                 Nube [] nubes = new Nube[5];
  90                 Thread[] hilos = new Thread[5];
  91                 Nube [] nubes1 = new Nube[5];
  92                 Thread[] hilos1 = new Thread[5];
  93                 Nube [] nubes2 = new Nube[5];
  94                 Thread[] hilos2 = new Thread[5];
  95                 
  96                 for(int i = 0; i < 5; i++){
  97                         nubes [i]  = new Nube ( i * 200,280,90,90, lienzo, angel, puntaje);
  98                         lienzo.add(nubes[i]);
  99                         
 100                          hilos[i] = new Thread(nubes [i]);
 101                      hilos[i].start();
 102                 }
 103                 for(int i = 0; i < 5; i++){
 104                         nubes1 [i]  = new Nube ( i * 290,370,90,90,lienzo, angel, puntaje);
 105                         lienzo.add(nubes1[i]);
 106                         
 107                         hilos1 [i] = new Thread(nubes1[i]);
 108                 hilos1[i].start();
 109                 }
 110                 for(int i = 0; i < 5; i++){
 111                         nubes2 [i]  = new Nube ( i * 370,500,90,90,  lienzo, angel, puntaje);
 112                         lienzo.add(nubes2[i]);
 113                         
 114                         hilos2 [i]= new Thread(nubes2[i]);
 115                 hilos2[i].start();
 116                 }
 117                                 
 118 
 119                 EscuchaTeclas escucha = new EscuchaTeclas (lienzo ,angel);
 120             marco.addKeyListener(escucha);
 121                 lienzo.add(puntaje);
 122                 marco.setSize(1280, 1024);
 123                 marco.setVisible(true);
 124         }
 125 }

CategoryJava | CategoryProgramacion


CategoryProgramacion

Java/Angel/Interfaz.java (last edited 2009-05-20 13:41:39 by Juan David Marin Useda)