• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java Coord类的典型用法和代码示例

java 1次浏览

本文整理汇总了Java中squidpony.squidmath.Coord的典型用法代码示例。如果您正苦于以下问题:Java Coord类的具体用法?Java Coord怎么用?Java Coord使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

Coord类属于squidpony.squidmath包,在下文中一共展示了Coord类的24个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: calculateDirection

点赞 3

import squidpony.squidmath.Coord; //导入依赖的package包/类
/**
 * calculate the direction from one adjacent {@link Coord} to another
 *
 * @param from
 * @param to
 * @return
 */
public static int calculateDirection(final Coord from, final Coord to) {
	if (from.x < to.x) {
		return Move.RIGHT;
	}
	if (from.x > to.x) {
		return Move.LEFT;
	}
	if (from.y < to.y) {
		return Move.UP;
	}
	if (from.y > to.y) {
		return Move.DOWN;
	}
	return Move.IDLE;
}
 

开发者ID:davidbecker,
项目名称:taloonerrl,
代码行数:23,
代码来源:DungeonUtil.java

示例2: putMap

点赞 3

import squidpony.squidmath.Coord; //导入依赖的package包/类
/**
 * Draws the map, applies any highlighting for the path to the cursor, and then draws the player.
 */
public void putMap()
{
    double alter = 0;
    for (int i = 0; i < gridWidth; i++) {
        for (int j = 0; j < gridHeight; j++) {
            if(fovmap[i][j] > 0)
                alter = 220 * fovmap[i][j] + 25 * PerlinNoise.noise(i / 6.0, j / 6.0, counter / 15.0);
            else
                alter = -50;
            display.put(i, j, lineDungeon[i][j], colorIndices[i][j], bgColorIndices[i][j], lights[i][j] +
                    (int)(-100 + alter));
        }
    }
    for (Coord pt : toCursor)
    {
        // use a brighter light to trace the path to the cursor, from 170 max lightness to 0 min.
        display.highlight(pt.x, pt.y, 100);
    }
}
 

开发者ID:tommyettinger,
项目名称:SquidLib-Demos,
代码行数:23,
代码来源:DungeonGame.java

示例3: putMap

点赞 3

import squidpony.squidmath.Coord; //导入依赖的package包/类
public void putMap()
{
    for (int i = 0; i < width; i++) {
        for (int j = 0; j < height; j++) {
            // if we see it now, we remember the cell and show a lit cell based on the fovmap value (between 0.0
            // and 1.0), with 1.0 being almost pure white at +215 lightness and 0.0 being rather dark at -105.
            if (fovmap[i][j] > 0.0) {
                seen[i][j] = true;
                display.put(i, j, lineDungeon[i][j], fgCenter.filter(colors[i][j]), bgCenter.filter(bgColors[i][j]),
                        lights[i][j] + (int) (-105 + 320 * fovmap[i][j]));
                // if we don't see it now, but did earlier, use a very dark background, but lighter than black.
            } else if (seen[i][j]) {
                display.put(i, j, lineDungeon[i][j], fgCenter.filter(colors[i][j]), bgCenter.filter(bgColors[i][j]), -140);
            }
        }
    }
    for (Coord pt : toCursor)
    {
        // use a brighter light to trace the path to the cursor, from 170 max lightness to 0 min.
        display.highlight(pt.x, pt.y, lights[pt.x][pt.y] + (int) (170 * fovmap[pt.x][pt.y]));
    }
}
 

开发者ID:tommyettinger,
项目名称:SquidLib-Demos,
代码行数:23,
代码来源:TsarGame.java

示例4: putMap

点赞 3

import squidpony.squidmath.Coord; //导入依赖的package包/类
/**
 * Draws the map, applies any highlighting for the path to the cursor, and then draws the player.
 */
public void putMap()
{
    for (int i = 0; i < gridWidth; i++) {
        for (int j = 0; j < gridHeight; j++) {
            display.put(i, j, lineDungeon[i][j], colorIndices[i][j], bgColorIndices[i][j], 40);
        }
    }
    for (Coord pt : toCursor)
    {
        // use a brighter light to trace the path to the cursor, from 170 max lightness to 0 min.
        display.highlight(pt.x, pt.y, 100);
    }
    //places the player as an '@' at his position in orange (6 is an index into SColor.LIMITED_PALETTE).
    display.put(player.x, player.y, '@', 6);
    //this helps compatibility with the HTML target, which doesn't support String.format()
    char[] spaceArray = new char[gridWidth];
    Arrays.fill(spaceArray, ' ');
    String spaces = String.valueOf(spaceArray);

    for (int i = 0; i < 6; i++) {
        display.putString(0, gridHeight + i + 1, spaces, 0, 1);
        display.putString(2, gridHeight + i + 1, lang[(langIndex + i) % 12], 0, 1);
    }
}
 

开发者ID:tommyettinger,
项目名称:SquidLib-Demos,
代码行数:28,
代码来源:BasicDemo.java

示例5: putMap

点赞 3

import squidpony.squidmath.Coord; //导入依赖的package包/类
/**
 * Draws the map, applies any highlighting for the path to the cursor, and then draws the player.
 */
