Package core

Examples of core.Tilemap


    collidesX = false;
    collidesY = false;
    grounded = false;

    Tilemap tm = Tilemap.getInstance();

    // Kollision des Akteurs mit der Tilemap

    // Tile links oben
    int x = getHitbox().newX;
    int y = getHitbox().newY;
    Collidable tile = tm.getTilefromCoord(x, y);
    synchronized (tile) {
      tile.getHitbox().setLocation(x - x % tm.getTilesizeX(),  y - y % tm.getTilesizeY());
      if (tile.isBlocked()) {
        tile.handleCollisionWith(this);
      }     
    }


    // Tile rechts oben
    x = getHitbox().newX + getHitbox().width - 1;
    y = getHitbox().newY;
    tile = tm.getTilefromCoord(x, y);
    synchronized (tile) {
      tile.getHitbox().setLocation(x - x % tm.getTilesizeX(),  y - y % tm.getTilesizeY());
      if (tile.isBlocked()) {
        tile.handleCollisionWith(this);
      }     
    }


    // Tile links
    x = getHitbox().newX;
    y = getHitbox().newY + getHitbox().height / 2;
    tile = tm.getTilefromCoord(x, y);
    synchronized (tile) {
      tile.getHitbox().setLocation(x - x % tm.getTilesizeX(),  y - y % tm.getTilesizeY());
      if (tile.isBlocked()) {
        tile.handleCollisionWith(this);
      }     
    }

    // Tile rechts
    x = getHitbox().newX + getHitbox().width - 1;
    y = getHitbox().newY + getHitbox().height / 2;
    tile = tm.getTilefromCoord(x, y);
    synchronized (tile) {
      tile.getHitbox().setLocation(x - x % tm.getTilesizeX(),  y - y % tm.getTilesizeY());
      if (tile.isBlocked()) {
        tile.handleCollisionWith(this);
      }     
    }


    // Tile links unten
    x = getHitbox().newX;
    y = getHitbox().newY + getHitbox().height;
    tile = tm.getTilefromCoord(x, y);
    synchronized (tile) {
      tile.getHitbox().setLocation(x - x % tm.getTilesizeX(),  y - y % tm.getTilesizeY());
      if (tile.isBlocked()) {
        tile.handleCollisionWith(this);
      }     
    }


    // Tile rechts unten
    x = getHitbox().newX + getHitbox().width - 1;
    y = getHitbox().newY + getHitbox().height;
    tile = tm.getTilefromCoord(x, y);
    synchronized (tile) {
      tile.getHitbox().setLocation(x - x % tm.getTilesizeX(),  y - y % tm.getTilesizeY());
      if (tile.isBlocked()) {
        tile.handleCollisionWith(this);
      }     
    }
   
View Full Code Here

TOP

Related Classes of core.Tilemap

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.