-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.html
68 lines (60 loc) · 2.01 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<!DOCTYPE html>
<html>
<head>
<script src="https://cdn.jsdelivr.net/npm/p5"></script>
</head>
<style>
body {
background-color: black;
}
</style>
<body>
<script>
function randomRange(randomSeed, name, min, max) {
return Math.floor(Math.random() * (max - min + 1) + min)
}
const randomSeed_ = 1
const settings = {
seed: randomRange(randomSeed_, "seed", 1, 1000000),
planetSize: randomRange(randomSeed_, "planetSize", 30, 100),
planetType: randomRange(randomSeed_, "planetType", 0, 10) < 4 ? 0 : 1,
hue: randomRange(randomSeed_, "baseHue", 0, 360),
}
settings.hasRings = settings.planetType === 0 && randomRange(randomSeed_, "hasRings", 0, 10) < 3
const observation = randomRange(randomSeed_, "numMoons", 0, 100)
if (observation < 25) {
settings.numMoons = 1
} else if (observation < 37) {
settings.numMoons = 2
} else if (observation < 40) {
settings.numMoons = 3
} else {
settings.numMoons = 0
}
settings.hasWater = settings.planetType === 1 && randomRange(randomSeed_, "hasWater", 0, 10) < 3
let seed = settings.seed //randomRange(0, 1000000)
let planetSize = settings.planetSize //randomRange(30, 100)
let hasRings = settings.hasRings // randomRange(0, 2) > 0.5 // random() < 0.5 // 50% chance
let numMoons = settings.numMoons // randomRange(1, 3) // floor(random(0, 5)) // Up to 3 moons
let planetType = settings.planetType // randomRange(0, 3) === 2 ? 1 : 0 // 0 = gas, 1 = solid
let baseHue = settings.hue // randomRange(0, 360)
let hasWater = settings.hasWater // 1 //randomRange(0, 1)
console.log(
JSON.stringify(
{
planetSize,
hasRings,
numMoons,
planetType,
hasWater,
baseHue,
seed,
},
null,
2,
),
)
</script>
<script src="./base.js"></script>
</body>
</html>