public void putMap()
{
    for (int i = 0; i < gridWidth; i++) {
        for (int j = 0; j < gridHeight; j++) {
            display.put(i, j, lineDungeon[i][j], colorIndices[i][j], bgColorIndices[i][j], 40);
        }
    }
    for (Coord pt : toCursor)
    {
        // use a brighter light to trace the path to the cursor, from 170 max lightness to 0 min.
        display.highlight(pt.x, pt.y, 100);
    }
    //places the player as an '@' at his position in orange.
    display.put(player.x, player.y, '@', SColor.SAFETY_ORANGE);
    //this helps compatibility with the HTML target, which doesn't support String.format()
    char[] spaceArray = new char[gridWidth];
    Arrays.fill(spaceArray, ' ');
    String spaces = String.valueOf(spaceArray);

    for (int i = 0; i < 4; i++) {
        display.putString(0, gridHeight + i + 1, spaces, 0, 1);
        display.putString(2, gridHeight + i + 1, lang[(langIndex + i) % lang.length], 0, 1);
    }
}
 

开发者ID:tommyettinger,
项目名称:SquidLib-Demos,
代码行数:28,
代码来源:SquidBasicDemo.java

示例6: putMap

点赞 3

import squidpony.squidmath.Coord; //导入依赖的package包/类
/**
 * Draws the map, applies any highlighting for the path to the cursor, and then draws the player.
 */
public void putMap()
{
    for (int i = 0; i < gridWidth; i++) {
        for (int j = 0; j < gridHeight; j++) {
            display.put(i, j, lineDungeon[i][j], colorIndices[i][j], bgColorIndices[i][j], 40);
        }
    }
    for (Coord pt : toCursor)
    {
        // use a brighter light to trace the path to the cursor, from 170 max lightness to 0 min.
        display.highlight(pt.x, pt.y, 100);
    }
    //places the player as an '@' at his position in orange (6 is an index into SColor.LIMITED_PALETTE).
    display.put(player.x, player.y, '@', 6);
    //this helps compatibility with the HTML target, which doesn't support String.format()
    char[] spaceArray = new char[gridWidth];
    Arrays.fill(spaceArray, ' ');
    String spaces = String.valueOf(spaceArray);

    for (int i = 0; i < 6; i++) {
        display.putString(0, gridHeight + i + 1, spaces, 0, 1);
        display.putString(2, gridHeight + i + 1, lang[(langIndex + i) % lang.length], 0, 1);
    }
}
 

开发者ID:tommyettinger,
项目名称:SquidLib-Demos,
代码行数:28,
代码来源:SquidBasicDemo.java

示例7: putMap

点赞 2

import squidpony.squidmath.Coord; //导入依赖的package包/类
/**
 * Draws the map, applies any highlighting for the path to the cursor, and
 * then draws the player.
 */
public void putMap() {
	for (int i = 0; i < gridWidth; i++) {
		for (int j = 0; j < gridHeight; j++) {
			display.put(i, j, lineDungeon[i][j], colorIndices[i][j], bgColorIndices[i][j], 40);
		}
	}
	for (Coord pt : toCursor) {
		// use a brighter light to trace the path to the cursor, from 170
		// max lightness to 0 min.
		display.highlight(pt.x, pt.y, 100);
	}
	// places the player as an '@' at his position in orange (6 is an index
	// into SColor.LIMITED_PALETTE).
	display.put(player.x, player.y, '@', 6);
	// for clarity, you could replace the above line with the uncommented
	// line below
	// display.put(player.x, player.y, '@', SColor.INTERNATIONAL_ORANGE);
	// since this is what 6 refers to, a color constant in a palette where 6
	// refers to this shade of orange.
	// You could experiment with different SColors; the JavaDocs for each
	// color show a nice preview.
	// To view JavaDocs for a field, you can use Ctrl-Q in IntelliJ IDEA and
	// Android Studio, or
	// just mouse over in Eclipse.
	// SColor extends Color, so you can use an SColor anywhere a Color is
	// expected.

	// The arrays we produced in create() are used here to provide a blank
	// area behind text
	display.put(0, gridHeight + 1, spaces, languageFG, languageBG);
	for (int i = 0; i < 6; i++) {
		display.putString(2, gridHeight + i + 1, lang[(langIndex + i) % lang.length], 0, 1);
	}
}
 

开发者ID:goyaak,
项目名称:cascadian-order-office-roguelike,
代码行数:39,
代码来源:MySquidGame.java

示例8: render

点赞 2

import squidpony.squidmath.Coord; //导入依赖的package包/类
@Override
public void render() {
	// standard clear the background routine for libGDX
	Gdx.gl.glClearColor(bgColor.r / 255.0f, bgColor.g / 255.0f, bgColor.b / 255.0f, 1.0f);
	Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
	Gdx.gl.glEnable(GL20.GL_BLEND);

	// need to display the map every frame, since we clear the screen to
	// avoid artifacts.
	putMap();

	// if the user clicked, we have a list of moves to perform.
	if (!awaitedMoves.isEmpty()) {
		// this doesn't check for input, but instead processes and removes
		// Points from awaitedMoves.
		secondsWithoutMoves += Gdx.graphics.getDeltaTime();
		if (secondsWithoutMoves >= 0.1) {
			secondsWithoutMoves = 0;
			Coord m = awaitedMoves.remove(0);
			toCursor.remove(0);
			move(m.x - player.x, m.y - player.y);
		}
	}
	// if we are waiting for the player's input and get input, process it.
	else if (input.hasNext()) {
		input.next();
	}

	// stage has its own batch and must be explicitly told to draw().
	stage.draw();
	// you may need to explicitly tell stage to act() if input isn't
	// working.
	// there shouldn't be a problem from calling act(), but
	// you can comment out the next line to test if input has problems.
	stage.act();
}
 

开发者ID:goyaak,
项目名称:cascadian-order-office-roguelike,
代码行数:37,
代码来源:MySquidGame.java

示例9: getFovForPosition

点赞 2

import squidpony.squidmath.Coord; //导入依赖的package包/类
/**
 * lookup/create the fov map for the given map position
 *
 * @param x
 *            horizontal tile position
 * @param y
 *            vertical tile position
 * @return values in returned array mean 0 for no light and 1.0 for fully lit
 */
public double[][] getFovForPosition(final int x, final int y) {
	double[][] fovLighMap = null;
	final Coord c = Coord.get(x, y);
	if (storedFovMaps.containsKey(c)) {
		fovLighMap = storedFovMaps.get(c);
	} else {
		if (ArrayHelper.isInArrayBounds(fovResistance, x, y)) {
			fovLighMap = fov.calculateFOV(fovResistance, x, y, FOV_RADIUS, RADIUS_TECHNIQUE);
			storedFovMaps.put(c, fovLighMap);
		}
	}
	return fovLighMap;
}
 

开发者ID:davidbecker,
项目名称:taloonerrl,
代码行数:23,
代码来源:FovWrapper.java

示例10: addPlayerWalkPath

点赞 2

import squidpony.squidmath.Coord; //导入依赖的package包/类
private boolean addPlayerWalkPath() {
	if (MapManager.getInstance().getMap().isInMapBounds(mouseOverX, mouseOverY)
			&& MapManager.getInstance().getMap().isVisited(mouseOverX, mouseOverY)) {
		final EntitySubscription entitySubscription = GameEngine.getInstance()
				.getAspectSubscriptionManager()
				.get(Aspect.all(PositionComponent.class, PlayerComponent.class));
		final PositionComponent positionComponent = ComponentMappers.getInstance().position
				.get(entitySubscription.getEntities().get(0));
		// skip current path and override it with new on click for now
		// if (!positionComponent.isProcessingTurn()) {
		Coord start = Coord.get(positionComponent.getX(), positionComponent.getY());
		final DijkstraMap dijkstraMap = MapManager.getInstance().getMap().getDijkstraMap();
		dijkstraMap.setGoal(mouseOverX, mouseOverY);
		final ArrayList<Coord> path = dijkstraMap.findPath(Integer.MAX_VALUE, null, null, start);
		final int size = path.size();
		final int[] directions = new int[size];
		int index = 0;
		for (final Coord coord : path) {
			directions[index] = Move.from(squidpony.squidgrid.Direction.toGoTo(start, coord));
			start = coord;
			index = index + 1;
		}
		TurnScheduler.getInstance().addTurnsToQueue(directions);
		// }
		return true;
	}
	return false;
}
 

开发者ID:davidbecker,
项目名称:taloonerrl,
代码行数:29,
代码来源:InputSystem.java

示例11: directionFromCoords

点赞 2

import squidpony.squidmath.Coord; //导入依赖的package包/类
@Test
public void directionFromCoords() {
	final Coord up = Coord.get(1, 2);
	final Coord down = Coord.get(1, 0);
	final Coord left = Coord.get(0, 1);
	final Coord right = Coord.get(2, 1);
	final Coord center = Coord.get(1, 1);
	assertEquals(Move.DOWN, DungeonUtil.calculateDirection(up, center));
	assertEquals(Move.UP, DungeonUtil.calculateDirection(down, center));
	assertEquals(Move.LEFT, DungeonUtil.calculateDirection(right, center));
	assertEquals(Move.RIGHT, DungeonUtil.calculateDirection(left, center));
	assertEquals(Move.IDLE, DungeonUtil.calculateDirection(center, center));
}
 

开发者ID:davidbecker,
项目名称:taloonerrl,
代码行数:14,
代码来源:TestDungeonUtil.java

示例12: checkOverlap

点赞 2

import squidpony.squidmath.Coord; //导入依赖的package包/类
private boolean checkOverlap(AnimatedEntity ae, int x, int y, ArrayList<Coord> futureOccupied)
{
    for(AnimatedEntity mon : monsters.keySet())
    {
        if(mon.gridX == x && mon.gridY == y && !mon.equals(ae))
            return true;
    }
    for(Coord p : futureOccupied)
    {
        if(x == p.x && y == p.y)
            return true;
    }
    return false;
}
 

