當前位置: 首頁>>代碼示例>>Java>>正文


Java Point2i類代碼示例

本文整理匯總了Java中com.stewsters.util.math.Point2i的典型用法代碼示例。如果您正苦於以下問題:Java Point2i類的具體用法?Java Point2i怎麽用?Java Point2i使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Point2i類屬於com.stewsters.util.math包,在下文中一共展示了Point2i類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getNeighbors

import com.stewsters.util.math.Point2i; //導入依賴的package包/類
public static LinkedList<Point2i> getNeighbors(int x, int y, int range) {

        LinkedList<Point2i> results = new LinkedList<Point2i>();
        for (int x1 = x - range; x1 < x + range; x1++) {
            for (int y1 = y - range; y1 < y + range; y1++) {
                if (x1 == x || y1 == y)
                    continue;
                if (manhattanDistance(x, y, x1, y1) <= range) {
                    results.add(new Point2i(x1, y1));
                }

            }
        }

        return results;
    }
 
開發者ID:stewsters,項目名稱:acceptableLosses,代碼行數:17,代碼來源:MapTools.java

示例2: generateHallways

import com.stewsters.util.math.Point2i; //導入依賴的package包/類
private static Spacecraft generateHallways(Blueprint blueprint, Spacecraft spacecraft) {

        // Cutting paths
        HallwayPathFinder pathFinder2d = new HallwayPathFinder(spacecraft.gridMap, spacecraft.gridMap.getWidthInTiles() * spacecraft.gridMap.getHeightInTiles(), false);
        HallwayMover2d hallwayMover2d = new HallwayMover2d(spacecraft.gridMap);

        // for each pair of room centers
        for (Room roomFrom : spacecraft.rooms) {
            for (Room roomTo : spacecraft.rooms) {

                Point2i roomCenterFrom = roomFrom.center();
                Point2i roomCenterTo = roomTo.center();

                FullPath2d fullPath2d = pathFinder2d.findPath(hallwayMover2d, roomCenterFrom.x, roomCenterFrom.y, roomCenterTo.x, roomCenterTo.y);

                if (fullPath2d != null) {
                    for (int step = 0; step < fullPath2d.getLength(); step++) {
                        TileType tileType = spacecraft.gridMap.getTile(fullPath2d.getX(step), fullPath2d.getY(step));


                        if (tileType == TileType.WALL || tileType == TileType.REINFORCED_WALL) {
                            spacecraft.gridMap.writeToBothSides(fullPath2d.getX(step), fullPath2d.getY(step), TileType.DOOR);
                        } else if (tileType != TileType.DOOR) {
                            spacecraft.gridMap.writeToBothSides(fullPath2d.getX(step), fullPath2d.getY(step), TileType.FLOOR);
                        }

                    }
                }
            }
        }

        return spacecraft;
    }
 
開發者ID:stewsters,項目名稱:shipwright,代碼行數:34,代碼來源:ShipWright.java

示例3: findPath

import com.stewsters.util.math.Point2i; //導入依賴的package包/類
Optional<List<Point2i>> findPath(
CanTraverse2d canTraverse2d,
CanOccupy2d canOccupy2d,
MovementCost2d movementCost2d,
AStarHeuristic2d heuristic,
boolean allowDiagMovement,
int sx, int sy, int tx, int ty);
 
開發者ID:stewsters,項目名稱:stewsters-util,代碼行數:8,代碼來源:PathFinder2d.java

示例4: floodFill

import com.stewsters.util.math.Point2i; //導入依賴的package包/類
/**
 * Flood fills on things that fit the predicate
 *
 * @param map       The map we are working on
 * @param start     The beginning of the flood fille
 * @param predicate The predicate to check
 * @param brush2d   The brush to fill
 */
public static void floodFill(GeneratedMap2d map, Point2i start, CellPredicate2d predicate, Brush2d brush2d) {

    Deque<Point2i> todo = new ArrayDeque<Point2i>();
    ArrayList<Point2i> match = new ArrayList<>();
    HashSet<Point2i> done = new HashSet<Point2i>();

    todo.push(start);

    Point2i p;
    while (todo.size() > 0) {
        p = todo.pop();

        if (!done.contains(p) && predicate.belongs(map, p.x, p.y)) {

            match.add(p);

            //todo: done list?
            if (p.x > 0)
                todo.push(new Point2i(p.x - 1, p.y));
            if (p.x < map.getXSize() - 1)
                todo.push(new Point2i(p.x + 1, p.y));
            if (p.y > 0)
                todo.push(new Point2i(p.x, p.y - 1));
            if (p.y < map.getYSize() - 1)
                todo.push(new Point2i(p.x, p.y + 1));
        }
        done.add(p);
    }

    // Goes over the whole map replacing a cell satisfying the predicate with the brush contents.
    for (Point2i point2i : match) {
        brush2d.draw(map, point2i.x, point2i.y);
    }

}
 
開發者ID:stewsters,項目名稱:stewsters-util,代碼行數:44,代碼來源:MapGen2d.java

示例5: window2world

import com.stewsters.util.math.Point2i; //導入依賴的package包/類
public static Point2i window2world(int x, int y, OrthographicCamera camera) {
    Vector3 pos = new Vector3(x, y, 0);
    camera.unproject(pos);

    return new Point2i((int) ((pos.x)), (int) ((pos.y)));
}
 
開發者ID:stewsters,項目名稱:acceptableLosses,代碼行數:7,代碼來源:MapTools.java

示例6: libgdx2world

import com.stewsters.util.math.Point2i; //導入依賴的package包/類
public static Point2i libgdx2world(float x, float y) {
    return new Point2i((int) (x), (int) (y));
}
 
開發者ID:stewsters,項目名稱:acceptableLosses,代碼行數:4,代碼來源:MapTools.java

示例7: tapCommand

import com.stewsters.util.math.Point2i; //導入依賴的package包/類
public void tapCommand(Point2i point2i) {
    Gdx.app.log("command", "tap " + point2i.toString());
    commandQueue.add(new TapCommand(point2i));
}
 
開發者ID:stewsters,項目名稱:acceptableLosses,代碼行數:5,代碼來源:InputManager.java

示例8: center

import com.stewsters.util.math.Point2i; //導入依賴的package包/類
public Point2i center() {
    int center_x = (x1 + x2) / 2;
    int center_y = (y1 + y2) / 2;
    return new Point2i(center_x, center_y);
}
 
開發者ID:stewsters,項目名稱:stewsters-util,代碼行數:6,代碼來源:Rect.java

示例9: search

import com.stewsters.util.math.Point2i; //導入依賴的package包/類
Optional<List<Point2i>> search(Objective2d objective,
CanTraverse2d canTraverse2d,
MovementCost2d movementCost2d,
boolean allowDiagMovement,
int sx, int sy);
 
開發者ID:stewsters,項目名稱:stewsters-util,代碼行數:6,代碼來源:Searcher2d.java

示例10: TapCommand

import com.stewsters.util.math.Point2i; //導入依賴的package包/類
public TapCommand(Point2i point2i) {
    this.point2i = point2i;

}
 
開發者ID:stewsters,項目名稱:acceptableLosses,代碼行數:5,代碼來源:TapCommand.java


注:本文中的com.stewsters.util.math.Point2i類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。