Advertisement
zacmaster

juego(Torreta)

May 19th, 2015
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.02 KB | None | 0 0
  1. package juego;
  2.  
  3. import java.awt.Color;
  4.  
  5. import entorno.*;
  6.  
  7.  
  8. public class Juego extends InterfaceJuego
  9. {
  10.     private Entorno entorno;
  11.     torreta torreta;
  12.     Bala[] Bala;
  13.     Juego()
  14.     {
  15.         // Inicializa el objeto entorno, pero aun no lo inicia.
  16.         entorno = new Entorno(this, "Zombieland - Versión 0.01", 800, 600);
  17.         torreta = new torreta(100, entorno.alto()-500);
  18.         //Bala= new Bala(300,entorno.alto()-500);
  19.         this.Bala = new Bala[10];
  20.         for(int i = 0; i<this.Bala.length; i++) {
  21.             this.Bala[i] = new Bala();
  22.         }
  23.        
  24.    
  25.        
  26.        
  27.         /*
  28.          * Es fundamental que recién al final del constructor de la clase Juego se
  29.          * inicie el objeto entorno de la siguiente manera.
  30.          */
  31.         entorno.iniciar();
  32.     }
  33.  
  34.     /*
  35.      * Durante el juego, el método tick() será ejecutado en cada instante y
  36.      * por lo tanto es el método más importante de esta clase. Aquí se debe
  37.      * actualizar el estado interno del juego para simular el paso del tiempo
  38.      * (ver el enunciado del TP para mayor detalle).
  39.      */
  40.     public void tick()
  41.     {
  42.  
  43.         torreta.dibujarse(entorno);
  44.     //  Bala.dibujarse(entorno);
  45.         for (int i=0;i<Bala.length;i++)
  46.         {
  47.                 Bala[i].dibujarse(entorno);
  48.             }      
  49.        
  50.        
  51.         entorno.escribirTexto("el que lee esto, deme 50$",300,600);
  52.         entorno.escribirTexto("Kevin Zarate",720, 20);
  53.        
  54.    
  55.         //MOVER LA TORRETA
  56.         if (entorno.estaPresionada(entorno.TECLA_IZQUIERDA) && torreta.getX() > 5)
  57.             torreta.moverIzquierda();
  58.         if (entorno.estaPresionada(entorno.TECLA_DERECHA) && torreta.getX() < entorno.ancho() -5)
  59.             torreta.moverDerecha();
  60.         if (entorno.estaPresionada(entorno.TECLA_ARRIBA) && torreta.getY()<entorno.alto()-5)
  61.             torreta.moverArriba();
  62.         if (entorno.estaPresionada(entorno.TECLA_ABAJO) && torreta.getY()<600)
  63.             torreta.moverAbajo();
  64.    
  65.         if (!entorno.estaPresionada('P'))
  66.         {
  67.             for (int i=0;i<Bala.length;i++)
  68.             //{
  69.                 //if (!pelotita[i].getAtrapada())
  70.                 //{
  71.                     {Bala[i].avanzar();
  72.                 }
  73.             }
  74.        
  75.     }
  76.  
  77.     @SuppressWarnings("unused")
  78.     public static void main(String[] args)
  79.     {      
  80.         Juego juego = new Juego();
  81.     }
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement