mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
Support better tiles
This commit is contained in:
@@ -560,6 +560,12 @@ public class Graphics {
|
||||
batch.draw(image, adjustX(x), adjustY(y, h), w, h, 0, 0, image.getWidth(), image.getHeight(), false, true);
|
||||
}
|
||||
|
||||
public void drawImageWithTransforms(TextureRegion image, float x, float y, float w, float h, float rotation, boolean flipX, boolean flipY) {
|
||||
float originX = x + w / 2;
|
||||
float originY = y + h / 2;
|
||||
batch.draw(image.getTexture(), adjustX(x), adjustY(y, h), originX - x, h - (originY - y), w, h, 1, 1, rotation, image.getRegionX(), image.getRegionY(), image.getRegionWidth(), image.getRegionHeight(), flipX, flipY);
|
||||
}
|
||||
|
||||
public void setProjectionMatrix(Matrix4 matrix) {
|
||||
batch.setProjectionMatrix(matrix);
|
||||
shapeRenderer.setProjectionMatrix(matrix);
|
||||
|
||||
@@ -118,6 +118,7 @@ public enum FSkinImage implements FImage {
|
||||
|
||||
//Planar Conquest Tiles
|
||||
HEXAGON_TILE (FSkinProp.IMG_HEXAGON_TILE, SourceFile.PLANAR_CONQUEST),
|
||||
COLORLESS_TILE (FSkinProp.IMG_COLORLESS_TILE, SourceFile.PLANAR_CONQUEST),
|
||||
WHITE_TILE (FSkinProp.IMG_WHITE_TILE, SourceFile.PLANAR_CONQUEST),
|
||||
BLUE_TILE (FSkinProp.IMG_BLUE_TILE, SourceFile.PLANAR_CONQUEST),
|
||||
BLACK_TILE (FSkinProp.IMG_BLACK_TILE, SourceFile.PLANAR_CONQUEST),
|
||||
|
||||
@@ -267,20 +267,19 @@ public class CommandCenterScreen extends FScreen implements IVCommandCenter {
|
||||
tileImage = FSkinImage.GREEN_TILE;
|
||||
break;
|
||||
default:
|
||||
tileImage = null;
|
||||
tileImage = FSkinImage.COLORLESS_TILE;
|
||||
break;
|
||||
}
|
||||
|
||||
if (tileImage != null) {
|
||||
g.drawImage(tileImage, x, y, w, h);
|
||||
}
|
||||
//transform image based on grid coordinates so tiles blend together better
|
||||
g.drawImageWithTransforms(tileImage.getTextureRegion(), x, y, w, h, tile.getImageRotation(), tile.flipImageX(), tile.flipImageY());
|
||||
g.drawImage(FSkinImage.HEXAGON_TILE, x, y, w, h);
|
||||
|
||||
if (x < getWidth() / 2 && x + w > getWidth() / 2 && y < getHeight() / 2 && y + h > getHeight() / 2) {
|
||||
/*if (x < getWidth() / 2 && x + w > getWidth() / 2 && y < getHeight() / 2 && y + h > getHeight() / 2) {
|
||||
float pedestalWidth = w * 0.8f;
|
||||
float pedestalHeight = pedestalWidth * walker.getHeight() / walker.getWidth();
|
||||
g.drawImage(walker, x + (w - pedestalWidth) / 2, y + h / 2 - pedestalHeight * 0.8f, pedestalWidth, pedestalHeight);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 61 KiB After Width: | Height: | Size: 346 KiB |
@@ -242,12 +242,13 @@ public enum FSkinProp {
|
||||
IMG_TROPHY_SHELF (new int[] {0, 223, 798, 257}, PropType.TROPHY),
|
||||
|
||||
//planar conquest images
|
||||
IMG_HEXAGON_TILE (new int[] {0, 0, 220, 192}, PropType.PLANAR_CONQUEST),
|
||||
IMG_WHITE_TILE (new int[] {0, 192, 80, 70}, PropType.PLANAR_CONQUEST),
|
||||
IMG_BLUE_TILE (new int[] {80, 192, 80, 70}, PropType.PLANAR_CONQUEST),
|
||||
IMG_BLACK_TILE (new int[] {160, 192, 80, 70}, PropType.PLANAR_CONQUEST),
|
||||
IMG_RED_TILE (new int[] {240, 192, 80, 70}, PropType.PLANAR_CONQUEST),
|
||||
IMG_GREEN_TILE (new int[] {320, 192, 80, 70}, PropType.PLANAR_CONQUEST),
|
||||
IMG_HEXAGON_TILE (new int[] {354, 0, 151, 173}, PropType.PLANAR_CONQUEST),
|
||||
IMG_COLORLESS_TILE (new int[] {0, 354, 151, 173}, PropType.PLANAR_CONQUEST),
|
||||
IMG_WHITE_TILE (new int[] {0, 0, 151, 173}, PropType.PLANAR_CONQUEST),
|
||||
IMG_BLUE_TILE (new int[] {89, 177, 151, 173}, PropType.PLANAR_CONQUEST),
|
||||
IMG_BLACK_TILE (new int[] {177, 0, 151, 173}, PropType.PLANAR_CONQUEST),
|
||||
IMG_RED_TILE (new int[] {266, 177, 151, 173}, PropType.PLANAR_CONQUEST),
|
||||
IMG_GREEN_TILE (new int[] {177, 354, 151, 173}, PropType.PLANAR_CONQUEST),
|
||||
|
||||
//button images
|
||||
IMG_BTN_START_UP (new int[] {480, 200, 160, 80}, PropType.ICON),
|
||||
|
||||
@@ -31,14 +31,14 @@ public class ConquestPlaneMap {
|
||||
if (tileWidth == tileWidth0) { return; }
|
||||
tileWidth = tileWidth0;
|
||||
tileHeight = Math.round((float)tileWidth * (float)FSkinProp.IMG_HEXAGON_TILE.getHeight() / (float)FSkinProp.IMG_HEXAGON_TILE.getWidth());
|
||||
padding = tileHeight / 2;
|
||||
padding = tileWidth / 2;
|
||||
}
|
||||
|
||||
public int getWidth() {
|
||||
return tileWidth * 3 / 4 * (gridSize - 1) + tileWidth + 2 * padding;
|
||||
return tileWidth * gridSize + tileWidth / 2 + 2 * padding;
|
||||
}
|
||||
public int getHeight() {
|
||||
return tileHeight * gridSize + tileHeight / 2 + 2 * padding;
|
||||
return tileHeight * 3 / 4 * (gridSize - 1) + tileHeight + 2 * padding;
|
||||
}
|
||||
|
||||
public HexagonTile getTileAtPoint(float x, float y) {
|
||||
@@ -61,28 +61,28 @@ public class ConquestPlaneMap {
|
||||
scrollLeft -= padding;
|
||||
scrollTop -= padding;
|
||||
|
||||
int dx = tileWidth * 3 / 4;
|
||||
int startQ = getIndexInRange((int)Math.floor((float)(scrollLeft - tileWidth) / (float)dx) + 1);
|
||||
int startR = getIndexInRange((int)Math.floor((float)(scrollTop - tileHeight * 1.5f) / (float)tileHeight) + 1);
|
||||
int endQ = getIndexInRange((int)Math.floor((float)(scrollLeft + visibleWidth - tileWidth) / (float)dx) + 2);
|
||||
int endR = getIndexInRange((int)Math.floor((float)(scrollTop + visibleHeight - tileHeight * 1.5f) / (float)tileHeight) + 2);
|
||||
int dy = tileHeight * 3 / 4;
|
||||
int startQ = getIndexInRange((int)Math.floor((float)(scrollLeft - tileWidth * 1.5f) / (float)tileWidth) + 1);
|
||||
int startR = getIndexInRange((int)Math.floor((float)(scrollTop - tileHeight) / (float)dy) + 1);
|
||||
int endQ = getIndexInRange((int)Math.floor((float)(scrollLeft + visibleWidth - tileWidth * 1.5f) / (float)tileWidth) + 2);
|
||||
int endR = getIndexInRange((int)Math.floor((float)(scrollTop + visibleHeight - tileHeight) / (float)dy) + 2);
|
||||
|
||||
int y;
|
||||
int x = startQ * dx - scrollLeft;
|
||||
int startY = startR * tileHeight - scrollTop;
|
||||
for (int q = startQ; q <= endQ; q++) {
|
||||
y = startY;
|
||||
if (q % 2 == 1) {
|
||||
y += tileHeight / 2; //odd columns start lower
|
||||
}
|
||||
int x;
|
||||
int y = startR * dy - scrollTop;
|
||||
int startX = startQ * tileWidth - scrollLeft;
|
||||
for (int r = startR; r <= endR; r++) {
|
||||
x = startX;
|
||||
if (r % 2 == 1) {
|
||||
x += tileWidth / 2; //odd columns start lower
|
||||
}
|
||||
for (int q = startQ; q <= endQ; q++) {
|
||||
HexagonTile tile = grid[q][r];
|
||||
if (tile != null) {
|
||||
renderer.draw(tile, x, y, tileWidth, tileHeight);
|
||||
}
|
||||
y += tileHeight;
|
||||
x += tileWidth;
|
||||
}
|
||||
x += dx;
|
||||
y += dy;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,15 +109,15 @@ public class ConquestPlaneMap {
|
||||
double regionAngle = 2 * Math.PI / regionCount;
|
||||
|
||||
//these assume a tile width of 2, radius of 1
|
||||
double centerX = 1.5 * center;
|
||||
double centerY = sqrt3 * (center + 0.5f * (center & 1));
|
||||
double maxDist = (centerX + centerY) / 2;
|
||||
double centerY = 1.5 * center;
|
||||
double centerX = sqrt3 * (center + 0.5f * (center & 1));
|
||||
double maxDist = (centerY + centerX) / 2;
|
||||
|
||||
//create a circular map, divided into regions
|
||||
for (int q = 0; q < gridSize; q++) {
|
||||
for (int r = 0; r < gridSize; r++) {
|
||||
double x = 1.5 * q;
|
||||
double y = sqrt3 * (r + 0.5f * (q & 1));
|
||||
for (int q = 0; q < gridSize; q++) {
|
||||
double x = sqrt3 * (q + 0.5f * (r & 1));
|
||||
double y = 1.5 * r;
|
||||
double dx = x - centerX;
|
||||
double dy = y - centerY;
|
||||
double dist = Math.sqrt(dx * dx + dy * dy);
|
||||
@@ -172,6 +172,34 @@ public class ConquestPlaneMap {
|
||||
return colorIndex;
|
||||
}
|
||||
|
||||
public float getImageRotation() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public boolean flipImageX() {
|
||||
/*if (q % 2 == 1) {
|
||||
if (q % 4 == 1) {
|
||||
return r % 2 == 1;
|
||||
}
|
||||
return r % 2 == 0;
|
||||
}*/
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean flipImageY() {
|
||||
/*if (q % 2 == 0) {
|
||||
if (q % 4 == 0) {
|
||||
return r % 2 == 1;
|
||||
}
|
||||
return r % 2 == 0;
|
||||
}
|
||||
if (q % 4 == 1) {
|
||||
return r % 2 == 1;
|
||||
}
|
||||
return r % 2 == 0;*/
|
||||
return false;
|
||||
}
|
||||
|
||||
public List<HexagonTile> getNeighbors() {
|
||||
List<HexagonTile> neighbors = new ArrayList<HexagonTile>();
|
||||
addToList(q, r - 1, neighbors); //tile above
|
||||
|
||||
Reference in New Issue
Block a user