开发者ID:tommyettinger,
项目名称:SquidLib-Demos,
代码行数:15,
代码来源:TsarGame.java

示例13: putMap

点赞 2

import squidpony.squidmath.Coord; //导入依赖的package包/类
public void putMap()
{
    for (int i = 0; i < width; i++) {
        for (int j = 0; j < height; j++) {
            // if we see it now, we remember the cell and show a lit cell based on the fovmap value (between 0.0
            // and 1.0), with 1.0 being almost pure white at +215 lightness and 0.0 being rather dark at -105.
            if (fovmap[i][j] > 0.0) {
                seen[currentDepth][i][j] = true;
                display.put(i * 2, j, lineDungeons[currentDepth][i * 2][j], colors[i][j], bgColors[i][j],
                        lights[i][j] + (int) (-105 + 320 * fovmap[i][j]));
                display.put(i * 2 + 1, j, lineDungeons[currentDepth][i * 2 + 1][j], colors[i][j], bgColors[i][j],
                        lights[i][j] + (int) (-105 + 320 * fovmap[i][j]));
                // if we don't see it now, but did earlier, use a very dark background, but lighter than black.
            } else if (seen[currentDepth][i][j]) {
                display.put(i * 2, j, lineDungeons[currentDepth][i * 2][j], colors[i][j], bgColors[i][j], -140);
                display.put(i * 2 + 1, j, lineDungeons[currentDepth][i * 2 + 1][j], colors[i][j], bgColors[i][j], -140);
            }
        }
    }
    for (Coord pt : toCursor)
    {
        // use a brighter light to trace the path to the cursor, from 170 max lightness to 0 min.
        display.highlight(pt.x * 2, pt.y, lights[pt.x][pt.y] + (int) (170 * fovmap[pt.x][pt.y]));
        display.highlight(pt.x * 2 + 1, pt.y, lights[pt.x][pt.y] + (int) (170 * fovmap[pt.x][pt.y]));
    }
    String currentHealth = "Health: " + health;
    int len = currentHealth.length();
    for (int i = 0; i < len; i++) {
        display.put(width - len / 2 + i, height, currentHealth.charAt(i), 11);
    }
}
 

开发者ID:tommyettinger,
项目名称:SquidLib-Demos,
代码行数:32,
代码来源:PandoraGame.java

示例14: render

点赞 2

import squidpony.squidmath.Coord; //导入依赖的package包/类
@Override
public void render () {
    // standard clear the background routine for libGDX
    Gdx.gl.glClearColor(bgColor.r / 255.0f, bgColor.g / 255.0f, bgColor.b / 255.0f, 1.0f);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    // need to display the map every frame, since we clear the screen to avoid artifacts.
    putMap();
    // if the user clicked, we have a list of moves to perform.
    if(!awaitedMoves.isEmpty())
    {
        // this doesn't check for input, but instead processes and removes Points from awaitedMoves.
        secondsWithoutMoves += Gdx.graphics.getDeltaTime();
        if (secondsWithoutMoves >= 0.1) {
            secondsWithoutMoves = 0;
            Coord m = awaitedMoves.remove(0);
            toCursor.remove(0);
            move(m.x - player.x, m.y - player.y);
        }
    }
    // if we are waiting for the player's input and get input, process it.
    else if(input.hasNext()) {
        input.next();
    }

    // stage has its own batch and must be explicitly told to draw(). this also causes it to act().
    stage.draw();
}
 

开发者ID:tommyettinger,
项目名称:SquidLib-Demos,
代码行数:29,
代码来源:BasicDemo.java

示例15: putMap

点赞 2

import squidpony.squidmath.Coord; //导入依赖的package包/类
/**
 * Draws the map, applies any highlighting for the path to the cursor, and then draws the player.
 */
public void putMap()
{
    double tm = (System.currentTimeMillis() & 0xffffffL) * 0.001;
    for (int i = 0; i < gridWidth; i++) {
        for (int j = 0; j < gridHeight; j++) {
            if (visible[i][j] > 0.0) {
                int bright = (int) (-60 +
                        180 * (visible[i][j] * (1.0 + 0.2 * SeededNoise.noise(i * 0.2, j * 0.2, tm, 10000))));
                display.put(i, j, lineDungeon[i][j], colors[i][j], bgColors[i][j], bright);
            } else if (seen.contains(i, j))
                display.put(i, j, lineDungeon[i][j], colors[i][j], bgColors[i][j], -95);
            else
                display.put(i, j, ' ', SColor.BLACK);
        }
    }
    Coord pt;
    for (int i = 0; i < toCursor.size(); i++) {
        pt = toCursor.get(i);
        // use a brighter light to trace the path to the cursor, from 170 max lightness to 0 min.
        display.put(pt.x, pt.y, line[i + 1], SColor.CW_RICH_AZURE, bgColors[pt.x][pt.y], 130);
    }
    //this helps compatibility with the HTML target, which doesn't support String.format()
    char[] spaceArray = new char[gridWidth];
    Arrays.fill(spaceArray, ' ');
    String spaces = String.valueOf(spaceArray);

    for (int i = 0; i < bonusHeight - 1; i++) {
        display.putString(0, gridHeight + i + 1, spaces, SColor.BLACK, SColor.COSMIC_LATTE);
        display.putString(2, gridHeight + i + 1, lang[(langIndex + i) % lang.length], SColor.BLACK, SColor.COSMIC_LATTE);
    }
}
 

