Skip to content

Commit 96fae9d

Browse files
committed
Fix tilemap scene layout offset
1 parent 6c7eb3d commit 96fae9d

File tree

5 files changed

+21
-8
lines changed

5 files changed

+21
-8
lines changed

src/model/tilemap/worldmap/zone/surface/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export class SurfaceZone {
4242
const zoneCanvasPoint = Point.plus(canvasPoint, [ySize, xSize])
4343
const surface = this.get(zonePoint)
4444
let color = surface.color
45-
if (Point.equals(tilePoint, [39, 8])) {
45+
if (Point.equals(tilePoint, [43, 4])) {
4646
const regionId = this._regionGrid.get(zonePoint)
4747
const regionColor = this._regionColorMap.get(regionId)
4848
color = regionColor.average(color).average(color)

src/model/tilemap/worldmap/zone/surface/model.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,10 @@ function isWaterChannel(context, direction) {
7575
}
7676

7777

78-
function selectRegionsInLine(context, target, direction) {
78+
function selectRegionsInLine(context, midPoint, direction) {
7979
const {worldPoint, regionGrid, zoneRect} = context
8080
const regions = []
81+
direction.axis
8182
// regionGrid.get(zonePoint)
8283
return regions
8384
}
@@ -91,6 +92,9 @@ function buildLandMaskGrid(context) {
9192
const relativePoint = Point.multiplyScalar(worldPoint, zoneRect.width)
9293
const noiseRect = Rect.multiply(rect, zoneRect.width)
9394
return Grid.fromRect(zoneRect, zonePoint => {
95+
// if (! world.surface.isBorder(worldPoint)) {
96+
// return world.surface.isLand(worldPoint)
97+
// }
9498
const noisePoint = Point.plus(relativePoint, zonePoint)
9599
const noise = world.noise.get4DZoneOutline(noiseRect, noisePoint)
96100
return noise > SURFACE_NOISE_RATIO

src/model/tilemap/worldmap/zone/surface/region.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { EvenPointSampling } from '/src/lib/geometry/point/sampling'
77

88

99
const EMPTY = null
10-
const REGION_SCALE = [2, 3] // distance between region origins
10+
const REGION_SCALE = 3 // distance between region origins
1111
const REGION_GROWTH = [2, 1]
1212
const REGION_CHANCE = .1
1313

@@ -16,7 +16,7 @@ export function buildRegionGridMap(context) {
1616
const {zoneRect} = context
1717
// create a grid with many regions fragmenting the zone map
1818
const regionGrid = Grid.fromRect(zoneRect, () => EMPTY)
19-
const origins = EvenPointSampling.create(zoneRect, Random.choiceFrom(REGION_SCALE))
19+
const origins = EvenPointSampling.create(zoneRect, REGION_SCALE)
2020
const originMap = new Map()
2121
const regionColorMap = new Map()
2222
// region type {id: water | land}

src/ui/css/tilemap.css

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@
3535
padding: 0 .5rem;
3636
}
3737

38+
.UITileMap .UITileMapScene .UITileMapSceneView {
39+
position: relative;
40+
}
41+
3842
.UITileMap .UITileMapScene .UITileMapSceneContent {
3943
background-color: #FFF;
4044
background-image: linear-gradient(45deg, #E8E8E8 25%, transparent 25%),
@@ -43,10 +47,13 @@
4347
linear-gradient(-45deg, transparent 75%, #E8E8E8 75%);
4448
background-size: 20px 20px;
4549
background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
46-
position: relative;
50+
position: absolute;
51+
top: 0px;
52+
right: 0px;
53+
bottom: 0px;
54+
left: 0px;
4755
}
4856

49-
5057
.UITileMap .UITileMapScene .MouseTrack {
5158
box-shadow: inset 0 0 .5rem #000;
5259
}

src/ui/tilemap/scene.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@ const ZOOM_INCREMENT = 10
1616
export function UITileMapScene(props) {
1717
const viewportRef = useRef(null)
1818
const viewport = useResize(viewportRef)
19-
return <section className="UITileMapScene" ref={viewportRef}>
19+
return <section className="UITileMapScene">
2020
<section className="UITileMapSceneDashboard">
2121
<Text>Seed: {props.tileMap.seed}, {props.tileMap.getDescription()}</Text>
2222
</section>
23-
<UITileMapSceneContent viewport={viewport} {...props} />
23+
<section className="UITileMapSceneView" ref={viewportRef}>
24+
<UITileMapSceneContent viewport={viewport} {...props} />
25+
</section>
2426
</section>
2527
}
2628

0 commit comments

Comments
 (0)