mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 04:38: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);
|
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) {
|
public void setProjectionMatrix(Matrix4 matrix) {
|
||||||
batch.setProjectionMatrix(matrix);
|
batch.setProjectionMatrix(matrix);
|
||||||
shapeRenderer.setProjectionMatrix(matrix);
|
shapeRenderer.setProjectionMatrix(matrix);
|
||||||
|
|||||||
@@ -118,6 +118,7 @@ public enum FSkinImage implements FImage {
|
|||||||
|
|
||||||
//Planar Conquest Tiles
|
//Planar Conquest Tiles
|
||||||
HEXAGON_TILE (FSkinProp.IMG_HEXAGON_TILE, SourceFile.PLANAR_CONQUEST),
|
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),
|
WHITE_TILE (FSkinProp.IMG_WHITE_TILE, SourceFile.PLANAR_CONQUEST),
|
||||||
BLUE_TILE (FSkinProp.IMG_BLUE_TILE, SourceFile.PLANAR_CONQUEST),
|
BLUE_TILE (FSkinProp.IMG_BLUE_TILE, SourceFile.PLANAR_CONQUEST),
|
||||||
BLACK_TILE (FSkinProp.IMG_BLACK_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;
|
tileImage = FSkinImage.GREEN_TILE;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
tileImage = null;
|
tileImage = FSkinImage.COLORLESS_TILE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tileImage != null) {
|
//transform image based on grid coordinates so tiles blend together better
|
||||||
g.drawImage(tileImage, x, y, w, h);
|
g.drawImageWithTransforms(tileImage.getTextureRegion(), x, y, w, h, tile.getImageRotation(), tile.flipImageX(), tile.flipImageY());
|
||||||
}
|
|
||||||
g.drawImage(FSkinImage.HEXAGON_TILE, x, y, w, h);
|
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 pedestalWidth = w * 0.8f;
|
||||||
float pedestalHeight = pedestalWidth * walker.getHeight() / walker.getWidth();
|
float pedestalHeight = pedestalWidth * walker.getHeight() / walker.getWidth();
|
||||||
g.drawImage(walker, x + (w - pedestalWidth) / 2, y + h / 2 - pedestalHeight * 0.8f, pedestalWidth, pedestalHeight);
|
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),
|
IMG_TROPHY_SHELF (new int[] {0, 223, 798, 257}, PropType.TROPHY),
|
||||||
|
|
||||||
//planar conquest images
|
//planar conquest images
|
||||||
IMG_HEXAGON_TILE (new int[] {0, 0, 220, 192}, PropType.PLANAR_CONQUEST),
|
IMG_HEXAGON_TILE (new int[] {354, 0, 151, 173}, PropType.PLANAR_CONQUEST),
|
||||||
IMG_WHITE_TILE (new int[] {0, 192, 80, 70}, PropType.PLANAR_CONQUEST),
|
IMG_COLORLESS_TILE (new int[] {0, 354, 151, 173}, PropType.PLANAR_CONQUEST),
|
||||||
IMG_BLUE_TILE (new int[] {80, 192, 80, 70}, PropType.PLANAR_CONQUEST),
|
IMG_WHITE_TILE (new int[] {0, 0, 151, 173}, PropType.PLANAR_CONQUEST),
|
||||||
IMG_BLACK_TILE (new int[] {160, 192, 80, 70}, PropType.PLANAR_CONQUEST),
|
IMG_BLUE_TILE (new int[] {89, 177, 151, 173}, PropType.PLANAR_CONQUEST),
|
||||||
IMG_RED_TILE (new int[] {240, 192, 80, 70}, PropType.PLANAR_CONQUEST),
|
IMG_BLACK_TILE (new int[] {177, 0, 151, 173}, PropType.PLANAR_CONQUEST),
|
||||||
IMG_GREEN_TILE (new int[] {320, 192, 80, 70}, 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
|
//button images
|
||||||
IMG_BTN_START_UP (new int[] {480, 200, 160, 80}, PropType.ICON),
|
IMG_BTN_START_UP (new int[] {480, 200, 160, 80}, PropType.ICON),
|
||||||
|
|||||||
@@ -31,14 +31,14 @@ public class ConquestPlaneMap {
|
|||||||
if (tileWidth == tileWidth0) { return; }
|
if (tileWidth == tileWidth0) { return; }
|
||||||
tileWidth = tileWidth0;
|
tileWidth = tileWidth0;
|
||||||
tileHeight = Math.round((float)tileWidth * (float)FSkinProp.IMG_HEXAGON_TILE.getHeight() / (float)FSkinProp.IMG_HEXAGON_TILE.getWidth());
|
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() {
|
public int getWidth() {
|
||||||
return tileWidth * 3 / 4 * (gridSize - 1) + tileWidth + 2 * padding;
|
return tileWidth * gridSize + tileWidth / 2 + 2 * padding;
|
||||||
}
|
}
|
||||||
public int getHeight() {
|
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) {
|
public HexagonTile getTileAtPoint(float x, float y) {
|
||||||
@@ -61,28 +61,28 @@ public class ConquestPlaneMap {
|
|||||||
scrollLeft -= padding;
|
scrollLeft -= padding;
|
||||||
scrollTop -= padding;
|
scrollTop -= padding;
|
||||||
|
|
||||||
int dx = tileWidth * 3 / 4;
|
int dy = tileHeight * 3 / 4;
|
||||||
int startQ = getIndexInRange((int)Math.floor((float)(scrollLeft - tileWidth) / (float)dx) + 1);
|
int startQ = getIndexInRange((int)Math.floor((float)(scrollLeft - tileWidth * 1.5f) / (float)tileWidth) + 1);
|
||||||
int startR = getIndexInRange((int)Math.floor((float)(scrollTop - tileHeight * 1.5f) / (float)tileHeight) + 1);
|
int startR = getIndexInRange((int)Math.floor((float)(scrollTop - tileHeight) / (float)dy) + 1);
|
||||||
int endQ = getIndexInRange((int)Math.floor((float)(scrollLeft + visibleWidth - tileWidth) / (float)dx) + 2);
|
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 * 1.5f) / (float)tileHeight) + 2);
|
int endR = getIndexInRange((int)Math.floor((float)(scrollTop + visibleHeight - tileHeight) / (float)dy) + 2);
|
||||||
|
|
||||||
int y;
|
int x;
|
||||||
int x = startQ * dx - scrollLeft;
|
int y = startR * dy - scrollTop;
|
||||||
int startY = startR * tileHeight - scrollTop;
|
int startX = startQ * tileWidth - scrollLeft;
|
||||||
for (int q = startQ; q <= endQ; q++) {
|
for (int r = startR; r <= endR; r++) {
|
||||||
y = startY;
|
x = startX;
|
||||||
if (q % 2 == 1) {
|
if (r % 2 == 1) {
|
||||||
y += tileHeight / 2; //odd columns start lower
|
x += tileWidth / 2; //odd columns start lower
|
||||||
}
|
}
|
||||||
for (int r = startR; r <= endR; r++) {
|
for (int q = startQ; q <= endQ; q++) {
|
||||||
HexagonTile tile = grid[q][r];
|
HexagonTile tile = grid[q][r];
|
||||||
if (tile != null) {
|
if (tile != null) {
|
||||||
renderer.draw(tile, x, y, tileWidth, tileHeight);
|
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;
|
double regionAngle = 2 * Math.PI / regionCount;
|
||||||
|
|
||||||
//these assume a tile width of 2, radius of 1
|
//these assume a tile width of 2, radius of 1
|
||||||
double centerX = 1.5 * center;
|
double centerY = 1.5 * center;
|
||||||
double centerY = sqrt3 * (center + 0.5f * (center & 1));
|
double centerX = sqrt3 * (center + 0.5f * (center & 1));
|
||||||
double maxDist = (centerX + centerY) / 2;
|
double maxDist = (centerY + centerX) / 2;
|
||||||
|
|
||||||
//create a circular map, divided into regions
|
//create a circular map, divided into regions
|
||||||
for (int q = 0; q < gridSize; q++) {
|
for (int r = 0; r < gridSize; r++) {
|
||||||
for (int r = 0; r < gridSize; r++) {
|
for (int q = 0; q < gridSize; q++) {
|
||||||
double x = 1.5 * q;
|
double x = sqrt3 * (q + 0.5f * (r & 1));
|
||||||
double y = sqrt3 * (r + 0.5f * (q & 1));
|
double y = 1.5 * r;
|
||||||
double dx = x - centerX;
|
double dx = x - centerX;
|
||||||
double dy = y - centerY;
|
double dy = y - centerY;
|
||||||
double dist = Math.sqrt(dx * dx + dy * dy);
|
double dist = Math.sqrt(dx * dx + dy * dy);
|
||||||
@@ -172,6 +172,34 @@ public class ConquestPlaneMap {
|
|||||||
return colorIndex;
|
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() {
|
public List<HexagonTile> getNeighbors() {
|
||||||
List<HexagonTile> neighbors = new ArrayList<HexagonTile>();
|
List<HexagonTile> neighbors = new ArrayList<HexagonTile>();
|
||||||
addToList(q, r - 1, neighbors); //tile above
|
addToList(q, r - 1, neighbors); //tile above
|
||||||
|
|||||||
Reference in New Issue
Block a user