开发者ID:tommyettinger,
项目名称:SquidLib-Demos,
代码行数:35,
代码来源:MainApplication.java

示例16: move

点赞 2

import squidpony.squidmath.Coord; //导入依赖的package包/类
/**
 * Move the player or open closed doors, remove any monsters the player bumped, then update the DijkstraMap and
 * have the monsters that can see the player try to approach.
 * In a fully-fledged game, this would not be organized like this, but this is a one-file demo.
 * @param xmod
 * @param ymod
 */
private void move(int xmod, int ymod) {
    clearHelp();

    if(health <= 0) return;

    int newX = player.gridX + xmod, newY = player.gridY + ymod;
    if (newX >= 0 && newY >= 0 && newX < width && newY < height
            && bareDungeon[newX][newY] != '#')
    {
        // '+' is a door.
        if (decoDungeon[newX][newY] == '+') {
            decoDungeon[newX][newY] = '/';
            lineDungeon[newX*2][newY] = '/';
            // changes to the map mean the resistances for FOV need to be regenerated.
            res = DungeonUtility.generateResistances(decoDungeon);
            // recalculate FOV, store it in fovmap for the render to use.
            fovmap = fov.calculateFOV(res, player.gridX, player.gridY, 8, Radius.SQUARE);
        } else {
            // recalculate FOV, store it in fovmap for the render to use.
            fovmap = fov.calculateFOV(res, newX, newY, 8, Radius.SQUARE);
            display.slide(player, newX, newY);
            monsters.remove(Coord.get(newX, newY));
        }
        if(newX == dungeonGen.stairsDown.x && newY == dungeonGen.stairsDown.y)
        {
            messages.appendMessage("WINNER WINNER CHICKEN DINNER!");
        }

        phase = Phase.PLAYER_ANIM;
    }
}
 

开发者ID:tommyettinger,
项目名称:SquidLib-Demos,
代码行数:39,
代码来源:SquidShowcaseDemo.java

示例17: checkOverlap

点赞 2

import squidpony.squidmath.Coord; //导入依赖的package包/类
private boolean checkOverlap(Monster mon, int x, int y, ArrayList<Coord> futureOccupied)
{
    if(monsters.containsPosition(Coord.get(x, y)) && !mon.equals(monsters.get(Coord.get(x, y))))
        return true;
    for(Coord p : futureOccupied)
    {
        if(x == p.x && y == p.y)
            return true;
    }
    return false;
}
 

开发者ID:tommyettinger,
项目名称:SquidLib-Demos,
代码行数:12,
代码来源:SquidShowcaseDemo.java

示例18: putMap

点赞 2

import squidpony.squidmath.Coord; //导入依赖的package包/类
public void putMap()
{
    display.erase();
    boolean overlapping;
    for (int i = 0; i < width; i++) {
        for (int j = 0; j < height; j++) {
            overlapping = (!monsters.isEmpty() && monsters.containsPosition(Coord.get(i,j))) || (!monsters.isEmpty() && player.gridX == i && player.gridY == j);
            // if we see it now, we remember the cell and show a lit cell based on the fovmap value (between 0.0
            // and 1.0), with 1.0 being almost pure white at +215 lightness and 0.0 being rather dark at -105.
            if (fovmap[i][j] > 0.0) {
                seen[i][j] = true;
                display.put(i*2, j, (overlapping) ? ' ' : lineDungeon[i*2][j], fgCenter.filter(colors[i*2][j]), bgCenter.filter(bgColors[i*2][j]),
                        lights[i][j] + (int) (-105 + 320 * fovmap[i][j]));
                display.put(i*2+1, j, (overlapping) ? ' ' : lineDungeon[i*2+1][j], fgCenter.filter(colors[i*2][j]), bgCenter.filter(bgColors[i*2][j]),
                        lights[i][j] + (int) (-105 + 320 * fovmap[i][j]));
                // if we don't see it now, but did earlier, use a very dark background, but lighter than black.
            } else if (seen[i][j]) {
                display.put(i*2, j, lineDungeon[i*2][j], fgCenter.filter(colors[i*2][j]), bgCenter.filter(bgColors[i*2][j]), -140);
                display.put(i*2+1, j, lineDungeon[i*2+1][j], fgCenter.filter(colors[i*2][j]), bgCenter.filter(bgColors[i*2][j]), -140);
            }
        }
    }
    for (Coord pt : toCursor)
    {
        // use a brighter light to trace the path to the cursor, from 170 max lightness to 0 min.
        display.highlight(pt.x*2, pt.y, lights[pt.x][pt.y] + (int) (170 * fovmap[pt.x][pt.y]));
        display.highlight(pt.x*2+1, pt.y, lights[pt.x][pt.y] + (int) (170 * fovmap[pt.x][pt.y]));
    }

}
 

