Package general.datastructures

Examples of general.datastructures.Vector2f


 
  public void drawSprite(int id)
  {
    Sprite s = unitManager.getSprite(id);
    Texture tex = s.getTexture();
    Vector2f wc_position = s.getPosition();
    float rotation = s.getRotation();
   
    if(map.isInMap(Math.worldToMap(wc_position, map.getTilesize())) && viewport.scale_cpy(1.1f).isInside(wc_position))
    {
      glEnableClientState(GL_VERTEX_ARRAY);
      glEnableClientState(GL_TEXTURE_COORD_ARRAY);
      glEnable(GL_TEXTURE_2D);
     
      glPushMatrix();
     
      tex.bind();   
     
      glTranslatef(Math.worldToScreen(wc_position.x(),viewport.getLeft()), Math.worldToScreen(wc_position.y(),viewport.getTop()), 0f);
     
      glRotatef(rotation, 0, 0, 1.0f);
      //glTranslatef(-texture.getImageWidth()/2, -texture.getImageHeight()/2, 0);
     
      glVertexPointer(2, 0, s.getVertexBuffer());
View Full Code Here


   
    for(int mapX=(int)(viewport.getLeft() / map.getTilesize())-1; mapX<=(viewport.getRight() / map.getTilesize())+1; mapX++)
    {
      for(int mapY=(int)(viewport.getTop() / map.getTilesize()-1); mapY<=(viewport.getBottom() / map.getTilesize())+1; mapY++)
      {
        if(map.isInMap(new Vector2f(mapX, mapY)))
        {
          float screenX = Math.mapToScreen(mapX, viewport.getLeft(), map.getTilesize());   
          float screenY = Math.mapToScreen(mapY, viewport.getTop(), map.getTilesize());
         
          map.BindMapTexture(map.getData(mapX, mapY));
View Full Code Here

        if(Keyboard.getEventKeyState())
        {
          String name = "Panzer " + (unitManager.getSpriteCount()+1);
          //TODO playerID anpassen
          //Vector2f spawnpos = new Vector2f(Math.screenToMap(Mouse.getX(), viewport.getLeft(), map.getTilesize()), Math.screenToMap(VERTICAL_RESOLUTION-Mouse.getY(), viewport.getLeft(), map.getTilesize()));
          Vector2f sc_spawnpos = new Vector2f(Mouse.getX(),VERTICAL_RESOLUTION-Mouse.getY());
          unitManager.createSprite(name, "tank.png", sc_spawnpos, 1, players.elementAt(0));
        }
      }
    }
   
    if(Keyboard.isKeyDown(Keyboard.KEY_LEFT))
    {
      viewport.move(new Vector2f(-2f, 0));
    }
    else if(Keyboard.isKeyDown(Keyboard.KEY_RIGHT))
    {
      viewport.move(new Vector2f(2f, 0));
    }
   
    if(Keyboard.isKeyDown(Keyboard.KEY_UP))
    {
      viewport.move(new Vector2f(0, -2f));
    }
    else if(Keyboard.isKeyDown(Keyboard.KEY_DOWN))
    {
      viewport.move(new Vector2f(0, 2f));
    }
   
    while(Mouse.next())
    {
      int mouseButton = Mouse.getEventButton();
     
      Vector2f sc_mousePos = new Vector2f(Mouse.getX(),VERTICAL_RESOLUTION-Mouse.getY());
      //System.out.println(mousePos);
           
      if(mouseButton == 0 && Mouse.getEventButtonState())
      {
        ((HumanPlayer)players.get(0)).selectSprite(sc_mousePos);
View Full Code Here

      }

      closedlist.add(currentWP);

      // Expand Node
      Vector2f currentpoint = currentWP.getVector2f();

      newWaypoints = new Vector<Waypoint>(8);

      //8er Nachbarschaft hinzufuegen
      newWaypoints.add(new Waypoint(new Vector2f(currentpoint.x()-1 , currentpoint.y()-1 ),   Math.sqrt(2,currentWP));
      newWaypoints.add(new Waypoint(new Vector2f(currentpoint.x()-1 , currentpoint.y() ),     1      ,currentWP));
      newWaypoints.add(new Waypoint(new Vector2f(currentpoint.x()-1 , currentpoint.y()+1 ),   Math.sqrt(2,currentWP));
      newWaypoints.add(new Waypoint(new Vector2f(currentpoint.x() , currentpoint.y()-1 ),     1      ,currentWP));
      newWaypoints.add(new Waypoint(new Vector2f(currentpoint.x() , currentpoint.y()+1 ),     1      ,currentWP));
      newWaypoints.add(new Waypoint(new Vector2f(currentpoint.x()+1 , currentpoint.y()-1 ),   Math.sqrt(2,currentWP));
      newWaypoints.add(new Waypoint(new Vector2f(currentpoint.x()+1 , currentpoint.y() ),     1      ,currentWP));
      newWaypoints.add(new Waypoint(new Vector2f(currentpoint.x()+1 , currentpoint.y()+1 ),   Math.sqrt(2,currentWP));

      //System.err.println("Alle punkte zum vektor hinzugefuegt");

      for(Waypoint wp : newWaypoints)
      {
View Full Code Here

TOP

Related Classes of general.datastructures.Vector2f

Copyright © 2018 www.massapicom. 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.