ObjetoMovil.java

   1 /**
   2  * @author Oscar Dario Alonso P
   3  * @author Roger Eduardo Urrego
   4  */
   5 
   6 public abstract class ObjetoGrafico {
   7         private boolean visible =false;
   8         private int posX;
   9         private int posY;
  10         private int ancho;
  11         private int alto;
  12         public ObjetoGrafico (int x, int y, int an, int bl){
  13                 posX = x;
  14                 posY = y;
  15                 ancho = an;
  16                 alto = bl;
  17                 
  18         }
  19     public abstract void paint (Graphics g);
  20 
  21     /**
  22          * @param visible  the visible to set
  23          * @uml.property  name="visible"
  24          */
  25     public void setVisible(boolean v) {
  26            visible = v;
  27     }
  28     public void moverArriba (int dy){
  29            posY -= dy;
  30     }
  31     public void moverAbajo (int dy){
  32            posY += dy;
  33     }
  34         public void moverIzquierda (int dx){
  35            posX -= dx;
  36         }   
  37     public void moverDerecha (int dx){
  38            posX += dx;
  39     }
  40     /**
  41          * @return  the visible
  42          * @uml.property  name="visible"
  43          */
  44     public boolean getVisible(){
  45            return visible;
  46     }
  47     /**
  48          * @return  the posY
  49          * @uml.property  name="posY"
  50          */
  51     public int getPosY() {
  52                 return posY;
  53         }
  54     /**
  55          * @return  the posX
  56          * @uml.property  name="posX"
  57          */
  58     public int getPosX() {
  59                 return posX;
  60     }
  61     /**
  62          * @param posY  the posY to set
  63          * @uml.property  name="posY"
  64          */
  65     public void setPosY(int y) {
  66                 posY = y;
  67     }
  68     /**
  69          *@param posX  the posX to set
  70          * @uml.property  name="posX"
  71          */
  72     public void setPosX(int x) {
  73                 posX = x;
  74     }
  75     /**
  76          * @return  the ancho
  77          * @uml.property  name="ancho"
  78          */
  79     public int getAncho() {
  80                 return ancho;
  81         }
  82     /**
  83          * @param ancho  the ancho to set
  84          * @uml.property  name="ancho"
  85          */
  86     public void setAncho(int an) {
  87                 ancho = an;
  88         }
  89     /**
  90          * @return  the alto
  91          * @uml.property  name="alto"
  92          */
  93     public int getAlto() {
  94         return alto;
  95         }
  96     /**
  97          * @param alto  the alto to set
  98          * @uml.property  name="alto"
  99          */
 100     public void setAlto(int bl) {
 101         alto = bl;
 102     }
 103     public boolean colisiona (ObjetoGrafico otro){
 104         Rectangle r1 = new Rectangle (posX, posY, ancho, alto);
 105         Rectangle r2 = new Rectangle (otro.posX, otro.posY, otro.ancho, otro.alto);
 106         return r1.intersects(r2) && getVisible() && otro.getVisible();
 107     }
 108 }

CategoryJava | CategoryProgramacion

Java/Programas/FroggerGame/ObjetoGrafico.java (last edited 2008-11-13 10:44:40 by OscarAlonso)