Package it.timehero.example.slick.timehero.entities

Examples of it.timehero.example.slick.timehero.entities.Entity


    // brute force collisions, compare every entity against
    // every other entity. If any of them collide notify
    // both entities that the collision has occured
    for (int p=0;p<entities.size();p++) {
      for (int s=p+1;s<entities.size();s++) {
        Entity me = (Entity) entities.get(p);
        Entity him = (Entity) entities.get(s);
        if (me.collidesWith(him)) {
          me.collidedWith(him);
          him.collidedWith(me);
        }
      }
    }
     
        // draw the appropriate section of the tilemap based on the centre (hence the -(TANK_SIZE/2)) of
        // the player
        int playerTileX = (int) gigi.getX();
        int playerTileY = (int) gigi.getY();
        
        // caculate the offset of the player from the edge of the tile. As the player moves around this
        // varies and this tells us how far to offset the tile based rendering to give the smooth
        // motion of scrolling
        int playerTileOffsetX = (int) ((playerTileX - gigi.getX()) * mappa.getTileSize());
        int playerTileOffsetY = (int) ((playerTileY - gigi.getY()) * mappa.getTileSize());
        
        // render the section of the map that should be visible. Notice the -1 and +3 which renders
        // a little extra map around the edge of the screen to cope with tiles scrolling on and off
        // the screen
        mappa.render(playerTileOffsetX - (gigi.ENTITY_SPRITE_SIZE / 2), playerTileOffsetY - (gigi.ENTITY_SPRITE_SIZE / 2)
                   playerTileX - leftOffsetInTiles - 1
                   playerTileY - topOffsetInTiles - 1,
                   widthInTiles + 3, heightInTiles + 3);
        
        // draw entities relative to the player that must appear in the centre of the screen
        g.translate(400 - (int) (gigi.getX() * 32), 300 - (int) (gigi.getY() * 32));

        // elimino le entit� segnalate per la rimozione
        removeEntity();
       
        // disegno entit�
        for (int i = 0; i < entities.size(); i++) {
      Entity ent = entities.get(i);
      // l'eroe deve essere animato in modo diverso (in base all'input dell'utente)

      ent.draw(g);       

      /*
      if ( ent instanceof Gigi){
        ((Gigi)ent).draw(g);
      } else {
View Full Code Here


    }
    // scorre le entit� ed elimina quelle segnalate per la rimozione
    private void removeEntity(){
      for (int i = 0; i < entities.size(); i++) {
        Entity temp = entities.get(i);
        if (temp.isToRemove()){
          entities.remove(temp);
          punteggio++;
        }
     
    }
View Full Code Here

      x =dado.nextInt(mappa.getWidth());
      y =dado.nextInt(mappa.getHeight());
      if (!mappa.blocked(x, y)){
        boolean qualcuno = false;
        for (int i = 0; i < entities.size(); i++) {
          Entity array_element = entities.get(i);
          if (array_element.getX() == x && array_element.getY() == y){
            qualcuno = true;
          }
        }
        if (!qualcuno){
          found = true;         
        }
      }
      }
      try {
      Entity entita = new Entity(x,y, "data/grafica/hero3.gif",25,32,4,6,5,7,0,3);
      entities.add(entita);
    } catch (SlickException e) {
      e.printStackTrace();
    }
     
View Full Code Here

TOP

Related Classes of it.timehero.example.slick.timehero.entities.Entity

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.