mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 11:48:02 +00:00
replace Vector2 with GridPoint2 (originally Point - awt)
This commit is contained in:
@@ -3,7 +3,7 @@ package forge.adventure.stage;
|
|||||||
import com.badlogic.gdx.graphics.Pixmap;
|
import com.badlogic.gdx.graphics.Pixmap;
|
||||||
import com.badlogic.gdx.graphics.Texture;
|
import com.badlogic.gdx.graphics.Texture;
|
||||||
import com.badlogic.gdx.graphics.g2d.Batch;
|
import com.badlogic.gdx.graphics.g2d.Batch;
|
||||||
import com.badlogic.gdx.math.Vector2;
|
import com.badlogic.gdx.math.GridPoint2;
|
||||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||||
import forge.adventure.world.WorldSave;
|
import forge.adventure.world.WorldSave;
|
||||||
|
|
||||||
@@ -37,36 +37,36 @@ public class WorldBackground extends Actor {
|
|||||||
if (chunks == null) {
|
if (chunks == null) {
|
||||||
initialize();
|
initialize();
|
||||||
}
|
}
|
||||||
Vector2 pos = translateFromWorldToChunk(playerX, playerY);
|
GridPoint2 pos = translateFromWorldToChunk(playerX, playerY);
|
||||||
if (currentChunkX != pos.x || currentChunkY != pos.y) {
|
if (currentChunkX != pos.x || currentChunkY != pos.y) {
|
||||||
int xDiff = currentChunkX - (int)pos.x;
|
int xDiff = currentChunkX - pos.x;
|
||||||
int yDiff = currentChunkY - (int)pos.y;
|
int yDiff = currentChunkY - pos.y;
|
||||||
ArrayList<Vector2> points = new ArrayList<>();
|
ArrayList<GridPoint2> points = new ArrayList<GridPoint2>();
|
||||||
for (int x = -1; x < 2; x++) {
|
for (int x = -1; x < 2; x++) {
|
||||||
for (int y = -1; y < 2; y++) {
|
for (int y = -1; y < 2; y++) {
|
||||||
points.add(new Vector2(pos.x + x, pos.y + y));
|
points.add(new GridPoint2(pos.x + x, pos.y + y));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int x = -1; x < 2; x++) {
|
for (int x = -1; x < 2; x++) {
|
||||||
for (int y = -1; y < 2; y++) {
|
for (int y = -1; y < 2; y++) {
|
||||||
Vector2 point = new Vector2(currentChunkX + x, currentChunkY + y);
|
GridPoint2 point = new GridPoint2(currentChunkX + x, currentChunkY + y);
|
||||||
if (points.contains(point))// old Point is part of new points
|
if (points.contains(point))// old Point is part of new points
|
||||||
{
|
{
|
||||||
points.remove(point);
|
points.remove(point);
|
||||||
} else {
|
} else {
|
||||||
if (point.y < 0 || point.x < 0 || point.y >= chunks[0].length || point.x >= chunks.length)
|
if (point.y < 0 || point.x < 0 || point.y >= chunks[0].length || point.x >= chunks.length)
|
||||||
continue;
|
continue;
|
||||||
unLoadChunk((int)point.x, (int)point.y);
|
unLoadChunk(point.x, point.y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (Vector2 point : points) {
|
for (GridPoint2 point : points) {
|
||||||
if (point.y < 0 || point.x < 0 || point.y >= chunks[0].length || point.x >= chunks.length)
|
if (point.y < 0 || point.x < 0 || point.y >= chunks[0].length || point.x >= chunks.length)
|
||||||
continue;
|
continue;
|
||||||
loadChunk((int)point.x, (int)point.y);
|
loadChunk(point.x, point.y);
|
||||||
}
|
}
|
||||||
currentChunkX = (int)pos.x;
|
currentChunkX = pos.x;
|
||||||
currentChunkY = (int)pos.y;
|
currentChunkY = pos.y;
|
||||||
}
|
}
|
||||||
batch.disableBlending();
|
batch.disableBlending();
|
||||||
for (int x = -1; x < 2; x++) {
|
for (int x = -1; x < 2; x++) {
|
||||||
@@ -75,7 +75,7 @@ public class WorldBackground extends Actor {
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
||||||
batch.draw(getChunkTexture((int)pos.x + x, (int)pos.y + y), transChunkToWorld((int)pos.x + x), transChunkToWorld((int)pos.y + y));
|
batch.draw(getChunkTexture(pos.x + x, pos.y + y), transChunkToWorld(pos.x + x), transChunkToWorld(pos.y + y));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
batch.enableBlending();
|
batch.enableBlending();
|
||||||
@@ -154,10 +154,10 @@ public class WorldBackground extends Actor {
|
|||||||
|
|
||||||
for (int x = -1; x < 2; x++) {
|
for (int x = -1; x < 2; x++) {
|
||||||
for (int y = -1; y < 2; y++) {
|
for (int y = -1; y < 2; y++) {
|
||||||
Vector2 point = new Vector2(currentChunkX + x, currentChunkY + y);
|
GridPoint2 point = new GridPoint2(currentChunkX + x, currentChunkY + y);
|
||||||
if (point.y < 0 || point.x < 0 || point.y >= chunks[0].length || point.x >= chunks.length)
|
if (point.y < 0 || point.x < 0 || point.y >= chunks[0].length || point.x >= chunks.length)
|
||||||
continue;
|
continue;
|
||||||
loadChunk((int)point.x, (int)point.y);
|
loadChunk(point.x, point.y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -171,10 +171,10 @@ public class WorldBackground extends Actor {
|
|||||||
return xy * tileSize * chunkSize;
|
return xy * tileSize * chunkSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2 translateFromWorldToChunk(float x, float y) {
|
GridPoint2 translateFromWorldToChunk(float x, float y) {
|
||||||
float worldWidthTiles = x / tileSize;
|
float worldWidthTiles = x / tileSize;
|
||||||
float worldHeightTiles = y / tileSize;
|
float worldHeightTiles = y / tileSize;
|
||||||
return new Vector2((int) worldWidthTiles / chunkSize, (int) worldHeightTiles / chunkSize);
|
return new GridPoint2((int) worldWidthTiles / chunkSize, (int) worldHeightTiles / chunkSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPlayerPos(float x, float y) {
|
public void setPlayerPos(float x, float y) {
|
||||||
|
|||||||
Reference in New Issue
Block a user