Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import static nomadrealms.context.game.world.map.area.coordinate.ChunkCoordinate.CHUNK_SIZE;

import engine.common.math.Vector2f;
import engine.visuals.constraint.box.ConstraintPair;
import nomadrealms.context.game.world.map.area.coordinate.ChunkCoordinate;
import nomadrealms.context.game.world.map.area.coordinate.TileCoordinate;
import nomadrealms.context.game.world.map.generation.MapGenerationStrategy;
Expand Down Expand Up @@ -53,14 +54,14 @@ public void render(RenderingEnvironment re) {
// TODO: instanced rendering - render all tiles in a chunk together
}

private Vector2f indexPosition() {
return new Vector2f(
private ConstraintPair indexPosition() {
return new ConstraintPair(new Vector2f(
coord.x() * TILE_HORIZONTAL_SPACING,
coord.y() * TILE_VERTICAL_SPACING)
.scale(CHUNK_SIZE);
.scale(CHUNK_SIZE));
}

public Vector2f pos() {
public ConstraintPair pos() {
return zone.pos().add(indexPosition());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import static nomadrealms.context.game.world.map.area.coordinate.ZoneCoordinate.zoneCoordinateOf;

import engine.common.math.Vector2f;
import engine.visuals.constraint.box.ConstraintPair;
import nomadrealms.context.game.world.World;
import nomadrealms.context.game.world.map.area.coordinate.ChunkCoordinate;
import nomadrealms.context.game.world.map.area.coordinate.RegionCoordinate;
Expand Down Expand Up @@ -55,11 +56,11 @@ public void render(RenderingEnvironment re, Vector2f origin) {
lazyGetZone(zoneCoord).render(re, origin);
}

private Vector2f indexPosition() {
return new Vector2f(coord.x() * TILE_HORIZONTAL_SPACING, coord.y() * TILE_VERTICAL_SPACING).scale(REGION_SIZE * ZONE_SIZE * CHUNK_SIZE);
private ConstraintPair indexPosition() {
return new ConstraintPair(new Vector2f(coord.x() * TILE_HORIZONTAL_SPACING, coord.y() * TILE_VERTICAL_SPACING).scale(REGION_SIZE * ZONE_SIZE * CHUNK_SIZE));
}

public Vector2f pos() {
public ConstraintPair pos() {
return indexPosition();
}

Expand Down
10 changes: 5 additions & 5 deletions src/main/java/nomadrealms/context/game/world/map/area/Tile.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ public Tile(Chunk chunk, TileCoordinate coord) {
*
* @return
*/
private Vector2f indexPosition() {
private ConstraintPair indexPosition() {
Vector2f toCenter = new Vector2f(TILE_RADIUS * SIDE_LENGTH, TILE_RADIUS * HEIGHT);
Vector2f base = new Vector2f(coord.x() * TILE_HORIZONTAL_SPACING, coord.y() * TILE_VERTICAL_SPACING);
Vector2f columnOffset = new Vector2f(0, (coord.x() % 2 == 0) ? 0 : TILE_RADIUS * HEIGHT);
return toCenter.add(base).add(columnOffset);
return new ConstraintPair(toCenter.add(base).add(columnOffset));
}

/**
Expand All @@ -82,8 +82,8 @@ private Vector2f indexPosition() {
* @param re rendering environment
*/
public void render(RenderingEnvironment re) {
Vector2f position = chunk.pos().add(indexPosition());
Vector2f screenPosition = position.sub(re.camera.position().vector());
ConstraintPair position = chunk.pos().add(indexPosition());
Vector2f screenPosition = position.sub(re.camera.position()).vector();
render(re, screenPosition, 1);
if (re.showDebugInfo) {
re.textRenderer
Expand Down Expand Up @@ -235,7 +235,7 @@ public TileCoordinate coord() {
}

public ConstraintPair getScreenPosition(RenderingEnvironment re) {
return new ConstraintPair(chunk.pos().add(indexPosition())).sub(re.camera.position());
return chunk.pos().add(indexPosition()).sub(re.camera.position());
}

public Appendage[] validAppendages() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.util.Random;

import engine.common.math.Vector2f;
import engine.visuals.constraint.box.ConstraintPair;
import nomadrealms.context.game.world.World;
import nomadrealms.context.game.world.map.area.coordinate.ChunkCoordinate;
import nomadrealms.context.game.world.map.area.coordinate.TileCoordinate;
Expand Down Expand Up @@ -134,16 +135,16 @@ public PointsGenerationStep pointsGenerationStep() {
return pointsGenerationStep;
}

private Vector2f indexPosition() {
return new Vector2f(coord.x() * TILE_HORIZONTAL_SPACING, coord.y() * TILE_VERTICAL_SPACING).scale(ZONE_SIZE * CHUNK_SIZE);
private ConstraintPair indexPosition() {
return new ConstraintPair(new Vector2f(coord.x() * TILE_HORIZONTAL_SPACING, coord.y() * TILE_VERTICAL_SPACING).scale(ZONE_SIZE * CHUNK_SIZE));
}

/**
* Returns the absolute position of the top left corner of this zone.
*
* @return the absolute position of the top left corner of this zone
*/
public Vector2f pos() {
public ConstraintPair pos() {
return region.pos().add(indexPosition());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public int size() {
public void render(Zone zone, RenderingEnvironment re) {
float zoneSizeHorizontal = ZONE_SIZE * CHUNK_SIZE * TILE_HORIZONTAL_SPACING;
float zoneSizeVertical = ZONE_SIZE * CHUNK_SIZE * TILE_VERTICAL_SPACING;
Vector2f screenPos = position.scale(zoneSizeHorizontal, zoneSizeVertical).add(zone.pos()).sub(re.camera.position().vector());
Vector2f screenPos = position.scale(zoneSizeHorizontal, zoneSizeVertical).add(zone.pos().vector()).sub(re.camera.position().vector());
re.circleShaderProgram
.set("color", toRangedVector(rgb(100, 0, 0)))
.set("transform", new Matrix4f(screenPos.x(), screenPos.y(), 100, 100, re.glContext))
Expand Down