开发者ID:tommyettinger,
项目名称:SquidLib-Demos,
代码行数:31,
代码来源:SquidShowcaseDemo.java

示例19: render

点赞 2

import squidpony.squidmath.Coord; //导入依赖的package包/类
@Override
public void render () {
    // standard clear the background routine for libGDX
    Gdx.gl.glClearColor(bgColor.r / 255.0f, bgColor.g / 255.0f, bgColor.b / 255.0f, 1.0f);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    stage.getCamera().position.x = pg.getX();
    stage.getCamera().position.y =  pg.getY();

    putMap();
    // if the user clicked, we have a list of moves to perform.
    if(!awaitedMoves.isEmpty())
    {
        // this doesn't check for input, but instead processes and removes Coords from awaitedMoves.
        if (!display.hasActiveAnimations()) {
            Coord m = awaitedMoves.remove(0);
            if(!toCursor.isEmpty())
                toCursor.remove(0);
            move(m.x - player.x, m.y - player.y);
            // this only happens if we just removed the last Coord from awaitedMoves, and it's only then that we need to
            // re-calculate the distances from all cells to the player. We don't need to calculate this information on
            // each part of a many-cell move (just the end), nor do we need to calculate it whenever the mouse moves.
            if (awaitedMoves.isEmpty()) {
                // the next two lines remove any lingering data needed for earlier paths
                playerToCursor.clearGoals();
                playerToCursor.resetMap();
                // the next line marks the player as a "goal" cell, which seems counter-intuitive, but it works because all
                // cells will try to find the distance between themselves and the nearest goal, and once this is found, the
                // distances don't change as long as the goals don't change. Since the mouse will move and new paths will be
                // found, but the player doesn't move until a cell is clicked, the "goal" is the non-changing cell, so the
                // player's position, and the "target" of a pathfinding method like DijkstraMap.findPathPreScanned() is the
                // currently-moused-over cell, which we only need to set where the mouse is being handled.
                playerToCursor.setGoal(player);
                playerToCursor.partialScan(13, blockage);
            }
        }
    }
    // if we are waiting for the player's input and get input, process it.
    else if(input.hasNext()) {
        input.next();
    }
    // we need to do some work with viewports here so the language display (or game info messages in a real game)
    // will display in the same place even though the map view will move around. We have the language stuff set up
    // its viewport so it is in place and won't be altered by the map. Then we just tell the Stage for the language
    // texts to draw.
    languageStage.getViewport().apply(false);
    languageStage.draw();
    // certain classes that use scene2d.ui widgets need to be told to act() to process input.
    stage.act();
    // we have the main stage set itself up after the language stage has already drawn.
    stage.getViewport().apply(false);
    // stage has its own batch and must be explicitly told to draw().
    stage.draw();
    Gdx.graphics.setTitle("SparseLayers Demo running at FPS: " + Gdx.graphics.getFramesPerSecond());
}
 

开发者ID:carlminden,
项目名称:anathema-roguelike,
代码行数:56,
代码来源:SparseDemo.java

示例20: render

点赞 2

import squidpony.squidmath.Coord; //导入依赖的package包/类
@Override
public void render () {
    // standard clear the background routine for libGDX
    Gdx.gl.glClearColor(bgColor.r / 255.0f, bgColor.g / 255.0f, bgColor.b / 255.0f, 1.0f);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
    Gdx.gl.glEnable(GL20.GL_BLEND);

    counter += Gdx.graphics.getDeltaTime() * 15;

    lights = DungeonUtility.generateLightnessModifiers(decoDungeon, counter, '£', '¢');

    // need to display the map every frame, since we clear the screen to avoid artifacts.
    putMap();
    if(!awaitedMoves.isEmpty())
    {
        // extremely similar to the block below that also checks if animations are done
        // this doesn't check for input, but instead processes and removes Points from awaitedMoves.
        if(!display.hasActiveAnimations()) {
            secondsWithoutMoves += Gdx.graphics.getDeltaTime();
            if (secondsWithoutMoves >= 0.01) {
                secondsWithoutMoves = 0;
                Coord m = awaitedMoves.remove(0);
                toCursor.remove(0);
                move(m.x - player.x, m.y - player.y);
                player = m;

            }
        }
    }
    // if we are waiting for the player's input and get input, process it.
    else if(input.hasNext() && !display.hasActiveAnimations()) {
        input.next();
    }
    // if the previous blocks didn't happen, and there are no active animations, then either change the phase
    // (because with no animations running the last phase must have ended), or start a new animation soon.
    else// if(!display.hasActiveAnimations()) {
        //secondsWithoutMoves += Gdx.graphics.getDeltaTime();
        //if (secondsWithoutMoves >= 0.02) {
            //secondsWithoutMoves = 0;
        //}
    //}
    // if we do have an animation running, then how many frames have passed with no animation needs resetting
    //else
    {
        secondsWithoutMoves = 0;
    }

    input.show();

    // stage has its own batch and must be explicitly told to draw().
    stage.getViewport().apply(true);
    stage.draw();
    stage.act();
}
 

开发者ID:tommyettinger,
项目名称:SquidLib-Demos,
代码行数:55,
代码来源:DungeonGame.java

示例21: create

点赞 2

import squidpony.squidmath.Coord; //导入依赖的package包/类
@Override
public void create() {
    super.create();
    rng = new StatefulRNG(0x9876543210L);
    gridWidth = 120;
    gridHeight = 50;
    cellWidth = 8;
    cellHeight = 17;
    layers = new SquidLayers(gridWidth, gridHeight, cellWidth, cellHeight,
            DefaultResources.getStretchableFont());
    layers.setTextSize(cellWidth, cellHeight+1);
    colors = DefaultResources.getSCC().rainbow(0.2f, 1.0f, 144);
    layers.setLightingColor(colors.get(colorIndex));
    fov = new FOV(FOV.SHADOW);
    //PacMazeGenerator maze = new PacMazeGenerator(gridWidth, gridHeight, rng);
    OrganicMapGenerator org = new OrganicMapGenerator(gridWidth, gridHeight, rng);
    DungeonGenerator gen = new DungeonGenerator(gridWidth, gridHeight, rng);
    map = gen.generate(org.generate());
    displayedMap = DungeonUtility.hashesToLines(map);
    indicesBG = DungeonUtility.generateBGPaletteIndices(map);
    indicesFG = DungeonUtility.generatePaletteIndices(map);
    resMap = DungeonUtility.generateResistances(map);
    short[] packed = CoordPacker.pack(gen.getBareDungeon(), '.');
    points = CoordPacker.randomPortion(packed, 10, rng);
    lightness = new int[gridWidth][gridHeight];
    double[][] lit;
    for(Coord pt : points)
    {
        lit = fov.calculateFOV(resMap, pt.x, pt.y, 11, Radius.CIRCLE);
        for (int x = 0; x < gridWidth; x++) {
            for (int y = 0; y < gridHeight; y++) {
                if(lit[x][y] > 0.0)
                    lightness[x][y] += (int)(lit[x][y] * 200);
            }
        }
    }
    for (int x = 0; x < gridWidth; x++) {
        for (int y = 0; y < gridHeight; y++) {
            lightness[x][y] -= 40;
        }
    }
    batch = new SpriteBatch();
    stage = new Stage(new StretchViewport(gridWidth * cellWidth, gridHeight * cellHeight), batch);
    stage.addActor(layers);
}
 

开发者ID:tommyettinger,
项目名称:SquidLib-Demos,
代码行数:46,
代码来源:JTranscDemo.java

示例22: render

点赞 2

import squidpony.squidmath.Coord; //导入依赖的package包/类
@Override
public void render() {
    super.render();
    Gdx.gl.glClearColor(0f, 0f, 0f, 1.0f);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
    ctr += Gdx.graphics.getDeltaTime();
    if(ctr > 0.2) {
        ctr -= 0.2;
        lightness = new int[gridWidth][gridHeight];
        double[][] lit;
        Direction[] dirs = new Direction[4];
        Coord alter;
        for (int i = 0; i < points.size(); i++) {
            Coord pt = points.get(i);
            rng.shuffle(Direction.CARDINALS, dirs);
            for (Direction d : dirs) {
                alter = pt.translate(d);
                if (map[alter.x][alter.y] == '.') {
                    pt = alter;
                    points.set(i, pt);
                    break;
                }
            }
            lit = fov.calculateFOV(resMap, pt.x, pt.y, 7, Radius.CIRCLE);
            for (int x = 0; x < gridWidth; x++) {
                for (int y = 0; y < gridHeight; y++) {
                    if (lit[x][y] > 0.0)
                        lightness[x][y] += (int) (lit[x][y] * 200);
                }
            }
        }
        for (int x = 0; x < gridWidth; x++) {
            for (int y = 0; y < gridHeight; y++) {
                lightness[x][y] -= 40;
            }
        }
    }

    layers.setLightingColor(colors.get(colorIndex = (colorIndex + 1) % colors.size()));
    layers.put(0, 0, displayedMap, indicesFG, indicesBG, lightness);
    stage.draw();

}
 

开发者ID:tommyettinger,
项目名称:SquidLib-Demos,
代码行数:44,
代码来源:JTranscDemo.java

示例23: render

点赞 2

