mirror of
https://github.com/raeleus/Hashtag-DnD.git
synced 2025-07-05 21:20:27 -04:00
Added here, far, and distance options for #createlocation. Resolves #28
This commit is contained in:
parent
92fc206423
commit
45b18947af
3 changed files with 36 additions and 21 deletions
15
Library.js
15
Library.js
|
@ -1,5 +1,9 @@
|
|||
function getRandomInteger(min, max) {
|
||||
return Math.floor(Math.random() * (max - min + 1) ) + min;
|
||||
return Math.floor(Math.random() * (max - min + 1)) + min;
|
||||
}
|
||||
|
||||
function getRandomFloat(min, max) {
|
||||
return Math.random() * (max - min + 1) + min;
|
||||
}
|
||||
|
||||
function getRandom(seed) {
|
||||
|
@ -31,15 +35,6 @@ function rotate(cx, cy, x, y, angle) {
|
|||
}
|
||||
|
||||
function createLocation(x, y, name) {
|
||||
log(`createlocation ${name}:${x},${y}`)
|
||||
if (x == null || y == null) {
|
||||
var cx = x == null ? state.x : x
|
||||
var cy = y == null ? state.y : y
|
||||
var coords = rotate(cx, cy, getRandomInteger(-10, 10) + cx, cy, Math.random() * 360)
|
||||
x = coords[0]
|
||||
y = coords[1]
|
||||
}
|
||||
|
||||
x = Math.round(x)
|
||||
y = Math.round(y)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue