本文整理汇总了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;
}
示例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;
}
示例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);
示例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);
}
}
示例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)));
}
示例6: libgdx2world
import com.stewsters.util.math.Point2i; //导入依赖的package包/类
public static Point2i libgdx2world(float x, float y) {
return new Point2i((int) (x), (int) (y));
}
示例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));
}
示例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);
}
示例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);
示例10: TapCommand
import com.stewsters.util.math.Point2i; //导入依赖的package包/类
public TapCommand(Point2i point2i) {
this.point2i = point2i;
}