import squidpony.squidmath.Coord; //导入依赖的package包/类
@Override
public void render() {
    // standard clear the background routine for libGDX
    Gdx.gl.glClearColor(bgColor.r / 255.0f, bgColor.g / 255.0f, bgColor.b / 255.0f, 1.0f);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    // need to display the map every frame, since we clear the screen to avoid artifacts.
    putMap();
    // if the user clicked, we have a list of moves to perform.
    if (!awaitedMoves.isEmpty()) {
        if (!display.hasActiveAnimations()) {
            // this doesn't check for input, but instead processes and removes Coords from awaitedMoves.
            Coord m = awaitedMoves.remove(0);
            // sets up the line to the cursor from the player
            line = OrthoLine.lineChars(toCursor);
            if (!toCursor.isEmpty()) // this check is necessary because we can't remove from an empty list
                toCursor.remove(0); // and this just removed the player's current position from the list
            // move takes the relative distance to move for x and y, instead of an absolute position, so this is
            // relative to the player's current position.
            move(m.x - playerPosition.x, m.y - playerPosition.y);
            // this only happens if we just removed the last Coord from awaitedMoves, and it's only then that we need to
            // re-calculate the distances from all cells to the player. We don't need to calculate this information on
            // each part of a many-cell move (just the end), nor do we need to calculate it whenever the mouse moves.
            if (awaitedMoves.isEmpty()) {
                // the next two lines remove any lingering data needed for earlier paths
                playerToCursor.clearGoals();
                playerToCursor.resetMap();
                // the next line marks the player as a "goal" cell, which seems counter-intuitive, but it works because all
                // cells will try to find the distance between themselves and the nearest goal, and once this is found, the
                // distances don't change as long as the goals don't change. Since the mouse will move and new paths will be
                // found, but the player doesn't move until a cell is clicked, the "goal" is the non-changing cell, so the
                // player's position, and the "target" of a pathfinding method like DijkstraMap.findPathPreScanned() is the
                // currently-moused-over cell, which we only need to set where the mouse is being handled.
                playerToCursor.setGoal(playerPosition);
                // DijkstraMap.partialScan only finds the distance to get to a cell if that distance is less than some limit,
                // which is 12 here. It also won't try to find distances through an impassable cell, which here is the blockage
                // GreasedRegion that contains the cells just past the edge of the player's FOV area.
                playerToCursor.partialScan(12, blockage);
            }
        }
    }
    // if we are waiting for the player's input and get input, process it.
    else if (input.hasNext()) {
        input.next();
    }
    // certain classes that use scene2d.ui widgets need to be told to act() to process input.
    stage.act();
    // this next part is a minor optimization; of the next 6 lines of code, all but one are found in
    // the body of stage.draw(). The difference is, we add the line that calls display.drawActor(),
    // which if it was called separately from stage.draw(), would need stage to begin and end its
    // Batch before the same Batch had begin and end called again for just this actor. Each flush of
    // the Batch is slow, and happens on each batch.end(), so saving a flush every frame helps.
    Camera camera = stage.getCamera();
    batch.setProjectionMatrix(camera.combined);
    batch.begin();
    stage.getRoot().draw(batch, 1f);
    display.drawActor(batch, 1f, playerMobile); // this line is different from Stage.draw()
    batch.end();
}
 

开发者ID:tommyettinger,
项目名称:SquidLib-Demos,
代码行数:60,
代码来源:MainApplication.java

示例24: render

点赞 2

import squidpony.squidmath.Coord; //导入依赖的package包/类
@Override
public void render () {
    // standard clear the background routine for libGDX
    Gdx.gl.glClearColor(bgColor.r / 255.0f, bgColor.g / 255.0f, bgColor.b / 255.0f, 1.0f);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    // need to display the map every frame, since we clear the screen to avoid artifacts.
    putMap();
    // if the user clicked, we have a list of moves to perform.
    if(!awaitedMoves.isEmpty())
    {
        // this doesn't check for input, but instead processes and removes Coords from awaitedMoves.
        secondsWithoutMoves += Gdx.graphics.getDeltaTime();
        if (secondsWithoutMoves >= 0.1) {
            secondsWithoutMoves = 0;
            Coord m = awaitedMoves.remove(0);
            toCursor.remove(0);
            move(m.x - player.x, m.y - player.y);
        }
        // this only happens if we just removed the last Coord from awaitedMoves, and it's only then that we need to
        // re-calculate the distances from all cells to the player. We don't need to calculate this information on
        // each part of a many-cell move (just the end), nor do we need to calculate it whenever the mouse moves.
        if(awaitedMoves.isEmpty())
        {
            // the next two lines remove any lingering data needed for earlier paths
            playerToCursor.clearGoals();
            playerToCursor.resetMap();
            // the next line marks the player as a "goal" cell, which seems counter-intuitive, but it works because all
            // cells will try to find the distance between themselves and the nearest goal, and once this is found, the
            // distances don't change as long as the goals don't change. Since the mouse will move and new paths will be
            // found, but the player doesn't move until a cell is clicked, the "goal" is the non-changing cell, so the
            // player's position, and the "target" of a pathfinding method like DijkstraMap.findPathPreScanned() is the
            // currently-moused-over cell, which we only need to set where the mouse is being handled.
            playerToCursor.setGoal(player);
            playerToCursor.scan(null);
        }
    }
    // if we are waiting for the player's input and get input, process it.
    else if(input.hasNext()) {
        input.next();
    }

    // stage has its own batch and must be explicitly told to draw().
    stage.draw();
    // certain classes that use scene2d.ui widgets need to be told to act() to process input.
    stage.act();
}
 

开发者ID:tommyettinger,
项目名称:SquidLib-Demos,
代码行数:48,
代码来源:SquidBasicDemo.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)