Alexis deleted public_class_Jugador_extends_Ente__.html  over 8 years ago

Commit id: fa7bc399ea66b2d9f37d79b2fa305322a7649f56

deletions | additions      

       

public_double_getGanancia_double_precioJuego__.html  Block__759391447126365658.html  Juego_gtav_new_Jeugo_Gta__.html  public_class_Jugador_extends_Ente__.html           

public class Jugador extends Ente implements Dibujable,Actualizable{ 
private BufferedImage imagen; 
private int vel = 4; 
private int vida = 200; 

//Para los efectos de vuelo 
private BufferedImage[] efectosVuelo; 
private long banderaEfectoVuelo = System.nanoTime(); 
private long TiempoT0a1_nave = 1000000000/2; 
private long TiempoT1a0_nave = 1000000000/2; 
private int efectoVueloActualIndice = 0; 
private BufferedImage efectoVueloActual; 

//Para los disparos 
private long banderaDisparos = System.nanoTime(); 
private long rateDisparos = 1000000000 /2 ; 
public boolean dispara = false; 

//Para los efectos de rayo 
private RayoJugador rayo = new RayoJugador(); 

//Para estilo disparo 
private enum tipoDisparo {SIMPLE, RAYO}; 
private tipoDisparo disparoActual = tipoDisparo.SIMPLE; 

public Jugador(final double x, final double y) { 
this.x = x; 
this.y = y; 
efectosVuelo = new BufferedImage[2]; 
efectosVuelo[0] = Cargador.cargarImagen("/imagenes/efectos/naves/Efecto1-01.png"); 
efectosVuelo[1] = Cargador.cargarImagen("/imagenes/efectos/naves/Efecto1-02.png"); 


imagen = Cargador.cargarImagen("/imagenes/Nave2.1.png"); 
ancho = imagen.getWidth(); 
alto = imagen.getHeight(); 

public void dibujar(Graphics2D g2) { 
g2.drawImage(imagen,(int) x,(int) y, null); 
g2.drawImage(efectoVueloActual, ((int)x) +24, ((int)y) +56, null); 


switch (disparoActual) { 
case SIMPLE: 

break; 
case RAYO: 
rayo.dibujar(g2, x, y); 
break; 

g2.fillRect(Constantes.ANCHO_VENTANA-100-50, Constantes.ALTO_VENTANA-50,(int) rayo.getEnergia()*100 /300, 10); 


public void actualizar() { 
verificarControles(); 
cambiarEfectoVuelo(); 
rayo.actualizar(); 


private void verificarControles(){ 
if(GestorControles.teclado.izquierda){ 
if (x - vel >= 0) { 
x-= vel; 

}else if(GestorControles.teclado.derecha){ 
if (x + vel + ancho <= Constantes.ANCHO_VENTANA) { 
x+= vel; 


if(GestorControles.teclado.disparar){ 
switch (disparoActual) { 
case SIMPLE: 
if(System.nanoTime() - banderaDisparos > rateDisparos){ 
dispara = true; 
banderaDisparos = System.nanoTime(); 

break; 
case RAYO: 
if(rayo.getEnergia()*100/300 > 20){ 
rayo.en_carga_rayo = true; 

break; 

}else{ 
rayo.reinciarRayo(); 


if(GestorControles.teclado.cambio_arma){ 
GestorControles.teclado.cambio_arma = false; 
if(disparoActual == tipoDisparo.SIMPLE){ 
disparoActual = tipoDisparo.RAYO; 
}else if(disparoActual == tipoDisparo.RAYO){ 
disparoActual = tipoDisparo.SIMPLE; 
rayo.reinciarRayo(); 





private void cambiarEfectoVuelo(){ 
efectoVueloActual = efectosVuelo[efectoVueloActualIndice]; 
if(efectoVueloActualIndice == 0){ 
if(System.nanoTime() - banderaEfectoVuelo > TiempoT0a1_nave){ 
efectoVueloActualIndice = 1; 
banderaEfectoVuelo = System.nanoTime(); 

}else if(efectoVueloActualIndice == 1){ 
if(System.nanoTime() - banderaEfectoVuelo > TiempoT1a0_nave){ 
efectoVueloActualIndice = 0; 
banderaEfectoVuelo = System.nanoTime(); 




public int getAncho() { 
return ancho; 

public int getAlto() { 
return alto; 

public RayoJugador getRayo() { 
return rayo; 

public Rectangle2D.Double getBoundsRayo(){ 
return new Rectangle2D.Double((int) x + 28, rayo.tope_rayo, 35-28, (int) (y - rayo.tope_rayo));