Android Open Source - zomblind pantalla






From Project

Back to project page zomblind.

License

The source code is released under:

Apache License

If you think the Android project zomblind listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/*******************************************************************************
 * Copyright 2013 Antonio Fern?ndez Ares (antares.es@gmail.com)
 * //from  w ww.j  av  a 2s.  c o  m
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 ******************************************************************************/
package antares.zomblind.in;

import android.content.Context;
import android.view.Display;
import android.view.MotionEvent;
import antares.zomblind.ZomblindActivity;
import antares.zomblind.core.objetos.ArmaLista.tipo_arma;

public class Pantalla {

  public float x = 50;
  public float y = 50;

  public float x0;
  public float y0;

  public int width;
  public int height;

  public String action = "";

  private ZomblindActivity _z;

  public Pantalla(Context ctx) {
    _z = (ZomblindActivity) ctx;
    Display display = _z.getWindowManager().getDefaultDisplay();
    width = display.getWidth();
    height = display.getHeight();

  }

  public int zona(float x, float y) {
    if (y < height * 0.25) {
      return 1;

    } else if (y < height * 0.75) {
      if (x < width * 0.25){
        return 3;
      }else if(x < width * 0.75){
        return 0;
      }else {
        return 4;
      }
      

    } else {
      return 2;

    }

  }
  
  public int isDisparando(){
    if(action == "disparo"){
      action = "";
      return _z._orientacion._zona_mirando;
    }else{
      return -1;
    }

  }

  public void update(MotionEvent evento) {

    if (_z.empezar == false) {
      _z.empezar = true;
    } else {

      if (evento.getAction() == MotionEvent.ACTION_DOWN) {
        x = evento.getX();
        y = evento.getY();

        x0 = x;
        y0 = y;
      } else if (evento.getAction() == MotionEvent.ACTION_UP) {
        x = evento.getX();
        y = evento.getY();

        if (zona(x,y)== 0 && zona(x0,y0)==0){
          action ="disparo";
          
          //Codigo del disparo
        }else if(zona(x,y)== 1 && zona(x0,y0)==0){
          action = "info_jugador";
          _z._entorno._jugador.info();
          //Codigo de la informaci?n del jugador
          
        }else if(zona(x,y)== 2 && zona(x0,y0)==0){
          action = "info_armas";
          //Informaci?n del arma
          
        }else if(zona(x,y)== 3 && zona(x0,y0)==0){
          action = "cambio_arma_cuerpo";
          
          //Codigo del cambio de arma cuerpo a cuerpo
          
        }else if(zona(x,y)== 4 && zona(x0,y0)==0){
          action = "cambio_arma_distancia";
          
          //Codigo del cambio de arma a distancia
          
        }else if(zona(x0,y0)== 4 && zona(x,y)==4){
          _z._entorno._jugador._armas.next(tipo_arma.DISTANCIA);
          _z._habladora.decir(_z._entorno._jugador._armas.getArma(tipo_arma.DISTANCIA)._name);
        }else if(zona(x0,y0)== 3 && zona(x,y)==3){
          _z._entorno._jugador._armas.next(tipo_arma.CUERPO);
          _z._habladora.decir(_z._entorno._jugador._armas.getArma(tipo_arma.CUERPO)._name);
        }
        
      }

//      synchronized (this) {

        // Detectamos eventos

//        action = String.valueOf(evento.getAction());
//        if (evento.getAction() == MotionEvent.ACTION_DOWN) {
//          x = evento.getX();
//          y = evento.getY();
//          Log.v("Entorno", x + "," + y);
//
//          if (_z._orientacion.isCalibrate() == false) {
//            _z._habladora.say("Dispositivo calibrado");
//            _z._orientacion.calibrate();
//          }
//        } else if (evento.getAction() == MotionEvent.EDGE_BOTTOM) {
//          x = evento.getX();
//          y = evento.getY();
//          Log.v("Entorno", x + "," + y);
//        }
//      }
    }
  }

}




Java Source Code List

antares.zomblind.ZomblindActivity.java
antares.zomblind.core.Jugador.java
antares.zomblind.core.Nucleo.java
antares.zomblind.core.levels.L000_menu.java
antares.zomblind.core.levels.NivelInfo.java
antares.zomblind.core.levels.checker.GolpeFrontal.java
antares.zomblind.core.levels.checker.Todos.java
antares.zomblind.core.levels.checker._Chequeador.java
antares.zomblind.core.levels.conditions.SinZombies.java
antares.zomblind.core.levels.conditions._Condicion.java
antares.zomblind.core.levels.generate.AleatorioFlojos.java
antares.zomblind.core.levels.generate.AleatorioTodos.java
antares.zomblind.core.levels.generate._Generador.java
antares.zomblind.core.levels.instancia.java
antares.zomblind.core.npcs.NpcData.java
antares.zomblind.core.npcs.NpcLista.java
antares.zomblind.core.npcs.npc.java
antares.zomblind.core.objetos.ArmaData.java
antares.zomblind.core.objetos.ArmaLista.java
antares.zomblind.core.objetos.Arma.java
antares.zomblind.core.objetos.Municion.java
antares.zomblind.core.opciones.java
antares.zomblind.in.acelerometro.java
antares.zomblind.in.orientacion.java
antares.zomblind.in.pantalla.java
antares.zomblind.in.teclado.java
antares.zomblind.out.debug.java
antares.zomblind.out.habladora.java
antares.zomblind.out.interfaz.java
antares.zomblind.out.vibrador.java