Skip to content

Commit eb6bcd7

Browse files
committed
Show river on biome
1 parent 4e31f1d commit eb6bcd7

File tree

6 files changed

+20
-11
lines changed

6 files changed

+20
-11
lines changed

src/model/world/basin/chunk/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export class BasinChunk {
2020
}
2121

2222
draw(props, params) {
23-
const {canvas, canvasPoint, tilePoint, tileSize, world, chunk} = props
23+
const {canvas, canvasPoint, tileSize, chunk} = props
2424
const chunkTileSize = tileSize / chunk.size
2525
if (tileSize < 10) return
2626
for (let x=0; x < chunk.size; x++) {

src/model/world/basin/model.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ import {
1717

1818

1919
const NO_BASIN_ID = null
20-
const FILL_CHANCE = .2 // chance of fill growing
21-
const FILL_GROWTH = 3
22-
const MIDPOINT_RATE = .6 //random point in 60% of chunkrect area around center point
23-
const MIDDLE_OFFSET = 2 // used to avoid midpoints on middle
20+
const FILL_CHANCE = .3 // chance of fill growing
21+
const FILL_GROWTH = 4
22+
const MIDPOINT_RATE = .7 //random point in 60% of chunkrect area around center point
23+
const MIDDLE_OFFSET = 1 // used to avoid midpoints on middle
2424

2525

2626
export function buildBasinModel(context) {

src/model/world/biome/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,11 @@ export class BiomeLayer {
118118
}
119119

120120
draw(props, params) {
121-
const {canvas, canvasPoint, tileSize, tilePoint} = props
121+
const {world, canvas, canvasPoint, tileSize, tilePoint} = props
122122
let color = this.get(tilePoint).color
123123
canvas.rect(canvasPoint, tileSize, color.toHex())
124+
if (params.get("showRivers")) {
125+
world.river.drawOnlyRivers(props, params)
126+
}
124127
}
125128
}

src/model/world/river/chunk/index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Point } from '/src/lib/geometry/point'
22
import { Color } from '/src/lib/color'
3+
34
import { buildRiverGrid } from './model'
45

56

@@ -34,9 +35,9 @@ export class RiverChunk {
3435
if (this.has(chunkPoint)) {
3536
canvas.rect(chunkCanvasPoint, chunkTileSize, color)
3637
}
37-
// if (Point.equals(basin.midpoint, chunkPoint)) {
38-
// canvas.rect(chunkCanvasPoint, chunkTileSize, Color.RED.toHex())
39-
// }
38+
if (Point.equals(basin.midpoint, chunkPoint)) {
39+
canvas.rect(chunkCanvasPoint, chunkTileSize, Color.RED.toHex())
40+
}
4041
}
4142
}
4243
}

src/model/world/river/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,13 @@ export class RiverLayer {
7979
}
8080

8181
draw(props, params) {
82-
const {canvas, canvasPoint, tileSize, tilePoint, world} = props
82+
const {world} = props
8383
world.surface.draw(props, params)
84+
this.drawOnlyRivers(props, params)
85+
}
86+
87+
drawOnlyRivers(props, params) {
88+
const {canvas, canvasPoint, tileSize, tilePoint, world} = props
8489
if (! params.get('showRivers') || ! this.has(tilePoint)) {
8590
return
8691
}

src/model/world/surface/model.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const MINIMUN_OCEAN_RATIO = 2
2020
const MINIMUN_SEA_RATIO = .05
2121
const MINIMUN_CONTINENT_RATIO = 1
2222

23-
export const EMPTY = null
23+
const EMPTY = null
2424

2525

2626
export function buildSurfaceModel(context) {

0 commit comments

Comments
 (0)