Package graphics

Source Code of graphics.GraphicsHidingPlace

package graphics;

import vehicles.RobberyCar;
import javax.swing.*;

import route.Route;

import java.awt.*;

import _main.Game;
import cross.*;

public class GraphicsHidingPlace extends AbstractGraphicsObject {

  int xp;
  int yp;
  Icon image;
  int rotation;
  Draw draw;
  HidingPlace cr;
  Icon table1;
 
  /**
   * GraphicsHidingPlace konstruktora, beolvassuk a felhasznalt kepeket a megfelelo attributumokba
   * a kesobbi felhasznalas celjabol
   */
  public GraphicsHidingPlace(){
     image = new ImageIcon("images/rejtekhely.gif","rejtekhely"); //egy ilyen imageIcont kell letrehozni
     table1 = new ImageIcon("images/stop.gif","stoptabla"); //egy ilyen imageIcont kell letrehozni
  }
  /**
   * Beallitjuk a pozicio erteket
   * @param xpos: x koordinata
   * @param ypos: y koordinata
   */
  public void setPosition(int xpos,int ypos){
    xp = xpos;
    yp = ypos;
  }
  /**
   * Pozicio elkerese
   * @return Point : koordinata
   */
  public Point getPosition(){
    return new Point(xp,yp);
  }
 
  /**
   * Beallitja az adott Graphics osztalyhoz tartozo draw-t.
   * @param d Draw
   */
  public void setDraw(Draw d){
    draw = d;
  }
  /**
   * Beallitjuk az adott keresztezodest
   * @param c Cross
   */
  public void setCross(HidingPlace c){
    cr = c;
  }
  /**
   * Kiszamoljuk a megjeleniteshez szukseges valtozok erteket
   */
  public void calcGraphics(){
    MainGraphics gr = Game.getInstance().getMap().getGraphics();
    draw.drawing(this,gr.getGraphic());
  }
  public Icon getImage(){
    return image;
  }
  /**
   * Visszaadja az adott tabla koordinatajat
   * @return Point: tabla pozicioja
   */
  public Point getTablePosition()
  {
    // MainGraphics-hoz hozzaferes
    MainGraphics gr = Game.getInstance().getMap().getGraphics();
   
    // stoptabla helye megnezzuk az elso bemeno utat:
    Route r = cr.getInRoutes().get(1);
   
    //megnezzuk a ket csomopontjat a kijelolt utnak
    Cross cr1 = r.getStartCross();
    Point cr1p = gr.getGraphicsFromObject(cr1).getPosition();
    Cross cr2 = r.getEndCross();
    Point cr2p = gr.getGraphicsFromObject(cr2).getPosition();
   
    // a tavolsag tizedenel helyezzuk el a tablat
    Point pos = new Point(cr2p.x+(cr1p.x-cr2p.x)/10,cr2p.y+(cr1p.y-cr2p.y)/10);
   

    return pos;
   
  }
  public Icon getTable(){return table1;}
}
TOP

Related Classes of graphics.GraphicsHidingPlace

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.